2016-05-09 19:40:45 +02:00
|
|
|
---
|
|
|
|
layout: "aws"
|
|
|
|
page_title: "AWS: aws_eip_association"
|
|
|
|
sidebar_current: "docs-aws-resource-eip-association"
|
|
|
|
description: |-
|
|
|
|
Provides an AWS EIP Association
|
|
|
|
---
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
~> **NOTE:** `aws_eip_association` is useful in scenarios where EIPs are either
|
|
|
|
pre-existing or distributed to customers or users and therefore cannot be changed.
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
|
|
|
```
|
|
|
|
resource "aws_eip_association" "eip_assoc" {
|
2017-02-18 23:48:50 +01:00
|
|
|
instance_id = "${aws_instance.web.id}"
|
2016-06-02 02:30:10 +02:00
|
|
|
allocation_id = "${aws_eip.example.id}"
|
2016-05-09 19:40:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_instance" "web" {
|
2017-02-18 23:48:50 +01:00
|
|
|
ami = "ami-21f78e11"
|
2016-05-09 19:40:45 +02:00
|
|
|
availability_zone = "us-west-2a"
|
2017-02-18 23:48:50 +01:00
|
|
|
instance_type = "t1.micro"
|
|
|
|
|
2016-05-09 19:40:45 +02:00
|
|
|
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
|
2017-02-18 23:48:50 +01:00
|
|
|
instance ID unless exactly one network interface is attached.
|
2016-05-09 19:40:45 +02:00
|
|
|
* `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
|
|
|
|
|
|
|
|
* `association_id` - The ID that represents the association of the Elastic IP
|
|
|
|
address with an instance.
|
|
|
|
* `allocation_id` - As above
|
|
|
|
* `instance_id` - As above
|
|
|
|
* `network_interface_id` - As above
|
|
|
|
* `private_ip_address` - As above
|
|
|
|
* `public_ip` - As above
|