2017-01-19 15:08:56 +01:00
|
|
|
---
|
|
|
|
layout: "alicloud"
|
|
|
|
page_title: "Alicloud: alicloud_eip_association"
|
|
|
|
sidebar_current: "docs-alicloud-resource-eip-association"
|
|
|
|
description: |-
|
|
|
|
Provides a ECS EIP Association resource.
|
|
|
|
---
|
|
|
|
|
2017-04-18 14:18:57 +02:00
|
|
|
# alicloud\_eip\_association
|
2017-01-19 15:08:56 +01:00
|
|
|
|
|
|
|
Provides an Alicloud EIP Association resource, to associate and disassociate Elastic IPs from ECS Instances.
|
|
|
|
|
|
|
|
~> **NOTE:** `alicloud_eip_association` is useful in scenarios where EIPs are either
|
|
|
|
pre-existing or distributed to customers or users and therefore cannot be changed.
|
|
|
|
In addition, it only supports ECS-VPC.
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2017-04-18 14:18:57 +02:00
|
|
|
```
|
|
|
|
# Create a new EIP association and use it to associate a EIP form a instance.
|
|
|
|
|
2017-01-19 15:08:56 +01:00
|
|
|
resource "alicloud_vpc" "vpc" {
|
2017-02-18 23:48:50 +01:00
|
|
|
cidr_block = "10.1.0.0/21"
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_vswitch" "vsw" {
|
2017-02-18 23:48:50 +01:00
|
|
|
vpc_id = "${alicloud_vpc.vpc.id}"
|
|
|
|
cidr_block = "10.1.1.0/24"
|
|
|
|
availability_zone = "cn-beijing-a"
|
|
|
|
|
|
|
|
depends_on = [
|
|
|
|
"alicloud_vpc.vpc",
|
|
|
|
]
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_instance" "ecs_instance" {
|
2017-02-18 23:48:50 +01:00
|
|
|
image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
|
|
|
|
instance_type = "ecs.s1.small"
|
|
|
|
availability_zone = "cn-beijing-a"
|
|
|
|
security_groups = ["${alicloud_security_group.group.id}"]
|
|
|
|
vswitch_id = "${alicloud_vswitch.vsw.id}"
|
|
|
|
instance_name = "hello"
|
|
|
|
instance_network_type = "vpc"
|
|
|
|
|
|
|
|
tags {
|
|
|
|
Name = "TerraformTest-instance"
|
|
|
|
}
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
|
2017-02-18 23:48:50 +01:00
|
|
|
resource "alicloud_eip" "eip" {}
|
2017-01-19 15:08:56 +01:00
|
|
|
|
|
|
|
resource "alicloud_eip_association" "eip_asso" {
|
2017-02-18 23:48:50 +01:00
|
|
|
allocation_id = "${alicloud_eip.eip.id}"
|
|
|
|
instance_id = "${alicloud_instance.ecs_instance.id}"
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_security_group" "group" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "terraform-test-group"
|
|
|
|
description = "New security group"
|
|
|
|
vpc_id = "${alicloud_vpc.vpc.id}"
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
|
|
* `allocation_id` - (Optional, Forces new resource) The allocation EIP ID.
|
|
|
|
* `instance_id` - (Optional, Forces new resource) The ID of the instance.
|
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `allocation_id` - As above.
|
2017-04-18 14:18:57 +02:00
|
|
|
* `instance_id` - As above.
|