Skip to content
v2.278.0

CfnVolume L1 construct ​

Specifies an Amazon Elastic Block Store (Amazon EBS) volume.

You can create an empty volume, a volume from a snapshot, or a volume copy from an existing source volume.

  • When you use AWS CloudFormation to update an Amazon EBS volume that modifies Iops , Size , or VolumeType , there is a cooldown period before another operation can occur. This can cause your stack to report being in UPDATE_IN_PROGRESS or UPDATE_ROLLBACK_IN_PROGRESS for long periods of time. Some common scenarios when you might encounter a cooldown period for Amazon EBS include:

  • You successfully update an Amazon EBS volume and the update succeeds. When you attempt another update within the cooldown window, that update will be subject to a cooldown period.

  • You successfully update an Amazon EBS volume and the update succeeds but another change in your update-stack call fails. The rollback will be subject to a cooldown period.

For more information, see Requirements for EBS volume modifications .

  • Amazon EBS does not support sizing down an Amazon EBS volume. AWS CloudFormation does not attempt to modify an Amazon EBS volume to a smaller size on rollback.

DeletionPolicy attribute

To control how AWS CloudFormation handles the volume when the stack is deleted, set a deletion policy for your volume. You can choose to retain the volume, to delete the volume, or to create a snapshot of the volume. For more information, see DeletionPolicy attribute .

If you set a deletion policy that creates a snapshot, all tags on the volume are included in the snapshot.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
const cfnVolume = new ec2.CfnVolume(this, 'MyCfnVolume', /* all optional props */ {
  autoEnableIo: false,
  availabilityZone: 'availabilityZone',
  availabilityZoneId: 'availabilityZoneId',
  encrypted: false,
  iops: 123,
  kmsKeyId: 'kmsKeyId',
  multiAttachEnabled: false,
  outpostArn: 'outpostArn',
  size: 123,
  snapshotId: 'snapshotId',
  sourceVolumeId: 'sourceVolumeId',
  tags: [{
    key: 'key',
    value: 'value',
  }],
  throughput: 123,
  volumeInitializationRate: 123,
  volumeType: 'volumeType',
});
python
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2

