github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/aws/r/volume_attachment.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_volume_attachment" 4 sidebar_current: "docs-aws-resource-volume-attachment" 5 description: |- 6 Provides an AWS EBS Volume Attachment 7 --- 8 9 # aws\_volume\_attachment 10 11 Provides an AWS EBS Volume Attachment as a top level resource, to attach and 12 detach volumes from AWS Instances. 13 14 ~> **NOTE on EBS block devices:** If you use `ebs_block_device` on an `aws_instance`, Terraform will assume management over the full set of non-root EBS block devices for the instance, and treats additional block devices as drift. For this reason, `ebs_block_device` cannot be mixed with external `aws_ebs_volume` + `aws_ebs_volume_attachment` resources for a given instance. 15 16 ## Example Usage 17 18 ```hcl 19 resource "aws_volume_attachment" "ebs_att" { 20 device_name = "/dev/sdh" 21 volume_id = "${aws_ebs_volume.example.id}" 22 instance_id = "${aws_instance.web.id}" 23 } 24 25 resource "aws_instance" "web" { 26 ami = "ami-21f78e11" 27 availability_zone = "us-west-2a" 28 instance_type = "t1.micro" 29 30 tags { 31 Name = "HelloWorld" 32 } 33 } 34 35 resource "aws_ebs_volume" "example" { 36 availability_zone = "us-west-2a" 37 size = 1 38 } 39 ``` 40 41 ## Argument Reference 42 43 The following arguments are supported: 44 45 * `device_name` - (Required) The device name to expose to the instance (for 46 example, `/dev/sdh` or `xvdh`) 47 * `instance_id` - (Required) ID of the Instance to attach to 48 * `volume_id` - (Required) ID of the Volume to be attached 49 * `force_detach` - (Optional, Boolean) Set to `true` if you want to force the 50 volume to detach. Useful if previous attempts failed, but use this option only 51 as a last resort, as this can result in **data loss**. See 52 [Detaching an Amazon EBS Volume from an Instance][1] for more information. 53 * `skip_destroy` - (Optional, Boolean) Set this to true if you do not wish 54 to detach the volume from the instance to which it is attached at destroy 55 time, and instead just remove the attachment from Terraform state. This is 56 useful when destroying an instance which has volumes created by some other 57 means attached. 58 59 ## Attributes Reference 60 61 * `device_name` - The device name exposed to the instance 62 * `instance_id` - ID of the Instance 63 * `volume_id` - ID of the Volume 64 65 [1]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-detaching-volume.html