Show / Hide Table of Contents

Class Volume

Creates a new EBS Volume in AWS EC2.

Inheritance
object
Resource
Volume
Implements
IVolume
IResource
IVolumeRef
IConstruct
IDependable
IEnvironmentAware
Inherited Members
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(string, IArnComponents)
Resource.GetResourceNameAttribute(string)
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Volume : Resource, IVolume, IResource, IVolumeRef, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class Volume Inherits Resource Implements IVolume, IResource, IVolumeRef, IConstruct, IDependable, IEnvironmentAware
Remarks

ExampleMetadata: infused

Examples
new Volume(this, "Volume", new VolumeProps {
                AvailabilityZone = "us-east-1a",
                Size = Size.Gibibytes(125),
                VolumeType = EbsDeviceVolumeType.GP3,
                Throughput = 125
            });

Synopsis

Constructors

Volume(Construct, string, IVolumeProps)

Creates a new EBS Volume in AWS EC2.

Properties

AvailabilityZone

The availability zone that the EBS Volume is contained within (ex: us-west-2a).

EncryptionKey

The customer-managed encryption key that is used to encrypt the Volume.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

VolumeId

The EBS Volume's ID.

VolumeRef

A reference to a Volume resource.

Methods

FromVolumeAttributes(Construct, string, IVolumeAttributes)

Import an existing EBS Volume into the Stack.

GrantAttachVolume(IGrantable, IInstanceRef[]?)

Grants permission to attach this Volume to an instance.

GrantAttachVolumeByResourceTag(IGrantable, Construct[], string?)

Grants permission to attach the Volume by a ResourceTag condition.

GrantDetachVolume(IGrantable, IInstanceRef[]?)

Grants permission to detach this Volume from an instance CAUTION: Granting an instance permission to detach from itself using this method will lead to an unresolvable circular reference between the instance role and the instance.

GrantDetachVolumeByResourceTag(IGrantable, Construct[], string?)

Grants permission to detach the Volume by a ResourceTag condition.

ValidateProps(IVolumeProps)

Creates a new EBS Volume in AWS EC2.

Constructors

Volume(Construct, string, IVolumeProps)

Creates a new EBS Volume in AWS EC2.

public Volume(Construct scope, string id, IVolumeProps props)
Parameters
scope Construct
id string
props IVolumeProps
Remarks

ExampleMetadata: infused

Examples
new Volume(this, "Volume", new VolumeProps {
                AvailabilityZone = "us-east-1a",
                Size = Size.Gibibytes(125),
                VolumeType = EbsDeviceVolumeType.GP3,
                Throughput = 125
            });

Properties

AvailabilityZone

The availability zone that the EBS Volume is contained within (ex: us-west-2a).

public virtual string AvailabilityZone { get; }
Property Value

string

Remarks

ExampleMetadata: infused

EncryptionKey

The customer-managed encryption key that is used to encrypt the Volume.

public virtual IKey? EncryptionKey { get; }
Property Value

IKey

Remarks

ExampleMetadata: infused

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

Remarks

ExampleMetadata: infused

VolumeId

The EBS Volume's ID.

public virtual string VolumeId { get; }
Property Value

string

Remarks

ExampleMetadata: infused

VolumeRef

A reference to a Volume resource.

public virtual IVolumeReference VolumeRef { get; }
Property Value

IVolumeReference

Remarks

ExampleMetadata: infused

Methods

FromVolumeAttributes(Construct, string, IVolumeAttributes)

Import an existing EBS Volume into the Stack.

public static IVolume FromVolumeAttributes(Construct scope, string id, IVolumeAttributes attrs)
Parameters
scope Construct

the scope of the import.

id string

the ID of the imported Volume in the construct tree.

attrs IVolumeAttributes

the attributes of the imported Volume.

Returns

IVolume

Remarks

ExampleMetadata: infused

GrantAttachVolume(IGrantable, IInstanceRef[]?)

Grants permission to attach this Volume to an instance.

public virtual Grant GrantAttachVolume(IGrantable grantee, IInstanceRef[]? instances = null)
Parameters
grantee IGrantable
instances IInstanceRef[]
Returns

Grant

Remarks

CAUTION: Granting an instance permission to attach to itself using this method will lead to an unresolvable circular reference between the instance role and the instance. Use IVolume.grantAttachVolumeToSelf to grant an instance permission to attach this volume to itself.

GrantAttachVolumeByResourceTag(IGrantable, Construct[], string?)

Grants permission to attach the Volume by a ResourceTag condition.

public virtual Grant GrantAttachVolumeByResourceTag(IGrantable grantee, Construct[] constructs, string? tagKeySuffix = null)
Parameters
grantee IGrantable
constructs Construct[]
tagKeySuffix string
Returns

Grant

Remarks

If you are looking to grant an Instance, AutoScalingGroup, EC2-Fleet, SpotFleet, ECS host, etc the ability to attach this volume to itself then this is the method you want to use.

This is implemented by adding a Tag with key VolumeGrantAttach-<suffix> to the given constructs and this Volume, and then conditioning the Grant such that the grantee is only given the ability to AttachVolume if both the Volume and the destination Instance have that tag applied to them.

GrantDetachVolume(IGrantable, IInstanceRef[]?)

Grants permission to detach this Volume from an instance CAUTION: Granting an instance permission to detach from itself using this method will lead to an unresolvable circular reference between the instance role and the instance.

public virtual Grant GrantDetachVolume(IGrantable grantee, IInstanceRef[]? instances = null)
Parameters
grantee IGrantable
instances IInstanceRef[]
Returns

Grant

Remarks

Use IVolume.grantDetachVolumeFromSelf to grant an instance permission to detach this volume from itself.

GrantDetachVolumeByResourceTag(IGrantable, Construct[], string?)

Grants permission to detach the Volume by a ResourceTag condition.

public virtual Grant GrantDetachVolumeByResourceTag(IGrantable grantee, Construct[] constructs, string? tagKeySuffix = null)
Parameters
grantee IGrantable
constructs Construct[]
tagKeySuffix string
Returns

Grant

Remarks

This is implemented via the same mechanism as IVolume.grantAttachVolumeByResourceTag, and is subject to the same conditions.

ValidateProps(IVolumeProps)

Creates a new EBS Volume in AWS EC2.

protected virtual void ValidateProps(IVolumeProps props)
Parameters
props IVolumeProps
Remarks

ExampleMetadata: infused

Examples
new Volume(this, "Volume", new VolumeProps {
                AvailabilityZone = "us-east-1a",
                Size = Size.Gibibytes(125),
                VolumeType = EbsDeviceVolumeType.GP3,
                Throughput = 125
            });

Implements

IVolume
IResource
IVolumeRef
Constructs.IConstruct
Constructs.IDependable
IEnvironmentAware
Back to top Generated by DocFX