1. Packages
  2. OpenStack
  3. API Docs
  4. compute
  5. FloatingIpAssociate
OpenStack v3.15.1 published on Thursday, Feb 1, 2024 by Pulumi

openstack.compute.FloatingIpAssociate

Explore with Pulumi AI

openstack logo
OpenStack v3.15.1 published on Thursday, Feb 1, 2024 by Pulumi

    Associate a floating IP to an instance.

    Example Usage

    Automatically detect the correct network

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using OpenStack = Pulumi.OpenStack;
    
    return await Deployment.RunAsync(() => 
    {
        var instance1 = new OpenStack.Compute.Instance("instance1", new()
        {
            ImageId = "ad091b52-742f-469e-8f3c-fd81cadf0743",
            FlavorId = "3",
            KeyPair = "my_key_pair_name",
            SecurityGroups = new[]
            {
                "default",
            },
        });
    
        var fip1FloatingIp = new OpenStack.Networking.FloatingIp("fip1FloatingIp", new()
        {
            Pool = "my_pool",
        });
    
        var fip1FloatingIpAssociate = new OpenStack.Compute.FloatingIpAssociate("fip1FloatingIpAssociate", new()
        {
            FloatingIp = fip1FloatingIp.Address,
            InstanceId = instance1.Id,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-openstack/sdk/v3/go/openstack/compute"
    	"github.com/pulumi/pulumi-openstack/sdk/v3/go/openstack/networking"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		instance1, err := compute.NewInstance(ctx, "instance1", &compute.InstanceArgs{
    			ImageId:  pulumi.String("ad091b52-742f-469e-8f3c-fd81cadf0743"),
    			FlavorId: pulumi.String("3"),
    			KeyPair:  pulumi.String("my_key_pair_name"),
    			SecurityGroups: pulumi.StringArray{
    				pulumi.String("default"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		fip1FloatingIp, err := networking.NewFloatingIp(ctx, "fip1FloatingIp", &networking.FloatingIpArgs{
    			Pool: pulumi.String("my_pool"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewFloatingIpAssociate(ctx, "fip1FloatingIpAssociate", &compute.FloatingIpAssociateArgs{
    			FloatingIp: fip1FloatingIp.Address,
    			InstanceId: instance1.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.openstack.compute.Instance;
    import com.pulumi.openstack.compute.InstanceArgs;
    import com.pulumi.openstack.networking.FloatingIp;
    import com.pulumi.openstack.networking.FloatingIpArgs;
    import com.pulumi.openstack.compute.FloatingIpAssociate;
    import com.pulumi.openstack.compute.FloatingIpAssociateArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var instance1 = new Instance("instance1", InstanceArgs.builder()        
                .imageId("ad091b52-742f-469e-8f3c-fd81cadf0743")
                .flavorId(3)
                .keyPair("my_key_pair_name")
                .securityGroups("default")
                .build());
    
            var fip1FloatingIp = new FloatingIp("fip1FloatingIp", FloatingIpArgs.builder()        
                .pool("my_pool")
                .build());
    
            var fip1FloatingIpAssociate = new FloatingIpAssociate("fip1FloatingIpAssociate", FloatingIpAssociateArgs.builder()        
                .floatingIp(fip1FloatingIp.address())
                .instanceId(instance1.id())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_openstack as openstack
    
    instance1 = openstack.compute.Instance("instance1",
        image_id="ad091b52-742f-469e-8f3c-fd81cadf0743",
        flavor_id="3",
        key_pair="my_key_pair_name",
        security_groups=["default"])
    fip1_floating_ip = openstack.networking.FloatingIp("fip1FloatingIp", pool="my_pool")
    fip1_floating_ip_associate = openstack.compute.FloatingIpAssociate("fip1FloatingIpAssociate",
        floating_ip=fip1_floating_ip.address,
        instance_id=instance1.id)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as openstack from "@pulumi/openstack";
    
    const instance1 = new openstack.compute.Instance("instance1", {
        imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
        flavorId: "3",
        keyPair: "my_key_pair_name",
        securityGroups: ["default"],
    });
    const fip1FloatingIp = new openstack.networking.FloatingIp("fip1FloatingIp", {pool: "my_pool"});
    const fip1FloatingIpAssociate = new openstack.compute.FloatingIpAssociate("fip1FloatingIpAssociate", {
        floatingIp: fip1FloatingIp.address,
        instanceId: instance1.id,
    });
    
    resources:
      instance1:
        type: openstack:compute:Instance
        properties:
          imageId: ad091b52-742f-469e-8f3c-fd81cadf0743
          flavorId: 3
          keyPair: my_key_pair_name
          securityGroups:
            - default
      fip1FloatingIp:
        type: openstack:networking:FloatingIp
        properties:
          pool: my_pool
      fip1FloatingIpAssociate:
        type: openstack:compute:FloatingIpAssociate
        properties:
          floatingIp: ${fip1FloatingIp.address}
          instanceId: ${instance1.id}
    

    Explicitly set the network to attach to

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using OpenStack = Pulumi.OpenStack;
    
    return await Deployment.RunAsync(() => 
    {
        var instance1 = new OpenStack.Compute.Instance("instance1", new()
        {
            ImageId = "ad091b52-742f-469e-8f3c-fd81cadf0743",
            FlavorId = "3",
            KeyPair = "my_key_pair_name",
            SecurityGroups = new[]
            {
                "default",
            },
            Networks = new[]
            {
                new OpenStack.Compute.Inputs.InstanceNetworkArgs
                {
                    Name = "my_network",
                },
                new OpenStack.Compute.Inputs.InstanceNetworkArgs
                {
                    Name = "default",
                },
            },
        });
    
        var fip1FloatingIp = new OpenStack.Networking.FloatingIp("fip1FloatingIp", new()
        {
            Pool = "my_pool",
        });
    
        var fip1FloatingIpAssociate = new OpenStack.Compute.FloatingIpAssociate("fip1FloatingIpAssociate", new()
        {
            FloatingIp = fip1FloatingIp.Address,
            InstanceId = instance1.Id,
            FixedIp = instance1.Networks.Apply(networks => networks[1].FixedIpV4),
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-openstack/sdk/v3/go/openstack/compute"
    	"github.com/pulumi/pulumi-openstack/sdk/v3/go/openstack/networking"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		instance1, err := compute.NewInstance(ctx, "instance1", &compute.InstanceArgs{
    			ImageId:  pulumi.String("ad091b52-742f-469e-8f3c-fd81cadf0743"),
    			FlavorId: pulumi.String("3"),
    			KeyPair:  pulumi.String("my_key_pair_name"),
    			SecurityGroups: pulumi.StringArray{
    				pulumi.String("default"),
    			},
    			Networks: compute.InstanceNetworkArray{
    				&compute.InstanceNetworkArgs{
    					Name: pulumi.String("my_network"),
    				},
    				&compute.InstanceNetworkArgs{
    					Name: pulumi.String("default"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		fip1FloatingIp, err := networking.NewFloatingIp(ctx, "fip1FloatingIp", &networking.FloatingIpArgs{
    			Pool: pulumi.String("my_pool"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewFloatingIpAssociate(ctx, "fip1FloatingIpAssociate", &compute.FloatingIpAssociateArgs{
    			FloatingIp: fip1FloatingIp.Address,
    			InstanceId: instance1.ID(),
    			FixedIp: instance1.Networks.ApplyT(func(networks []compute.InstanceNetwork) (*string, error) {
    				return &networks[1].FixedIpV4, nil
    			}).(pulumi.StringPtrOutput),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.openstack.compute.Instance;
    import com.pulumi.openstack.compute.InstanceArgs;
    import com.pulumi.openstack.compute.inputs.InstanceNetworkArgs;
    import com.pulumi.openstack.networking.FloatingIp;
    import com.pulumi.openstack.networking.FloatingIpArgs;
    import com.pulumi.openstack.compute.FloatingIpAssociate;
    import com.pulumi.openstack.compute.FloatingIpAssociateArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var instance1 = new Instance("instance1", InstanceArgs.builder()        
                .imageId("ad091b52-742f-469e-8f3c-fd81cadf0743")
                .flavorId(3)
                .keyPair("my_key_pair_name")
                .securityGroups("default")
                .networks(            
                    InstanceNetworkArgs.builder()
                        .name("my_network")
                        .build(),
                    InstanceNetworkArgs.builder()
                        .name("default")
                        .build())
                .build());
    
            var fip1FloatingIp = new FloatingIp("fip1FloatingIp", FloatingIpArgs.builder()        
                .pool("my_pool")
                .build());
    
            var fip1FloatingIpAssociate = new FloatingIpAssociate("fip1FloatingIpAssociate", FloatingIpAssociateArgs.builder()        
                .floatingIp(fip1FloatingIp.address())
                .instanceId(instance1.id())
                .fixedIp(instance1.networks().applyValue(networks -> networks[1].fixedIpV4()))
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_openstack as openstack
    
    instance1 = openstack.compute.Instance("instance1",
        image_id="ad091b52-742f-469e-8f3c-fd81cadf0743",
        flavor_id="3",
        key_pair="my_key_pair_name",
        security_groups=["default"],
        networks=[
            openstack.compute.InstanceNetworkArgs(
                name="my_network",
            ),
            openstack.compute.InstanceNetworkArgs(
                name="default",
            ),
        ])
    fip1_floating_ip = openstack.networking.FloatingIp("fip1FloatingIp", pool="my_pool")
    fip1_floating_ip_associate = openstack.compute.FloatingIpAssociate("fip1FloatingIpAssociate",
        floating_ip=fip1_floating_ip.address,
        instance_id=instance1.id,
        fixed_ip=instance1.networks[1].fixed_ip_v4)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as openstack from "@pulumi/openstack";
    
    const instance1 = new openstack.compute.Instance("instance1", {
        imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
        flavorId: "3",
        keyPair: "my_key_pair_name",
        securityGroups: ["default"],
        networks: [
            {
                name: "my_network",
            },
            {
                name: "default",
            },
        ],
    });
    const fip1FloatingIp = new openstack.networking.FloatingIp("fip1FloatingIp", {pool: "my_pool"});
    const fip1FloatingIpAssociate = new openstack.compute.FloatingIpAssociate("fip1FloatingIpAssociate", {
        floatingIp: fip1FloatingIp.address,
        instanceId: instance1.id,
        fixedIp: instance1.networks.apply(networks => networks[1].fixedIpV4),
    });
    
    resources:
      instance1:
        type: openstack:compute:Instance
        properties:
          imageId: ad091b52-742f-469e-8f3c-fd81cadf0743
          flavorId: 3
          keyPair: my_key_pair_name
          securityGroups:
            - default
          networks:
            - name: my_network
            - name: default
      fip1FloatingIp:
        type: openstack:networking:FloatingIp
        properties:
          pool: my_pool
      fip1FloatingIpAssociate:
        type: openstack:compute:FloatingIpAssociate
        properties:
          floatingIp: ${fip1FloatingIp.address}
          instanceId: ${instance1.id}
          fixedIp: ${instance1.networks[1].fixedIpV4}
    

    Create FloatingIpAssociate Resource

    new FloatingIpAssociate(name: string, args: FloatingIpAssociateArgs, opts?: CustomResourceOptions);
    @overload
    def FloatingIpAssociate(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            fixed_ip: Optional[str] = None,
                            floating_ip: Optional[str] = None,
                            instance_id: Optional[str] = None,
                            region: Optional[str] = None,
                            wait_until_associated: Optional[bool] = None)
    @overload
    def FloatingIpAssociate(resource_name: str,
                            args: FloatingIpAssociateArgs,
                            opts: Optional[ResourceOptions] = None)
    func NewFloatingIpAssociate(ctx *Context, name string, args FloatingIpAssociateArgs, opts ...ResourceOption) (*FloatingIpAssociate, error)
    public FloatingIpAssociate(string name, FloatingIpAssociateArgs args, CustomResourceOptions? opts = null)
    public FloatingIpAssociate(String name, FloatingIpAssociateArgs args)
    public FloatingIpAssociate(String name, FloatingIpAssociateArgs args, CustomResourceOptions options)
    
    type: openstack:compute:FloatingIpAssociate
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args FloatingIpAssociateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args FloatingIpAssociateArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args FloatingIpAssociateArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FloatingIpAssociateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args FloatingIpAssociateArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    FloatingIpAssociate Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The FloatingIpAssociate resource accepts the following input properties:

    FloatingIp string
    The floating IP to associate.
    InstanceId string
    The instance to associte the floating IP with.
    FixedIp string
    The specific IP address to direct traffic to.
    Region string
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    WaitUntilAssociated bool
    FloatingIp string
    The floating IP to associate.
    InstanceId string
    The instance to associte the floating IP with.
    FixedIp string
    The specific IP address to direct traffic to.
    Region string
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    WaitUntilAssociated bool
    floatingIp String
    The floating IP to associate.
    instanceId String
    The instance to associte the floating IP with.
    fixedIp String
    The specific IP address to direct traffic to.
    region String
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    waitUntilAssociated Boolean
    floatingIp string
    The floating IP to associate.
    instanceId string
    The instance to associte the floating IP with.
    fixedIp string
    The specific IP address to direct traffic to.
    region string
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    waitUntilAssociated boolean
    floating_ip str
    The floating IP to associate.
    instance_id str
    The instance to associte the floating IP with.
    fixed_ip str
    The specific IP address to direct traffic to.
    region str
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    wait_until_associated bool
    floatingIp String
    The floating IP to associate.
    instanceId String
    The instance to associte the floating IP with.
    fixedIp String
    The specific IP address to direct traffic to.
    region String
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    waitUntilAssociated Boolean

    Outputs

    All input properties are implicitly available as output properties. Additionally, the FloatingIpAssociate resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing FloatingIpAssociate Resource

    Get an existing FloatingIpAssociate resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: FloatingIpAssociateState, opts?: CustomResourceOptions): FloatingIpAssociate
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            fixed_ip: Optional[str] = None,
            floating_ip: Optional[str] = None,
            instance_id: Optional[str] = None,
            region: Optional[str] = None,
            wait_until_associated: Optional[bool] = None) -> FloatingIpAssociate
    func GetFloatingIpAssociate(ctx *Context, name string, id IDInput, state *FloatingIpAssociateState, opts ...ResourceOption) (*FloatingIpAssociate, error)
    public static FloatingIpAssociate Get(string name, Input<string> id, FloatingIpAssociateState? state, CustomResourceOptions? opts = null)
    public static FloatingIpAssociate get(String name, Output<String> id, FloatingIpAssociateState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    FixedIp string
    The specific IP address to direct traffic to.
    FloatingIp string
    The floating IP to associate.
    InstanceId string
    The instance to associte the floating IP with.
    Region string
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    WaitUntilAssociated bool
    FixedIp string
    The specific IP address to direct traffic to.
    FloatingIp string
    The floating IP to associate.
    InstanceId string
    The instance to associte the floating IP with.
    Region string
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    WaitUntilAssociated bool
    fixedIp String
    The specific IP address to direct traffic to.
    floatingIp String
    The floating IP to associate.
    instanceId String
    The instance to associte the floating IP with.
    region String
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    waitUntilAssociated Boolean
    fixedIp string
    The specific IP address to direct traffic to.
    floatingIp string
    The floating IP to associate.
    instanceId string
    The instance to associte the floating IP with.
    region string
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    waitUntilAssociated boolean
    fixed_ip str
    The specific IP address to direct traffic to.
    floating_ip str
    The floating IP to associate.
    instance_id str
    The instance to associte the floating IP with.
    region str
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    wait_until_associated bool
    fixedIp String
    The specific IP address to direct traffic to.
    floatingIp String
    The floating IP to associate.
    instanceId String
    The instance to associte the floating IP with.
    region String
    The region in which to obtain the V2 Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the region argument of the provider is used. Changing this creates a new floatingip_associate.
    waitUntilAssociated Boolean

    Import

    This resource can be imported by specifying all three arguments, separated by a forward slash:

     $ pulumi import openstack:compute/floatingIpAssociate:FloatingIpAssociate fip_1 floating_ip/instance_id/fixed_ip
    

    Package Details

    Repository
    OpenStack pulumi/pulumi-openstack
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the openstack Terraform Provider.
    openstack logo
    OpenStack v3.15.1 published on Thursday, Feb 1, 2024 by Pulumi