cfn_volume = ec2.CfnVolume(self, "MyCfnVolume",
    auto_enable_io=False,
    availability_zone="availabilityZone",
    availability_zone_id="availabilityZoneId",
    encrypted=False,
    iops=123,
    kms_key_id="kmsKeyId",
    multi_attach_enabled=False,
    outpost_arn="outpostArn",
    size=123,
    snapshot_id="snapshotId",
    source_volume_id="sourceVolumeId",
    tags=[CfnTag(
        key="key",
        value="value"
    )],
    throughput=123,
    volume_initialization_rate=123,
    volume_type="volumeType"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;

CfnVolume cfnVolume = CfnVolume.Builder.create(this, "MyCfnVolume")
        .autoEnableIo(false)
        .availabilityZone("availabilityZone")
        .availabilityZoneId("availabilityZoneId")
        .encrypted(false)
        .iops(123)
        .kmsKeyId("kmsKeyId")
        .multiAttachEnabled(false)
        .outpostArn("outpostArn")
        .size(123)
        .snapshotId("snapshotId")
        .sourceVolumeId("sourceVolumeId")
        .tags(List.of(CfnTag.builder()
                .key("key")
                .value("value")
                .build()))
        .throughput(123)
        .volumeInitializationRate(123)
        .volumeType("volumeType")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.EC2;

var cfnVolume = new CfnVolume(this, "MyCfnVolume", new CfnVolumeProps {
    AutoEnableIo = false,
    AvailabilityZone = "availabilityZone",
    AvailabilityZoneId = "availabilityZoneId",
    Encrypted = false,
    Iops = 123,
    KmsKeyId = "kmsKeyId",
    MultiAttachEnabled = false,
    OutpostArn = "outpostArn",
    Size = 123,
    SnapshotId = "snapshotId",
    SourceVolumeId = "sourceVolumeId",
    Tags = new [] { new CfnTag {
        Key = "key",
        Value = "value"
    } },
    Throughput = 123,
    VolumeInitializationRate = 123,
    VolumeType = "volumeType"
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

cfnVolume := awscdk.Aws_ec2.NewCfnVolume(this, jsii.String("MyCfnVolume"), &CfnVolumeProps{
	AutoEnableIo: jsii.Boolean(false),
	AvailabilityZone: jsii.String("availabilityZone"),
	AvailabilityZoneId: jsii.String("availabilityZoneId"),
	Encrypted: jsii.Boolean(false),
	Iops: jsii.Number(123),
	KmsKeyId: jsii.String("kmsKeyId"),
	MultiAttachEnabled: jsii.Boolean(false),
	OutpostArn: jsii.String("outpostArn"),
	Size: jsii.Number(123),
	SnapshotId: jsii.String("snapshotId"),
	SourceVolumeId: jsii.String("sourceVolumeId"),
	Tags: []CfnTag{
		&CfnTag{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
	Throughput: jsii.Number(123),
	VolumeInitializationRate: jsii.Number(123),
	VolumeType: jsii.String("volumeType"),
})

Initializer ​

ts
new CfnVolume(scope: Construct, id: string, props?: CfnVolumeProps)
python
CfnVolume(scope: Construct, id: str, props: typing.Optional[CfnVolumeProps] = None)
java
new CfnVolume(Construct scope, String id, CfnVolumeProps props)
csharp
new CfnVolume(Construct scope, string id, CfnVolumeProps? props = null)
go
NewCfnVolume(Scope Construct, Id *string, Props CfnVolumeProps)

Construct Props ​

autoEnableIooptionalboolean | IResolvableauto_enable_iooptionaltyping.Union[bool, IResolvable]autoEnableIooptionalBooleanAutoEnableIooptionalboolAutoEnableIooptionalinterface{} #
Indicates whether the volume is auto-enabled for I/O operations.
notes

By default, Amazon EBS disables I/O to the volume from attached EC2 instances when it determines that a volume's data is potentially inconsistent. If the consistency of the volume is not a concern, and you prefer that the volume be made available immediately if it's impaired, you can configure the volume to automatically enable I/O.

availabilityZoneoptionalstringavailability_zoneoptionalstravailabilityZoneoptionalStringAvailabilityZoneoptionalstringAvailabilityZoneoptional*string #
The ID of the Availability Zone in which to create the volume. For example, `us-east-1a` .

Either AvailabilityZone or AvailabilityZoneId must be specified, but not both.

If you are creating a volume copy, omit this parameter. The volume copy is created in the same Availability Zone as the source volume.

availabilityZoneIdoptionalstringavailability_zone_idoptionalstravailabilityZoneIdoptionalStringAvailabilityZoneIdoptionalstringAvailabilityZoneIdoptional*string #
The ID of the Availability Zone in which to create the volume. For example, `use1-az1` .

Either AvailabilityZone or AvailabilityZoneId must be specified, but not both.

If you are creating a volume copy, omit this parameter. The volume copy is created in the same Availability Zone as the source volume.

encryptedoptionalboolean | IResolvableencryptedoptionaltyping.Union[bool, IResolvable]encryptedoptionalBooleanEncryptedoptionalboolEncryptedoptionalinterface{} #
Indicates whether the volume should be encrypted.
notes

The effect of setting the encryption state to true depends on the volume origin (new, from a snapshot, or from an existing volume), starting encryption state, ownership, and whether encryption by default is enabled. For more information, see Encryption by default in the Amazon EBS User Guide .

If you are creating a volume copy, omit this parameter. The volume is automatically encrypted with the same KMS key as the source volume. You can't copy unencrypted volumes.

iopsoptionalnumberiopsoptionalint | floatiopsoptionalNumberIopsoptionaldoubleIopsoptional*float64 #
The number of I/O operations per second (IOPS) to provision for the volume.
notes

Required for io1 and io2 volumes. Optional for gp3 volumes. Omit for all other volume types.

Valid ranges:

  • gp3: 3,000 ( default ) - 80,000 IOPS
  • io1: 100 - 64,000 IOPS
  • io2: 100 - 256,000 IOPS

Instances built on the Nitro System can support up to 256,000 IOPS. Other instances can support up to 32,000 IOPS.

kmsKeyIdoptionalstringkms_key_idoptionalstrkmsKeyIdoptionalStringKmsKeyIdoptionalstringKmsKeyIdoptional*string #
The identifier of the AWS KMS key to use for Amazon EBS encryption.
notes

If KmsKeyId is specified, the encrypted state must be true .

If you omit this property and your account is enabled for encryption by default, or Encrypted is set to true , then the volume is encrypted using the default key specified for your account. If your account does not have a default key, then the volume is encrypted using the AWS managed key .

Alternatively, if you want to specify a different key, you can specify one of the following:

  • Key ID. For example, 1234abcd-12ab-34cd-56ef-1234567890ab.
  • Key alias. Specify the alias for the key, prefixed with alias/ . For example, for a key with the alias my_cmk , use alias/my_cmk . Or to specify the AWS managed key , use alias/aws/ebs .
  • Key ARN. For example, arn:aws:kms:us-east-1:012345678910:key/1234abcd-12ab-34cd-56ef-1234567890ab.
  • Alias ARN. For example, arn:aws:kms:us-east-1:012345678910:alias/ExampleAlias.

If you are creating a volume copy, omit this parameter. The volume is automatically encrypted with the same KMS key as the source volume. You can't copy unencrypted volumes.

multiAttachEnabledoptionalboolean | IResolvablemulti_attach_enabledoptionaltyping.Union[bool, IResolvable]multiAttachEnabledoptionalBooleanMultiAttachEnabledoptionalboolMultiAttachEnabledoptionalinterface{} #
Indicates whether Amazon EBS Multi-Attach is enabled.
notes

AWS CloudFormation does not currently support updating a single-attach volume to be multi-attach enabled, updating a multi-attach enabled volume to be single-attach, or updating the size or number of I/O operations per second (IOPS) of a multi-attach enabled volume.

outpostArnoptionalstringoutpost_arnoptionalstroutpostArnoptionalStringOutpostArnoptionalstringOutpostArnoptional*string #
The Amazon Resource Name (ARN) of the Outpost on which to create the volume.
notes

If you intend to use a volume with an instance running on an outpost, then you must create the volume on the same outpost as the instance. You can't use a volume created in an AWS Region with an instance on an AWS outpost, or the other way around.

sizeoptionalnumbersizeoptionalint | floatsizeoptionalNumberSizeoptionaldoubleSizeoptional*float64 #
The size of the volume, in GiBs.
notes
  • Required for new empty volumes.
  • Optional for volumes created from snapshots and volume copies. In this case, the size defaults to the size of the snapshot or source volume. You can optionally specify a size that is equal to or larger than the size of the source snapshot or volume.

Supported volume sizes:

  • gp2: 1 - 16,384 GiB
  • gp3: 1 - 65,536 GiB
  • io1: 4 - 16,384 GiB
  • io2: 4 - 65,536 GiB
  • st1 and sc1: 125 - 16,384 GiB
  • standard: 1 - 1024 GiB
snapshotIdoptionalstringsnapshot_idoptionalstrsnapshotIdoptionalStringSnapshotIdoptionalstringSnapshotIdoptional*string #
The snapshot from which to create the volume.

Only specify to create a volume from a snapshot. To create a new empty volume, omit this parameter and specify a value for Size instead. To create a volume copy, omit this parameter and specify SourceVolumeId instead.

sourceVolumeIdoptionalstringsource_volume_idoptionalstrsourceVolumeIdoptionalStringSourceVolumeIdoptionalstringSourceVolumeIdoptional*string #
The ID of the source EBS volume to copy.

When specified, the volume is created as an exact copy of the specified volume. Only specify to create a volume copy. To create a new empty volume or to create a volume from a snapshot, omit this parameter,

tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag #
The tags to apply to the volume during creation.
throughputoptionalnumberthroughputoptionalint | floatthroughputoptionalNumberThroughputoptionaldoubleThroughputoptional*float64 #
The throughput to provision for a volume, with a maximum of 1,000 MiB/s.

This parameter is valid only for gp3 volumes. The default value is 125.

Valid Range: Minimum value of 125. Maximum value of 1000.

volumeInitializationRateoptionalnumbervolume_initialization_rateoptionalint | floatvolumeInitializationRateoptionalNumberVolumeInitializationRateoptionaldoubleVolumeInitializationRateoptional*float64 #
Specifies the Amazon EBS Provisioned Rate for Volume Initialization (volume initialization rate), in MiB/s, at which to download the snapshot blocks from Amazon S3 to the volume.
notes

This is also known as volume initialization . Specifying a volume initialization rate ensures that the volume is initialized at a predictable and consistent rate after creation.

This parameter is supported only for volumes created from snapshots. Omit this parameter if:

  • You want to create the volume using fast snapshot restore. You must specify a snapshot that is enabled for fast snapshot restore. In this case, the volume is fully initialized at creation.

If you specify a snapshot that is enabled for fast snapshot restore and a volume initialization rate, the volume will be initialized at the specified rate instead of fast snapshot restore.

  • You want to create a volume that is initialized at the default rate.

For more information, see Initialize Amazon EBS volumes in the Amazon EC2 User Guide .

Valid range: 100 - 300 MiB/s

volumeTypeoptionalstringvolume_typeoptionalstrvolumeTypeoptionalStringVolumeTypeoptionalstringVolumeTypeoptional*string #
The volume type. This parameter can be one of the following values:.
notes
  • General Purpose SSD: gp2 | gp3
  • Provisioned IOPS SSD: io1 | io2
  • Throughput Optimized HDD: st1
  • Cold HDD: sc1
  • Magnetic: standard

Throughput Optimized HDD ( st1 ) and Cold HDD ( sc1 ) volumes can't be used as boot volumes.

For more information, see Amazon EBS volume types in the Amazon EBS User Guide .

Default: gp2

Properties ​

attrVolumeIdstringattr_volume_idstrattrVolumeIdStringAttrVolumeIdstringAttrVolumeId*string #
The ID of the volume.
autoEnableIomay be undefinedboolean | IResolvableauto_enable_iomay be undefinedtyping.Union[bool, IResolvable]autoEnableIomay be undefinedBooleanAutoEnableIomay be undefinedboolAutoEnableIomay be undefinedinterface{} #
Indicates whether the volume is auto-enabled for I/O operations.
availabilityZonemay be undefinedstringavailability_zonemay be undefinedstravailabilityZonemay be undefinedStringAvailabilityZonemay be undefinedstringAvailabilityZonemay be undefined*string #
The ID of the Availability Zone in which to create the volume.

For example, us-east-1a .

availabilityZoneIdmay be undefinedstringavailability_zone_idmay be undefinedstravailabilityZoneIdmay be undefinedStringAvailabilityZoneIdmay be undefinedstringAvailabilityZoneIdmay be undefined*string #
The ID of the Availability Zone in which to create the volume.

For example, use1-az1 .

CFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAMEstrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*string static #
The CloudFormation resource type name for this resource class.
Options for this resource, such as condition, update policy etc.
cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*string #
AWS resource type.
creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*string #
encryptedmay be undefinedboolean | IResolvableencryptedmay be undefinedtyping.Union[bool, IResolvable]encryptedmay be undefinedBooleanEncryptedmay be undefinedboolEncryptedmay be undefinedinterface{} #
Indicates whether the volume should be encrypted.
iopsmay be undefinednumberiopsmay be undefinedint | floatiopsmay be undefinedNumberIopsmay be undefineddoubleIopsmay be undefined*float64 #
The number of I/O operations per second (IOPS) to provision for the volume.
kmsKeyIdmay be undefinedstringkms_key_idmay be undefinedstrkmsKeyIdmay be undefinedStringKmsKeyIdmay be undefinedstringKmsKeyIdmay be undefined*string #
The identifier of the AWS KMS key to use for Amazon EBS encryption.
logicalIdstringlogical_idstrlogicalIdStringLogicalIdstringLogicalId*string #
The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

multiAttachEnabledmay be undefinedboolean | IResolvablemulti_attach_enabledmay be undefinedtyping.Union[bool, IResolvable]multiAttachEnabledmay be undefinedBooleanMultiAttachEnabledmay be undefinedboolMultiAttachEnabledmay be undefinedinterface{} #
Indicates whether Amazon EBS Multi-Attach is enabled.
nodeNodenodeNodenodeNodeNodeNodeNodeNode #
The tree node.
outpostArnmay be undefinedstringoutpost_arnmay be undefinedstroutpostArnmay be undefinedStringOutpostArnmay be undefinedstringOutpostArnmay be undefined*string #
The Amazon Resource Name (ARN) of the Outpost on which to create the volume.
refstringrefstrrefStringRefstringRef*string #
Return a string that will be resolved to a CloudFormation `{ Ref }` for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).

sizemay be undefinednumbersizemay be undefinedint | floatsizemay be undefinedNumberSizemay be undefineddoubleSizemay be undefined*float64 #
The size of the volume, in GiBs.
snapshotIdmay be undefinedstringsnapshot_idmay be undefinedstrsnapshotIdmay be undefinedStringSnapshotIdmay be undefinedstringSnapshotIdmay be undefined*string #
The snapshot from which to create the volume.
sourceVolumeIdmay be undefinedstringsource_volume_idmay be undefinedstrsourceVolumeIdmay be undefinedStringSourceVolumeIdmay be undefinedstringSourceVolumeIdmay be undefined*string #
The ID of the source EBS volume to copy.
stackStackstackStackstackStackStackStackStackStack #
The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

Tag Manager which manages the tags for this resource.
tagsRawmay be undefinedCfnTag[]tags_rawmay be undefinedtyping.List[CfnTag]tagsRawmay be undefinedList<CfnTag>TagsRawmay be undefinedCfnTag[]TagsRawmay be undefined*[]CfnTag #
The tags to apply to the volume during creation.
throughputmay be undefinednumberthroughputmay be undefinedint | floatthroughputmay be undefinedNumberThroughputmay be undefineddoubleThroughputmay be undefined*float64 #
The throughput to provision for a volume, with a maximum of 1,000 MiB/s.
volumeInitializationRatemay be undefinednumbervolume_initialization_ratemay be undefinedint | floatvolumeInitializationRatemay be undefinedNumberVolumeInitializationRatemay be undefineddoubleVolumeInitializationRatemay be undefined*float64 #
Specifies the Amazon EBS Provisioned Rate for Volume Initialization (volume initialization rate), in MiB/s, at which to download the snapshot blocks from Amazon S3 to the volume.
A reference to a Volume resource.
volumeTypemay be undefinedstringvolume_typemay be undefinedstrvolumeTypemay be undefinedStringVolumeTypemay be undefinedstringVolumeTypemay be undefined*string #
The volume type.

This parameter can be one of the following values:.

Methods ​

addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string) #
Syntactic sugar for `addOverride(path, undefined)`.
1 parameter

Parameters

  • pathpathpathpathPath — The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource) deprecated #
Use `addResourceDependency` instead.

This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.

addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource) deprecated #
Use `addResourceDependency` instead.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.

addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{}) #
Add a value to the CloudFormation Resource Metadata.
addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{}) #
Adds an override to the synthesized CloudFormation resource.
notes · 2 parameters

