Class Volume
Creates a new EBS Volume in AWS EC2.
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Volume : Resource, IVolume, IResource
Syntax (vb)
Public Class Volume
Inherits Resource
Implements IVolume, IResource
Remarks
ExampleMetadata: infused
Examples
Instance instance;
Role role;
var volume = new Volume(this, "Volume", new VolumeProps {
AvailabilityZone = "us-west-2a",
Size = Size.Gibibytes(500),
Encrypted = true
});
volume.GrantAttachVolume(role, new [] { instance });
Synopsis
Constructors
Volume(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Volume(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Volume(Construct, String, IVolumeProps) |
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. |
VolumeId | The EBS Volume's ID. |
Methods
FromVolumeAttributes(Construct, String, IVolumeAttributes) | Import an existing EBS Volume into the Stack. |
GrantAttachVolume(IGrantable, IInstance[]) | 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, IInstance[]) | 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) |
Constructors
Volume(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Volume(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Volume(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Volume(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Volume(Construct, String, IVolumeProps)
public Volume(Construct scope, string id, IVolumeProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IVolumeProps
Properties
AvailabilityZone
The availability zone that the EBS Volume is contained within (ex: us-west-2a).
public virtual string AvailabilityZone { get; }
Property Value
System.String
EncryptionKey
The customer-managed encryption key that is used to encrypt the Volume.
public virtual IKey EncryptionKey { get; }
Property Value
VolumeId
The EBS Volume's ID.
public virtual string VolumeId { get; }
Property Value
System.String
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 Constructs.Construct
the scope of the import.
- id System.String
the ID of the imported Volume in the construct tree.
- attrs IVolumeAttributes
the attributes of the imported Volume.
Returns
GrantAttachVolume(IGrantable, IInstance[])
Grants permission to attach this Volume to an instance.
public virtual Grant GrantAttachVolume(IGrantable grantee, IInstance[] instances = null)
Parameters
- grantee IGrantable
- instances IInstance[]
Returns
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 Constructs.Construct[]
- tagKeySuffix System.String
Returns
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, IInstance[])
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, IInstance[] instances = null)
Parameters
- grantee IGrantable
- instances IInstance[]
Returns
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 Constructs.Construct[]
- tagKeySuffix System.String
Returns
Remarks
This is implemented via the same mechanism as IVolume.grantAttachVolumeByResourceTag
,
and is subject to the same conditions.