aws_eip_association

Provides an AWS EIP Association as a top level resource, to associate and disassociate Elastic IPs from AWS Instances and Network Interfaces.

Example Usage

resource "aws_eip_association" "eip_assoc" {
  instance_id   = "${aws_instance.web.id}"
  allocation_id = "${aws_eip.example.id}"
}

resource "aws_instance" "web" {
  ami               = "ami-21f78e11"
  availability_zone = "us-west-2a"
  instance_type     = "t1.micro"

  tags {
    Name = "HelloWorld"
  }
}

resource "aws_eip" "example" {
  vpc = true
}

Argument Reference

The following arguments are supported:

  • allocation_id - (Optional) The allocation ID. This is required for EC2-VPC.
  • allow_reassociation - (Optional, Boolean) Whether to allow an Elastic IP to be re-associated. Defaults to true in VPC.
  • instance_id - (Optional) 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_id - (Optional) The ID of the network interface. If the instance has more than one network interface, you must specify a network interface ID.
  • private_ip_address - (Optional) 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 - (Optional) The Elastic IP address. This is required for EC2-Classic.

Attributes Reference

Import

EIP Assocations can be imported using their association ID.

$ terraform import aws_eip_association.test eipassoc-ab12c345

© 2018 HashiCorp
Licensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/aws/r/eip_association.html