Volume Attachment Args
Provides an AWS EBS Volume Attachment as a top level resource, to attach and detach volumes from AWS Instances.
NOTE on EBS block devices: If you use
ebs_block_device
on anaws.ec2.Instance
, this provider 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 externalaws.ebs.Volume
+aws.ec2.VolumeAttachment
resources for a given instance.
Example Usage
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Instance;
import com.pulumi.aws.ec2.InstanceArgs;
import com.pulumi.aws.ebs.Volume;
import com.pulumi.aws.ebs.VolumeArgs;
import com.pulumi.aws.ec2.VolumeAttachment;
import com.pulumi.aws.ec2.VolumeAttachmentArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var web = new Instance("web", InstanceArgs.builder()
.ami("ami-21f78e11")
.availabilityZone("us-west-2a")
.instanceType("t2.micro")
.tags(Map.of("Name", "HelloWorld"))
.build());
var example = new Volume("example", VolumeArgs.builder()
.availabilityZone("us-west-2a")
.size(1)
.build());
var ebsAtt = new VolumeAttachment("ebsAtt", VolumeAttachmentArgs.builder()
.deviceName("/dev/sdh")
.volumeId(example.id())
.instanceId(web.id())
.build());
}
}
Import
EBS Volume Attachments can be imported using DEVICE_NAME:VOLUME_ID:INSTANCE_ID
, e.g.,
$ pulumi import aws:ec2/volumeAttachment:VolumeAttachment example /dev/sdh:vol-049df61146c4d7901:i-12345678
1https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html#available-ec2-device-names 2https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/device_naming.html#available-ec2-device-names 3https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-detaching-volume.html
Constructors
Properties
The device name to expose to the instance (for example, /dev/sdh
or xvdh
). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.
Set to true
if you want to force the volume to detach. Useful if previous attempts failed, but use this option only as a last resort, as this can result in data loss. See Detaching an Amazon EBS Volume from an Instance for more information.
ID of the Instance to attach to
Set this to true if you do not wish to detach the volume from the instance to which it is attached at destroy time, and instead just remove the attachment from this provider state. This is useful when destroying an instance which has volumes created by some other means attached.
Set this to true to ensure that the target instance is stopped before trying to detach the volume. Stops the instance, if it is not already stopped.