Package com.pulumi.aws.ec2
Class VolumeAttachment
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.ec2.VolumeAttachment
-
public class VolumeAttachment extends com.pulumi.resources.CustomResourceProvides 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 `ebsBlockDevice` on an `aws.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, `ebsBlockDevice` cannot be mixed with external `aws.ebs.Volume` + `aws.ec2.VolumeAttachment` resources for a given instance. ## Example Usage
## Import ### Identity Schema #### Required * `deviceName` (String) Device name exposed to the instance. * `instanceId` (String) ID of the Instance. * `volumeId` (String) ID of the Volume. #### Optional * `accountId` (String) Account ID where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import EBS Volume Attachments using `DEVICE_NAME:VOLUME_ID:INSTANCE_ID`. For example: ```sh $ pulumi import aws:ec2/volumeAttachment:VolumeAttachment example /dev/sdh:vol-049df61146c4d7901:i-12345678 ```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.ArrayList; import java.util.Arrays; 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()); } }
-
-
Constructor Summary
Constructors Constructor Description VolumeAttachment(java.lang.String name)VolumeAttachment(java.lang.String name, VolumeAttachmentArgs args)VolumeAttachment(java.lang.String name, VolumeAttachmentArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>deviceName()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>forceDetach()static VolumeAttachmentget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, VolumeAttachmentState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>instanceId()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>skipDestroy()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>stopInstanceBeforeDetaching()com.pulumi.core.Output<java.lang.String>volumeId()
-
-
-
Constructor Detail
-
VolumeAttachment
public VolumeAttachment(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
VolumeAttachment
public VolumeAttachment(java.lang.String name, VolumeAttachmentArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
VolumeAttachment
public VolumeAttachment(java.lang.String name, VolumeAttachmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
deviceName
public com.pulumi.core.Output<java.lang.String> deviceName()
- Returns:
- Device name to expose to the instance (for example, `/dev/sdh` or `xvdh`). See [Device Naming on Linux Instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html#available-ec2-device-names) and [Device Naming on Windows Instances](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/device_naming.html#available-ec2-device-names) for more information.
-
forceDetach
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> forceDetach()
- Returns:
- Whether 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](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-detaching-volume.html) for more information.
-
instanceId
public com.pulumi.core.Output<java.lang.String> instanceId()
- Returns:
- ID of the Instance to attach to.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
skipDestroy
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> skipDestroy()
- Returns:
- Whether to skip detaching 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.
-
stopInstanceBeforeDetaching
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> stopInstanceBeforeDetaching()
- Returns:
- Whether to ensure that the target instance is stopped before trying to detach the volume. Stops the instance, if it is not already stopped.
-
volumeId
public com.pulumi.core.Output<java.lang.String> volumeId()
- Returns:
- ID of the Volume to be attached.
-
get
public static VolumeAttachment get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable VolumeAttachmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-