EipAssociation
Provides an AWS EIP Association as a top level resource, to associate and disassociate Elastic IPs from AWS Instances and Network Interfaces.
NOTE: Do not use this resource to associate an EIP to
aws.lb.LoadBalanceroraws.ec2.NatGatewayresources. Instead use theallocation_idavailable in those resources to allow AWS to manage the association, otherwise you will seeAuthFailureerrors.NOTE:
aws.ec2.EipAssociationis useful in scenarios where EIPs are either pre-existing or distributed to customers or users and therefore cannot be changed.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var web = new Aws.Ec2.Instance("web", new Aws.Ec2.InstanceArgs
{
Ami = "ami-21f78e11",
AvailabilityZone = "us-west-2a",
InstanceType = "t1.micro",
Tags =
{
{ "Name", "HelloWorld" },
},
});
var example = new Aws.Ec2.Eip("example", new Aws.Ec2.EipArgs
{
Vpc = true,
});
var eipAssoc = new Aws.Ec2.EipAssociation("eipAssoc", new Aws.Ec2.EipAssociationArgs
{
AllocationId = example.Id,
InstanceId = web.Id,
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
web, err := ec2.NewInstance(ctx, "web", &ec2.InstanceArgs{
Ami: pulumi.String("ami-21f78e11"),
AvailabilityZone: pulumi.String("us-west-2a"),
InstanceType: pulumi.String("t1.micro"),
Tags: pulumi.StringMap{
"Name": pulumi.String("HelloWorld"),
},
})
if err != nil {
return err
}
example, err := ec2.NewEip(ctx, "example", &ec2.EipArgs{
Vpc: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = ec2.NewEipAssociation(ctx, "eipAssoc", &ec2.EipAssociationArgs{
AllocationId: example.ID(),
InstanceId: web.ID(),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
web = aws.ec2.Instance("web",
ami="ami-21f78e11",
availability_zone="us-west-2a",
instance_type="t1.micro",
tags={
"Name": "HelloWorld",
})
example = aws.ec2.Eip("example", vpc=True)
eip_assoc = aws.ec2.EipAssociation("eipAssoc",
allocation_id=example.id,
instance_id=web.id)import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const web = new aws.ec2.Instance("web", {
ami: "ami-21f78e11",
availabilityZone: "us-west-2a",
instanceType: "t1.micro",
tags: {
Name: "HelloWorld",
},
});
const example = new aws.ec2.Eip("example", {
vpc: true,
});
const eipAssoc = new aws.ec2.EipAssociation("eip_assoc", {
allocationId: example.id,
instanceId: web.id,
});Create a EipAssociation Resource
new EipAssociation(name: string, args?: EipAssociationArgs, opts?: CustomResourceOptions);def EipAssociation(resource_name, opts=None, allocation_id=None, allow_reassociation=None, instance_id=None, network_interface_id=None, private_ip_address=None, public_ip=None, __props__=None);func NewEipAssociation(ctx *Context, name string, args *EipAssociationArgs, opts ...ResourceOption) (*EipAssociation, error)public EipAssociation(string name, EipAssociationArgs? args = null, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args EipAssociationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args EipAssociationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args EipAssociationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
EipAssociation Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The EipAssociation resource accepts the following input properties:
- Allocation
Id string The allocation ID. This is required for EC2-VPC.
- Allow
Reassociation bool Whether to allow an Elastic IP to be re-associated. Defaults to
truein VPC.- Instance
Id string The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- Network
Interface stringId The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
- Private
Ip stringAddress The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
- Public
Ip string The Elastic IP address. This is required for EC2-Classic.
- Allocation
Id string The allocation ID. This is required for EC2-VPC.
- Allow
Reassociation bool Whether to allow an Elastic IP to be re-associated. Defaults to
truein VPC.- Instance
Id string The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- Network
Interface stringId The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
- Private
Ip stringAddress The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
- Public
Ip string The Elastic IP address. This is required for EC2-Classic.
- allocation
Id string The allocation ID. This is required for EC2-VPC.
- allow
Reassociation boolean Whether to allow an Elastic IP to be re-associated. Defaults to
truein VPC.- instance
Id string The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- network
Interface stringId The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
- private
Ip stringAddress The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
- public
Ip string The Elastic IP address. This is required for EC2-Classic.
- allocation_
id str The allocation ID. This is required for EC2-VPC.
- allow_
reassociation bool Whether to allow an Elastic IP to be re-associated. Defaults to
truein VPC.- instance_
id str The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- network_
interface_ strid The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
- private_
ip_ straddress The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
- public_
ip str The Elastic IP address. This is required for EC2-Classic.
Outputs
All input properties are implicitly available as output properties. Additionally, the EipAssociation resource produces the following output properties:
Look up an Existing EipAssociation Resource
Get an existing EipAssociation 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?: EipAssociationState, opts?: CustomResourceOptions): EipAssociationstatic get(resource_name, id, opts=None, allocation_id=None, allow_reassociation=None, instance_id=None, network_interface_id=None, private_ip_address=None, public_ip=None, __props__=None);func GetEipAssociation(ctx *Context, name string, id IDInput, state *EipAssociationState, opts ...ResourceOption) (*EipAssociation, error)public static EipAssociation Get(string name, Input<string> id, EipAssociationState? state, CustomResourceOptions? opts = null)- 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.
The following state arguments are supported:
- Allocation
Id string The allocation ID. This is required for EC2-VPC.
- Allow
Reassociation bool Whether to allow an Elastic IP to be re-associated. Defaults to
truein VPC.- Instance
Id string The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- Network
Interface stringId The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
- Private
Ip stringAddress The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
- Public
Ip string The Elastic IP address. This is required for EC2-Classic.
- Allocation
Id string The allocation ID. This is required for EC2-VPC.
- Allow
Reassociation bool Whether to allow an Elastic IP to be re-associated. Defaults to
truein VPC.- Instance
Id string The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- Network
Interface stringId The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
- Private
Ip stringAddress The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
- Public
Ip string The Elastic IP address. This is required for EC2-Classic.
- allocation
Id string The allocation ID. This is required for EC2-VPC.
- allow
Reassociation boolean Whether to allow an Elastic IP to be re-associated. Defaults to
truein VPC.- instance
Id string The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- network
Interface stringId The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
- private
Ip stringAddress The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
- public
Ip string The Elastic IP address. This is required for EC2-Classic.
- allocation_
id str The allocation ID. This is required for EC2-VPC.
- allow_
reassociation bool Whether to allow an Elastic IP to be re-associated. Defaults to
truein VPC.- instance_
id str The ID of the instance. This is required for EC2-Classic. For EC2-VPC, you can specify either the instance ID or the network interface ID, but not both. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- network_
interface_ strid The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
- private_
ip_ straddress The primary or secondary private IP address to associate with the Elastic IP address. If no private IP address is specified, the Elastic IP address is associated with the primary private IP address.
- public_
ip str The Elastic IP address. This is required for EC2-Classic.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.