@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
109 lines • 4.72 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.VolumeAttachment = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 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 `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
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const web = new aws.ec2.Instance("web", {
* ami: "ami-21f78e11",
* availabilityZone: "us-west-2a",
* instanceType: aws.ec2.InstanceType.T2_Micro,
* tags: {
* Name: "HelloWorld",
* },
* });
* const example = new aws.ebs.Volume("example", {
* availabilityZone: "us-west-2a",
* size: 1,
* });
* const ebsAtt = new aws.ec2.VolumeAttachment("ebs_att", {
* deviceName: "/dev/sdh",
* volumeId: example.id,
* instanceId: web.id,
* });
* ```
*
* ## 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
* ```
*/
class VolumeAttachment extends pulumi.CustomResource {
/**
* Get an existing VolumeAttachment 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 Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new VolumeAttachment(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of VolumeAttachment. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === VolumeAttachment.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["deviceName"] = state?.deviceName;
resourceInputs["forceDetach"] = state?.forceDetach;
resourceInputs["instanceId"] = state?.instanceId;
resourceInputs["region"] = state?.region;
resourceInputs["skipDestroy"] = state?.skipDestroy;
resourceInputs["stopInstanceBeforeDetaching"] = state?.stopInstanceBeforeDetaching;
resourceInputs["volumeId"] = state?.volumeId;
}
else {
const args = argsOrState;
if (args?.deviceName === undefined && !opts.urn) {
throw new Error("Missing required property 'deviceName'");
}
if (args?.instanceId === undefined && !opts.urn) {
throw new Error("Missing required property 'instanceId'");
}
if (args?.volumeId === undefined && !opts.urn) {
throw new Error("Missing required property 'volumeId'");
}
resourceInputs["deviceName"] = args?.deviceName;
resourceInputs["forceDetach"] = args?.forceDetach;
resourceInputs["instanceId"] = args?.instanceId;
resourceInputs["region"] = args?.region;
resourceInputs["skipDestroy"] = args?.skipDestroy;
resourceInputs["stopInstanceBeforeDetaching"] = args?.stopInstanceBeforeDetaching;
resourceInputs["volumeId"] = args?.volumeId;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(VolumeAttachment.__pulumiType, name, resourceInputs, opts);
}
}
exports.VolumeAttachment = VolumeAttachment;
/** @internal */
VolumeAttachment.__pulumiType = 'aws:ec2/volumeAttachment:VolumeAttachment';
//# sourceMappingURL=volumeAttachment.js.map