VolumeAttachment
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_deviceon 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_devicecannot be mixed with externalaws.ebs.Volume+aws_ebs_volume_attachmentresources for a given instance.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var web = new Aws.Ec2.Instance("web", new Aws.Ec2.InstanceArgs
{
Ami = "ami-21f78e11",
AvailabilityZone = "us-west-2a",
InstanceType = "t1.micro",
Tags =
{
{ "Name", "HelloWorld" },
},
});
var example = new Aws.Ebs.Volume("example", new Aws.Ebs.VolumeArgs
{
AvailabilityZone = "us-west-2a",
Size = 1,
});
var ebsAtt = new Aws.Ec2.VolumeAttachment("ebsAtt", new Aws.Ec2.VolumeAttachmentArgs
{
DeviceName = "/dev/sdh",
InstanceId = web.Id,
VolumeId = example.Id,
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ebs"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
web, err := ec2.NewInstance(ctx, "web", &ec2.InstanceArgs{
Ami: pulumi.String("ami-21f78e11"),
AvailabilityZone: pulumi.String("us-west-2a"),
InstanceType: pulumi.String("t1.micro"),
Tags: pulumi.StringMap{
"Name": pulumi.String("HelloWorld"),
},
})
if err != nil {
return err
}
example, err := ebs.NewVolume(ctx, "example", &ebs.VolumeArgs{
AvailabilityZone: pulumi.String("us-west-2a"),
Size: pulumi.Int(1),
})
if err != nil {
return err
}
_, err = ec2.NewVolumeAttachment(ctx, "ebsAtt", &ec2.VolumeAttachmentArgs{
DeviceName: pulumi.String("/dev/sdh"),
InstanceId: web.ID(),
VolumeId: example.ID(),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
web = aws.ec2.Instance("web",
ami="ami-21f78e11",
availability_zone="us-west-2a",
instance_type="t1.micro",
tags={
"Name": "HelloWorld",
})
example = aws.ebs.Volume("example",
availability_zone="us-west-2a",
size=1)
ebs_att = aws.ec2.VolumeAttachment("ebsAtt",
device_name="/dev/sdh",
instance_id=web.id,
volume_id=example.id)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: "t1.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",
instanceId: web.id,
volumeId: example.id,
});Create a VolumeAttachment Resource
new VolumeAttachment(name: string, args: VolumeAttachmentArgs, opts?: CustomResourceOptions);def VolumeAttachment(resource_name, opts=None, device_name=None, force_detach=None, instance_id=None, skip_destroy=None, volume_id=None, __props__=None);func NewVolumeAttachment(ctx *Context, name string, args VolumeAttachmentArgs, opts ...ResourceOption) (*VolumeAttachment, error)public VolumeAttachment(string name, VolumeAttachmentArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args VolumeAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args VolumeAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args VolumeAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
VolumeAttachment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The VolumeAttachment resource accepts the following input properties:
- Device
Name string The device name to expose to the instance (for example,
/dev/sdhorxvdh). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.- Instance
Id string ID of the Instance to attach to
- Volume
Id string ID of the Volume to be attached
- Force
Detach bool Set to
trueif 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.- Skip
Destroy bool 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.
- Device
Name string The device name to expose to the instance (for example,
/dev/sdhorxvdh). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.- Instance
Id string ID of the Instance to attach to
- Volume
Id string ID of the Volume to be attached
- Force
Detach bool Set to
trueif 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.- Skip
Destroy bool 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.
- device
Name string The device name to expose to the instance (for example,
/dev/sdhorxvdh). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.- instance
Id string ID of the Instance to attach to
- volume
Id string ID of the Volume to be attached
- force
Detach boolean Set to
trueif 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.- skip
Destroy boolean 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.
- device_
name str The device name to expose to the instance (for example,
/dev/sdhorxvdh). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.- instance_
id str ID of the Instance to attach to
- volume_
id str ID of the Volume to be attached
- force_
detach bool Set to
trueif 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.- skip_
destroy bool 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the VolumeAttachment resource produces the following output properties:
Look up an Existing VolumeAttachment Resource
Get an existing VolumeAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: VolumeAttachmentState, opts?: CustomResourceOptions): VolumeAttachmentstatic get(resource_name, id, opts=None, device_name=None, force_detach=None, instance_id=None, skip_destroy=None, volume_id=None, __props__=None);func GetVolumeAttachment(ctx *Context, name string, id IDInput, state *VolumeAttachmentState, opts ...ResourceOption) (*VolumeAttachment, error)public static VolumeAttachment Get(string name, Input<string> id, VolumeAttachmentState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Device
Name string The device name to expose to the instance (for example,
/dev/sdhorxvdh). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.- Force
Detach bool Set to
trueif 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.- Instance
Id string ID of the Instance to attach to
- Skip
Destroy bool 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.
- Volume
Id string ID of the Volume to be attached
- Device
Name string The device name to expose to the instance (for example,
/dev/sdhorxvdh). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.- Force
Detach bool Set to
trueif 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.- Instance
Id string ID of the Instance to attach to
- Skip
Destroy bool 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.
- Volume
Id string ID of the Volume to be attached
- device
Name string The device name to expose to the instance (for example,
/dev/sdhorxvdh). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.- force
Detach boolean Set to
trueif 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.- instance
Id string ID of the Instance to attach to
- skip
Destroy boolean 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.
- volume
Id string ID of the Volume to be attached
- device_
name str The device name to expose to the instance (for example,
/dev/sdhorxvdh). See Device Naming on Linux Instances and Device Naming on Windows Instances for more information.- force_
detach bool Set to
trueif 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.- instance_
id str ID of the Instance to attach to
- skip_
destroy bool 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.
- volume_
id str ID of the Volume to be attached
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.