openstack.compute.FloatingIpAssociate
Explore with Pulumi AI
Associate a floating IP to an instance.
Example Usage
Automatically detect the correct network
import * as pulumi from "@pulumi/pulumi";
import * as openstack from "@pulumi/openstack";
const instance1 = new openstack.compute.Instance("instance_1", {
name: "instance_1",
imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
flavorId: "3",
keyPair: "my_key_pair_name",
securityGroups: ["default"],
});
const fip1 = new openstack.networking.FloatingIp("fip_1", {pool: "my_pool"});
const fip1FloatingIpAssociate = new openstack.compute.FloatingIpAssociate("fip_1", {
floatingIp: fip1.address,
instanceId: instance1.id,
});
import pulumi
import pulumi_openstack as openstack
instance1 = openstack.compute.Instance("instance_1",
name="instance_1",
image_id="ad091b52-742f-469e-8f3c-fd81cadf0743",
flavor_id="3",
key_pair="my_key_pair_name",
security_groups=["default"])
fip1 = openstack.networking.FloatingIp("fip_1", pool="my_pool")
fip1_floating_ip_associate = openstack.compute.FloatingIpAssociate("fip_1",
floating_ip=fip1.address,
instance_id=instance1.id)
package main
import (
"github.com/pulumi/pulumi-openstack/sdk/v4/go/openstack/compute"
"github.com/pulumi/pulumi-openstack/sdk/v4/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, "instance_1", &compute.InstanceArgs{
Name: pulumi.String("instance_1"),
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
}
fip1, err := networking.NewFloatingIp(ctx, "fip_1", &networking.FloatingIpArgs{
Pool: pulumi.String("my_pool"),
})
if err != nil {
return err
}
_, err = compute.NewFloatingIpAssociate(ctx, "fip_1", &compute.FloatingIpAssociateArgs{
FloatingIp: fip1.Address,
InstanceId: instance1.ID(),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using OpenStack = Pulumi.OpenStack;
return await Deployment.RunAsync(() =>
{
var instance1 = new OpenStack.Compute.Instance("instance_1", new()
{
Name = "instance_1",
ImageId = "ad091b52-742f-469e-8f3c-fd81cadf0743",
FlavorId = "3",
KeyPair = "my_key_pair_name",
SecurityGroups = new[]
{
"default",
},
});
var fip1 = new OpenStack.Networking.FloatingIp("fip_1", new()
{
Pool = "my_pool",
});
var fip1FloatingIpAssociate = new OpenStack.Compute.FloatingIpAssociate("fip_1", new()
{
FloatingIp = fip1.Address,
InstanceId = instance1.Id,
});
});
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()
.name("instance_1")
.imageId("ad091b52-742f-469e-8f3c-fd81cadf0743")
.flavorId(3)
.keyPair("my_key_pair_name")
.securityGroups("default")
.build());
var fip1 = new FloatingIp("fip1", FloatingIpArgs.builder()
.pool("my_pool")
.build());
var fip1FloatingIpAssociate = new FloatingIpAssociate("fip1FloatingIpAssociate", FloatingIpAssociateArgs.builder()
.floatingIp(fip1.address())
.instanceId(instance1.id())
.build());
}
}
resources:
instance1:
type: openstack:compute:Instance
name: instance_1
properties:
name: instance_1
imageId: ad091b52-742f-469e-8f3c-fd81cadf0743
flavorId: 3
keyPair: my_key_pair_name
securityGroups:
- default
fip1:
type: openstack:networking:FloatingIp
name: fip_1
properties:
pool: my_pool
fip1FloatingIpAssociate:
type: openstack:compute:FloatingIpAssociate
name: fip_1
properties:
floatingIp: ${fip1.address}
instanceId: ${instance1.id}
Explicitly set the network to attach to
import * as pulumi from "@pulumi/pulumi";
import * as openstack from "@pulumi/openstack";
const instance1 = new openstack.compute.Instance("instance_1", {
name: "instance_1",
imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
flavorId: "3",
keyPair: "my_key_pair_name",
securityGroups: ["default"],
networks: [
{
name: "my_network",
},
{
name: "default",
},
],
});
const fip1 = new openstack.networking.FloatingIp("fip_1", {pool: "my_pool"});
const fip1FloatingIpAssociate = new openstack.compute.FloatingIpAssociate("fip_1", {
floatingIp: fip1.address,
instanceId: instance1.id,
fixedIp: instance1.networks.apply(networks => networks[1].fixedIpV4),
});
import pulumi
import pulumi_openstack as openstack
instance1 = openstack.compute.Instance("instance_1",
name="instance_1",
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 = openstack.networking.FloatingIp("fip_1", pool="my_pool")
fip1_floating_ip_associate = openstack.compute.FloatingIpAssociate("fip_1",
floating_ip=fip1.address,
instance_id=instance1.id,
fixed_ip=instance1.networks[1].fixed_ip_v4)
package main
import (
"github.com/pulumi/pulumi-openstack/sdk/v4/go/openstack/compute"
"github.com/pulumi/pulumi-openstack/sdk/v4/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, "instance_1", &compute.InstanceArgs{
Name: pulumi.String("instance_1"),
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
}
fip1, err := networking.NewFloatingIp(ctx, "fip_1", &networking.FloatingIpArgs{
Pool: pulumi.String("my_pool"),
})
if err != nil {
return err
}
_, err = compute.NewFloatingIpAssociate(ctx, "fip_1", &compute.FloatingIpAssociateArgs{
FloatingIp: fip1.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
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using OpenStack = Pulumi.OpenStack;
return await Deployment.RunAsync(() =>
{
var instance1 = new OpenStack.Compute.Instance("instance_1", new()
{
Name = "instance_1",
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 fip1 = new OpenStack.Networking.FloatingIp("fip_1", new()
{
Pool = "my_pool",
});
var fip1FloatingIpAssociate = new OpenStack.Compute.FloatingIpAssociate("fip_1", new()
{
FloatingIp = fip1.Address,
InstanceId = instance1.Id,
FixedIp = instance1.Networks.Apply(networks => networks[1].FixedIpV4),
});
});
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()
.name("instance_1")
.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 fip1 = new FloatingIp("fip1", FloatingIpArgs.builder()
.pool("my_pool")
.build());
var fip1FloatingIpAssociate = new FloatingIpAssociate("fip1FloatingIpAssociate", FloatingIpAssociateArgs.builder()
.floatingIp(fip1.address())
.instanceId(instance1.id())
.fixedIp(instance1.networks().applyValue(networks -> networks[1].fixedIpV4()))
.build());
}
}
resources:
instance1:
type: openstack:compute:Instance
name: instance_1
properties:
name: instance_1
imageId: ad091b52-742f-469e-8f3c-fd81cadf0743
flavorId: 3
keyPair: my_key_pair_name
securityGroups:
- default
networks:
- name: my_network
- name: default
fip1:
type: openstack:networking:FloatingIp
name: fip_1
properties:
pool: my_pool
fip1FloatingIpAssociate:
type: openstack:compute:FloatingIpAssociate
name: fip_1
properties:
floatingIp: ${fip1.address}
instanceId: ${instance1.id}
fixedIp: ${instance1.networks[1].fixedIpV4}
Create FloatingIpAssociate Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new FloatingIpAssociate(name: string, args: FloatingIpAssociateArgs, opts?: CustomResourceOptions);
@overload
def FloatingIpAssociate(resource_name: str,
args: FloatingIpAssociateArgs,
opts: Optional[ResourceOptions] = None)
@overload
def FloatingIpAssociate(resource_name: str,
opts: Optional[ResourceOptions] = None,
floating_ip: Optional[str] = None,
instance_id: Optional[str] = None,
fixed_ip: Optional[str] = None,
region: Optional[str] = None,
wait_until_associated: Optional[bool] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var floatingIpAssociateResource = new OpenStack.Compute.FloatingIpAssociate("floatingIpAssociateResource", new()
{
FloatingIp = "string",
InstanceId = "string",
FixedIp = "string",
Region = "string",
WaitUntilAssociated = false,
});
example, err := compute.NewFloatingIpAssociate(ctx, "floatingIpAssociateResource", &compute.FloatingIpAssociateArgs{
FloatingIp: pulumi.String("string"),
InstanceId: pulumi.String("string"),
FixedIp: pulumi.String("string"),
Region: pulumi.String("string"),
WaitUntilAssociated: pulumi.Bool(false),
})
var floatingIpAssociateResource = new FloatingIpAssociate("floatingIpAssociateResource", FloatingIpAssociateArgs.builder()
.floatingIp("string")
.instanceId("string")
.fixedIp("string")
.region("string")
.waitUntilAssociated(false)
.build());
floating_ip_associate_resource = openstack.compute.FloatingIpAssociate("floatingIpAssociateResource",
floating_ip="string",
instance_id="string",
fixed_ip="string",
region="string",
wait_until_associated=False)
const floatingIpAssociateResource = new openstack.compute.FloatingIpAssociate("floatingIpAssociateResource", {
floatingIp: "string",
instanceId: "string",
fixedIp: "string",
region: "string",
waitUntilAssociated: false,
});
type: openstack:compute:FloatingIpAssociate
properties:
fixedIp: string
floatingIp: string
instanceId: string
region: string
waitUntilAssociated: false
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:
- Floating
Ip string - The floating IP to associate.
- Instance
Id string - The instance to associte the floating IP with.
- Fixed
Ip 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. - Wait
Until boolAssociated
- Floating
Ip string - The floating IP to associate.
- Instance
Id string - The instance to associte the floating IP with.
- Fixed
Ip 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. - Wait
Until boolAssociated
- floating
Ip String - The floating IP to associate.
- instance
Id String - The instance to associte the floating IP with.
- fixed
Ip 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. - wait
Until BooleanAssociated
- floating
Ip string - The floating IP to associate.
- instance
Id string - The instance to associte the floating IP with.
- fixed
Ip 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. - wait
Until booleanAssociated
- 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_ boolassociated
- floating
Ip String - The floating IP to associate.
- instance
Id String - The instance to associte the floating IP with.
- fixed
Ip 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. - wait
Until BooleanAssociated
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.
- Fixed
Ip string - The specific IP address to direct traffic to.
- Floating
Ip string - The floating IP to associate.
- Instance
Id 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. - Wait
Until boolAssociated
- Fixed
Ip string - The specific IP address to direct traffic to.
- Floating
Ip string - The floating IP to associate.
- Instance
Id 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. - Wait
Until boolAssociated
- fixed
Ip String - The specific IP address to direct traffic to.
- floating
Ip String - The floating IP to associate.
- instance
Id 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. - wait
Until BooleanAssociated
- fixed
Ip string - The specific IP address to direct traffic to.
- floating
Ip string - The floating IP to associate.
- instance
Id 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. - wait
Until booleanAssociated
- 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_ boolassociated
- fixed
Ip String - The specific IP address to direct traffic to.
- floating
Ip String - The floating IP to associate.
- instance
Id 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. - wait
Until BooleanAssociated
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
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- OpenStack pulumi/pulumi-openstack
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
openstack
Terraform Provider.