github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/alicloud/r/eip_association.html.markdown (about) 1 --- 2 layout: "alicloud" 3 page_title: "Alicloud: alicloud_eip_association" 4 sidebar_current: "docs-alicloud-resource-eip-association" 5 description: |- 6 Provides a ECS EIP Association resource. 7 --- 8 9 # alicloud\_eip\_association 10 11 Provides an Alicloud EIP Association resource, to associate and disassociate Elastic IPs from ECS Instances. 12 13 ~> **NOTE:** `alicloud_eip_association` is useful in scenarios where EIPs are either 14 pre-existing or distributed to customers or users and therefore cannot be changed. 15 In addition, it only supports ECS-VPC. 16 17 ## Example Usage 18 19 ``` 20 # Create a new EIP association and use it to associate a EIP form a instance. 21 22 resource "alicloud_vpc" "vpc" { 23 cidr_block = "10.1.0.0/21" 24 } 25 26 resource "alicloud_vswitch" "vsw" { 27 vpc_id = "${alicloud_vpc.vpc.id}" 28 cidr_block = "10.1.1.0/24" 29 availability_zone = "cn-beijing-a" 30 31 depends_on = [ 32 "alicloud_vpc.vpc", 33 ] 34 } 35 36 resource "alicloud_instance" "ecs_instance" { 37 image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd" 38 instance_type = "ecs.s1.small" 39 availability_zone = "cn-beijing-a" 40 security_groups = ["${alicloud_security_group.group.id}"] 41 vswitch_id = "${alicloud_vswitch.vsw.id}" 42 instance_name = "hello" 43 instance_network_type = "vpc" 44 45 tags { 46 Name = "TerraformTest-instance" 47 } 48 } 49 50 resource "alicloud_eip" "eip" {} 51 52 resource "alicloud_eip_association" "eip_asso" { 53 allocation_id = "${alicloud_eip.eip.id}" 54 instance_id = "${alicloud_instance.ecs_instance.id}" 55 } 56 57 resource "alicloud_security_group" "group" { 58 name = "terraform-test-group" 59 description = "New security group" 60 vpc_id = "${alicloud_vpc.vpc.id}" 61 } 62 ``` 63 64 ## Argument Reference 65 66 The following arguments are supported: 67 68 * `allocation_id` - (Optional, Forces new resource) The allocation EIP ID. 69 * `instance_id` - (Optional, Forces new resource) The ID of the instance. 70 71 ## Attributes Reference 72 73 The following attributes are exported: 74 75 * `allocation_id` - As above. 76 * `instance_id` - As above.