Eip

class Eip : KotlinCustomResource

Provides an Elastic IP resource.

Note: EIP may require IGW to exist prior to association. Use depends_on to set an explicit dependency on the IGW. Note: Do not use network_interface to associate the EIP to aws.lb.LoadBalancer or aws.ec2.NatGateway resources. Instead use the allocation_id available in those resources to allow AWS to manage the association, otherwise you will see AuthFailure errors.

Example Usage

Single EIP associated with an instance

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Eip;
import com.pulumi.aws.ec2.EipArgs;
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 lb = new Eip("lb", EipArgs.builder()
.instance(aws_instance.web().id())
.vpc(true)
.build());
}
}

Multiple EIPs associated with a single network interface

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.NetworkInterface;
import com.pulumi.aws.ec2.NetworkInterfaceArgs;
import com.pulumi.aws.ec2.Eip;
import com.pulumi.aws.ec2.EipArgs;
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 multi_ip = new NetworkInterface("multi-ip", NetworkInterfaceArgs.builder()
.subnetId(aws_subnet.main().id())
.privateIps(
"10.0.0.10",
"10.0.0.11")
.build());
var one = new Eip("one", EipArgs.builder()
.vpc(true)
.networkInterface(multi_ip.id())
.associateWithPrivateIp("10.0.0.10")
.build());
var two = new Eip("two", EipArgs.builder()
.vpc(true)
.networkInterface(multi_ip.id())
.associateWithPrivateIp("10.0.0.11")
.build());
}
}

Attaching an EIP to an Instance with a pre-assigned private ip (VPC Only)

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Vpc;
import com.pulumi.aws.ec2.VpcArgs;
import com.pulumi.aws.ec2.InternetGateway;
import com.pulumi.aws.ec2.InternetGatewayArgs;
import com.pulumi.aws.ec2.Subnet;
import com.pulumi.aws.ec2.SubnetArgs;
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.resources.CustomResourceOptions;
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 default_ = new Vpc("default", VpcArgs.builder()
.cidrBlock("10.0.0.0/16")
.enableDnsHostnames(true)
.build());
var gw = new InternetGateway("gw", InternetGatewayArgs.builder()
.vpcId(default_.id())
.build());
var myTestSubnet = new Subnet("myTestSubnet", SubnetArgs.builder()
.vpcId(default_.id())
.cidrBlock("10.0.0.0/24")
.mapPublicIpOnLaunch(true)
.build(), CustomResourceOptions.builder()
.dependsOn(gw)
.build());
var foo = new Instance("foo", InstanceArgs.builder()
.ami("ami-5189a661")
.instanceType("t2.micro")
.privateIp("10.0.0.12")
.subnetId(myTestSubnet.id())
.build());
var bar = new Eip("bar", EipArgs.builder()
.vpc(true)
.instance(foo.id())
.associateWithPrivateIp("10.0.0.12")
.build(), CustomResourceOptions.builder()
.dependsOn(gw)
.build());
}
}

Allocating EIP from the BYOIP pool

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Eip;
import com.pulumi.aws.ec2.EipArgs;
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 byoip_ip = new Eip("byoip-ip", EipArgs.builder()
.publicIpv4Pool("ipv4pool-ec2-012345")
.vpc(true)
.build());
}
}

Import

EIPs in a VPC can be imported using their Allocation ID, e.g.,

$ pulumi import aws:ec2/eip:Eip bar eipalloc-00a10e96

EIPs in EC2-Classic can be imported using their Public IP, e.g.,

$ pulumi import aws:ec2/eip:Eip bar 52.0.0.0

Properties

Link copied to clipboard
val address: Output<String>?

IP address from an EC2 BYOIP pool. This option is only available for VPC EIPs.

Link copied to clipboard
val allocationId: Output<String>

ID that AWS assigns to represent the allocation of the Elastic IP address for use with instances in a VPC.

Link copied to clipboard

User-specified 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.

Link copied to clipboard
val associationId: Output<String>

ID representing the association of the address with an instance in a VPC.

Link copied to clipboard
val carrierIp: Output<String>

Carrier IP address.

Link copied to clipboard
val customerOwnedIp: Output<String>

Customer owned IP.

Link copied to clipboard

ID of a customer-owned address pool. For more on customer owned IP addressed check out Customer-owned IP addresses guide.

Link copied to clipboard
val domain: Output<String>

Indicates if this EIP is for use in VPC (vpc) or EC2-Classic (standard).

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val instance: Output<String>

EC2 instance ID.

Link copied to clipboard

Location from which the IP address is advertised. Use this parameter to limit the address to this location.

Link copied to clipboard

Network interface ID to associate with.

Link copied to clipboard
val privateDns: Output<String>

The Private DNS associated with the Elastic IP address (if in VPC).

Link copied to clipboard
val privateIp: Output<String>

Contains the private IP address (if in VPC).

Link copied to clipboard
val publicDns: Output<String>

Public DNS associated with the Elastic IP address.

Link copied to clipboard
val publicIp: Output<String>

Contains the public IP address.

Link copied to clipboard
val publicIpv4Pool: Output<String>

EC2 IPv4 address pool identifier or amazon. This option is only available for VPC EIPs.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val tags: Output<Map<String, String>>?

Map of tags to assign to the resource. Tags can only be applied to EIPs in a VPC. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val tagsAll: Output<Map<String, String>>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val vpc: Output<Boolean>

Boolean if the EIP is in a VPC or not. Defaults to true unless the region supports EC2-Classic.