Class EipAssociation


  • public class EipAssociation
    extends com.pulumi.resources.CustomResource
    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` or `aws.ec2.NatGateway` resources. Instead use the `allocationId` available in those resources to allow AWS to manage the association, otherwise you will see `AuthFailure` 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.ArrayList;
     import java.util.Arrays;
     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()
                 .domain("vpc")
                 .build());
     
             var eipAssoc = new EipAssociation("eipAssoc", EipAssociationArgs.builder()
                 .instanceId(web.id())
                 .allocationId(example.id())
                 .build());
     
         }
     }
     
     
    ## Import Using `pulumi import`, import EIP Associations using their association IDs. For example: ```sh $ pulumi import aws:ec2/eipAssociation:EipAssociation test eipassoc-ab12c345 ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> allocationId()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> allowReassociation()  
      static EipAssociation get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, EipAssociationState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> instanceId()  
      com.pulumi.core.Output<java.lang.String> networkInterfaceId()  
      com.pulumi.core.Output<java.lang.String> privateIpAddress()  
      com.pulumi.core.Output<java.lang.String> publicIp()  
      com.pulumi.core.Output<java.lang.String> region()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EipAssociation

        public EipAssociation​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • EipAssociation

        public EipAssociation​(java.lang.String name,
                              @Nullable
                              EipAssociationArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • EipAssociation

        public EipAssociation​(java.lang.String name,
                              @Nullable
                              EipAssociationArgs args,
                              @Nullable
                              com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • allocationId

        public com.pulumi.core.Output<java.lang.String> allocationId()
        Returns:
        ID of the associated Elastic IP. This argument is required despite being optional at the resource level due to legacy support for EC2-Classic networking.
      • allowReassociation

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> allowReassociation()
        Returns:
        Whether to allow an Elastic IP address to be re-associated. Defaults to `true`.
      • instanceId

        public com.pulumi.core.Output<java.lang.String> instanceId()
        Returns:
        ID of the instance. The instance must have exactly one attached network interface. You can specify either the instance ID or the network interface ID, but not both.
      • networkInterfaceId

        public com.pulumi.core.Output<java.lang.String> networkInterfaceId()
        Returns:
        ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID. You can specify either the instance ID or the network interface ID, but not both.
      • privateIpAddress

        public com.pulumi.core.Output<java.lang.String> privateIpAddress()
        Returns:
        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.
      • publicIp

        public com.pulumi.core.Output<java.lang.String> publicIp()
        Returns:
        ) Address of the associated Elastic IP.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • get

        public static EipAssociation get​(java.lang.String name,
                                         com.pulumi.core.Output<java.lang.String> id,
                                         @Nullable
                                         EipAssociationState state,
                                         @Nullable
                                         com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.