All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.aws.ec2.VolumeAttachment Maven / Gradle / Ivy

// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.aws.ec2;

import com.pulumi.aws.Utilities;
import com.pulumi.aws.ec2.VolumeAttachmentArgs;
import com.pulumi.aws.ec2.inputs.VolumeAttachmentState;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.String;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * 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 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, `ebs_block_device` cannot be mixed with external `aws.ebs.Volume` + `aws.ec2.VolumeAttachment` resources for a given instance.
 * 
 * ## Example Usage
 * 
 * <!--Start PulumiCodeChooser -->
 * 
 * {@code
 * 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());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * ## Import * * 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 * ``` * */ @ResourceType(type="aws:ec2/volumeAttachment:VolumeAttachment") public class VolumeAttachment extends com.pulumi.resources.CustomResource { /** * The 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. * */ @Export(name="deviceName", refs={String.class}, tree="[0]") private Output deviceName; /** * @return The 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. * */ public Output deviceName() { return this.deviceName; } /** * 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](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-detaching-volume.html) for more information. * */ @Export(name="forceDetach", refs={Boolean.class}, tree="[0]") private Output forceDetach; /** * @return 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](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-detaching-volume.html) for more information. * */ public Output> forceDetach() { return Codegen.optional(this.forceDetach); } /** * ID of the Instance to attach to * */ @Export(name="instanceId", refs={String.class}, tree="[0]") private Output instanceId; /** * @return ID of the Instance to attach to * */ public Output instanceId() { return this.instanceId; } /** * 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. * */ @Export(name="skipDestroy", refs={Boolean.class}, tree="[0]") private Output skipDestroy; /** * @return 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. * */ public Output> skipDestroy() { return Codegen.optional(this.skipDestroy); } /** * 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. * */ @Export(name="stopInstanceBeforeDetaching", refs={Boolean.class}, tree="[0]") private Output stopInstanceBeforeDetaching; /** * @return 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. * */ public Output> stopInstanceBeforeDetaching() { return Codegen.optional(this.stopInstanceBeforeDetaching); } /** * ID of the Volume to be attached * */ @Export(name="volumeId", refs={String.class}, tree="[0]") private Output volumeId; /** * @return ID of the Volume to be attached * */ public Output volumeId() { return this.volumeId; } /** * * @param name The _unique_ name of the resulting resource. */ public VolumeAttachment(java.lang.String name) { this(name, VolumeAttachmentArgs.Empty); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. */ public VolumeAttachment(java.lang.String name, VolumeAttachmentArgs args) { this(name, args, null); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. * @param options A bag of options that control this resource's behavior. */ public VolumeAttachment(java.lang.String name, VolumeAttachmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("aws:ec2/volumeAttachment:VolumeAttachment", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); } private VolumeAttachment(java.lang.String name, Output id, @Nullable VolumeAttachmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("aws:ec2/volumeAttachment:VolumeAttachment", name, state, makeResourceOptions(options, id), false); } private static VolumeAttachmentArgs makeArgs(VolumeAttachmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { if (options != null && options.getUrn().isPresent()) { return null; } return args == null ? VolumeAttachmentArgs.Empty : args; } private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() .version(Utilities.getVersion()) .build(); return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); } /** * Get an existing Host resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state * @param options Optional settings to control the behavior of the CustomResource. */ public static VolumeAttachment get(java.lang.String name, Output id, @Nullable VolumeAttachmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { return new VolumeAttachment(name, id, state, options); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy