Eip Association Args
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.LoadBalancer
oraws.ec2.NatGateway
resources. Instead use theallocation_id
available in those resources to allow AWS to manage the association, otherwise you will seeAuthFailure
errors. NOTE:aws.ec2.EipAssociation
is useful in scenarios where EIPs are either pre-existing or distributed to customers or users and therefore cannot be changed.
Example Usage
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Instance;
import com.pulumi.aws.ec2.InstanceArgs;
import com.pulumi.aws.ec2.Eip;
import com.pulumi.aws.ec2.EipArgs;
import com.pulumi.aws.ec2.EipAssociation;
import com.pulumi.aws.ec2.EipAssociationArgs;
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 web = new Instance("web", InstanceArgs.builder()
.ami("ami-21f78e11")
.availabilityZone("us-west-2a")
.instanceType("t2.micro")
.tags(Map.of("Name", "HelloWorld"))
.build());
var example = new Eip("example", EipArgs.builder()
.vpc(true)
.build());
var eipAssoc = new EipAssociation("eipAssoc", EipAssociationArgs.builder()
.instanceId(web.id())
.allocationId(example.id())
.build());
}
}
Import
EIP Assocations can be imported using their association ID.
$ pulumi import aws:ec2/eipAssociation:EipAssociation test eipassoc-ab12c345
Constructors
Properties
The allocation ID. This is required for EC2-VPC.
Whether to allow an Elastic IP to be re-associated. Defaults to true
in VPC.
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.
The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
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.