EipAssociationArgs

data class EipAssociationArgs(val allocationId: Output<String>? = null, val force: Output<Boolean>? = null, val instanceId: Output<String>? = null, val instanceType: Output<String>? = null, val privateIpAddress: Output<String>? = null, val vpcId: Output<String>? = null) : ConvertibleToJava<EipAssociationArgs>

Provides an Alicloud EIP Association resource for associating Elastic IP to ECS Instance, SLB Instance or Nat Gateway.

NOTE: alicloud.ecs.EipAssociation is useful in scenarios where EIPs are either pre-existing or distributed to customers or users and therefore cannot be changed. NOTE: From version 1.7.1, the resource support to associate EIP to SLB Instance or Nat Gateway. NOTE: One EIP can only be associated with ECS or SLB instance which in the VPC. NOTE: Available since v1.117.0.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.ecs.SecurityGroup;
import com.pulumi.alicloud.ecs.SecurityGroupArgs;
import com.pulumi.alicloud.ecs.Instance;
import com.pulumi.alicloud.ecs.InstanceArgs;
import com.pulumi.alicloud.ecs.EipAddress;
import com.pulumi.alicloud.ecs.EipAddressArgs;
import com.pulumi.alicloud.ecs.EipAssociation;
import com.pulumi.alicloud.ecs.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) {
final var config = ctx.config();
final var name = config.get("name").orElse("tf-example");
final var exampleZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableResourceCreation("Instance")
.build());
final var exampleInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
.availabilityZone(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.cpuCoreCount(1)
.memorySize(2)
.build());
final var exampleImages = EcsFunctions.getImages(GetImagesArgs.builder()
.nameRegex("^ubuntu_[0-9]+_[0-9]+_x64*")
.owners("system")
.build());
var exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("10.4.0.0/16")
.build());
var exampleSwitch = new Switch("exampleSwitch", SwitchArgs.builder()
.vswitchName(name)
.cidrBlock("10.4.0.0/24")
.vpcId(exampleNetwork.id())
.zoneId(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.build());
var exampleSecurityGroup = new SecurityGroup("exampleSecurityGroup", SecurityGroupArgs.builder()
.vpcId(exampleNetwork.id())
.build());
var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()
.availabilityZone(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.instanceName(name)
.imageId(exampleImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
.instanceType(exampleInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id()))
.securityGroups(exampleSecurityGroup.id())
.vswitchId(exampleSwitch.id())
.tags(Map.ofEntries(
Map.entry("Created", "TF"),
Map.entry("For", "example")
))
.build());
var exampleEipAddress = new EipAddress("exampleEipAddress", EipAddressArgs.builder()
.addressName(name)
.build());
var exampleEipAssociation = new EipAssociation("exampleEipAssociation", EipAssociationArgs.builder()
.allocationId(exampleEipAddress.id())
.instanceId(exampleInstance.id())
.build());
}
}

Module Support

You can use the existing eip module to create several EIP instances and associate them with other resources one-click, like ECS instances, SLB, Nat Gateway and so on.

Import

Elastic IP address association can be imported using the id, e.g.

$ pulumi import alicloud:ecs/eipAssociation:EipAssociation example eip-abc12345678:i-abc12355

Constructors

Link copied to clipboard
fun EipAssociationArgs(allocationId: Output<String>? = null, force: Output<Boolean>? = null, instanceId: Output<String>? = null, instanceType: Output<String>? = null, privateIpAddress: Output<String>? = null, vpcId: Output<String>? = null)

Functions

Link copied to clipboard
open override fun toJava(): EipAssociationArgs

Properties

Link copied to clipboard
val allocationId: Output<String>? = null

The allocation EIP ID.

Link copied to clipboard
val force: Output<Boolean>? = null

When EIP is bound to a NAT gateway, and the NAT gateway adds a DNAT or SNAT entry, set it for true can unassociation any way. Default to false.

Link copied to clipboard
val instanceId: Output<String>? = null

The ID of the ECS or SLB instance or Nat Gateway or NetworkInterface or HaVip.

Link copied to clipboard
val instanceType: Output<String>? = null

The type of cloud product that the eip instance to bind. Valid values: EcsInstance, SlbInstance, Nat, NetworkInterface, HaVip and IpAddress.

Link copied to clipboard
val privateIpAddress: Output<String>? = null

The private IP address in the network segment of the vswitch which has been assigned.

Link copied to clipboard
val vpcId: Output<String>? = null

The ID of the VPC that has IPv4 gateways enabled and that is deployed in the same region as the EIP. When you associate an EIP with an IP address, the system can enable the IP address to access the Internet based on VPC route configurations. Note: This parameter is required if instance_type is set to IpAddress. In this case, the EIP is associated with an IP address.