To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

typescript
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');

would add the overrides

json
"Properties": {
  "GlobalSecondaryIndexes": [
    {
      "Projection": {
        "NonKeyAttributes": [ "myattribute" ]
        ...
      }
      ...
    },
    {
      "ProjectionType": "INCLUDE"
      ...
    },
  ]
  ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.

Parameters

  • pathpathpathpathPath — - The path of the property, you can use dot notation to override values in complex types.
  • valuevaluevaluevalueValue — - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string) #
Adds an override that deletes the value of a property from the resource definition.
1 parameter

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{}) #
Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).

2 parameters

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path of the property.
  • valuevaluevaluevalueValue — The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string) #
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength) #
Sets the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.

1 parameter

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions) #
Sets the deletion policy of the resource based on the removal policy specified.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:

arnForVolume(resource: IVolumeRef): string@staticmethod def arn_for_volume(resource: IVolumeRef) -> strpublic static String arnForVolume(IVolumeRef resource)public static string ArnForVolume(IVolumeRef resource)func ArnForVolume(Resource IVolumeRef) *string static #
cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string #
fromVolumeId(scope: Construct, id: string, volumeId: string): IVolumeRef@staticmethod def from_volume_id(scope: Construct, id: str, volume_id: str) -> IVolumeRefpublic static IVolumeRef fromVolumeId(Construct scope, String id, String volumeId)public static IVolumeRef FromVolumeId(Construct scope, string id, string volumeId)func FromVolumeId(Scope Construct, Id *string, VolumeId *string) IVolumeRef static #
Creates a new IVolumeRef from a volumeId.
getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference #
Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.

1 parameter

Parameters

  • attributeNameattribute_nameattributeNameattributeNameAttributeName — The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{} #
Retrieve a value value from the CloudFormation Resource Metadata.
inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector) #
Examines the CloudFormation resource and discloses attributes.
1 parameter

Parameters

  • inspectorinspectorinspectorinspectorInspector — tree inspector to collect and process attributes.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *bool static #
Returns `true` if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

returns

Returns: The construct as a stack element or undefined if it is not a stack element.

isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *bool static #
Check whether the given object is a CfnResource.
isCfnVolume(x: any): boolean@staticmethod def is_cfn_volume(x: Any) -> boolpublic static Boolean isCfnVolume(Object x)public static bool IsCfnVolume(object x)func IsCfnVolume(X interface{}) *bool static #
Checks whether the given object is a CfnVolume.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *bool static #
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{} #
Retrieves an array of resources and stacks this resource depends on.

For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.

overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string) #
Overrides the auto-generated logical ID with a specific ID.
1 parameter

Parameters

  • newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId — The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource) deprecated #
Use `removeResourceDependency` instead

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource) #
Indicates that this resource no longer depends on another resource.

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource) #
Replaces one dependency with another.
2 parameters

Parameters

  • targettargettargettargetTarget — The dependency to replace.
  • newTargetnew_targetnewTargetnewTargetNewTarget — The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string #
Returns a string representation of this construct.
returns

Returns: a string representation of this resource

with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct #
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.