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, orVolumeType, there is a cooldown period before another operation can occur. This can cause your stack to report being inUPDATE_IN_PROGRESSorUPDATE_ROLLBACK_IN_PROGRESSfor 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-stackcall 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.
| CloudFormation | AWS::EC2::Volume |
|---|---|
| Source | |
| Type last changed |
Example
// 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',
});
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"
)
// 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();
// 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"
});
// 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
new CfnVolume(scope: Construct, id: string, props?: CfnVolumeProps)
CfnVolume(scope: Construct, id: str, props: typing.Optional[CfnVolumeProps] = None)
new CfnVolume(Construct scope, String id, CfnVolumeProps props)
new CfnVolume(Construct scope, string id, CfnVolumeProps? props = null)
NewCfnVolume(Scope Construct, Id *string, Props CfnVolumeProps)
Construct Props
autoEnableIooptionalboolean | IResolvableauto_enable_iooptionaltyping.Union[bool, IResolvable]autoEnableIooptionalBooleanAutoEnableIooptionalboolAutoEnableIooptionalinterface{} #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 #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 #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{} #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.
notes
Required for io1 and io2 volumes. Optional for gp3 volumes. Omit for all other volume types.
Valid ranges:
- gp3:
3,000( default )- 80,000IOPS - io1:
100 - 64,000IOPS - io2:
100 - 256,000IOPS
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 #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 aliasmy_cmk, usealias/my_cmk. Or to specify the AWS managed key , usealias/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{} #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 #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.
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,384GiB - gp3:
1 - 65,536GiB - io1:
4 - 16,384GiB - io2:
4 - 65,536GiB - st1 and sc1:
125 - 16,384GiB - standard:
1 - 1024GiB
snapshotIdoptionalstringsnapshot_idoptionalstrsnapshotIdoptionalStringSnapshotIdoptionalstringSnapshotIdoptional*string #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 #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 #throughputoptionalnumberthroughputoptionalint | floatthroughputoptionalNumberThroughputoptionaldoubleThroughputoptional*float64 #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 #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 #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
autoEnableIomay be undefinedboolean | IResolvableauto_enable_iomay be undefinedtyping.Union[bool, IResolvable]autoEnableIomay be undefinedBooleanAutoEnableIomay be undefinedboolAutoEnableIomay be undefinedinterface{} #availabilityZonemay be undefinedstringavailability_zonemay be undefinedstravailabilityZonemay be undefinedStringAvailabilityZonemay be undefinedstringAvailabilityZonemay be undefined*string #For example, us-east-1a .
availabilityZoneIdmay be undefinedstringavailability_zone_idmay be undefinedstravailabilityZoneIdmay be undefinedStringAvailabilityZoneIdmay be undefinedstringAvailabilityZoneIdmay be undefined*string #For example, use1-az1 .
CFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAMEstrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*string static #cfnOptionsICfnResourceOptionscfn_optionsICfnResourceOptionscfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptions #cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*string #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{} #iopsmay be undefinednumberiopsmay be undefinedint | floatiopsmay be undefinedNumberIopsmay be undefineddoubleIopsmay be undefined*float64 #kmsKeyIdmay be undefinedstringkms_key_idmay be undefinedstrkmsKeyIdmay be undefinedStringKmsKeyIdmay be undefinedstringKmsKeyIdmay be undefined*string #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{} #outpostArnmay be undefinedstringoutpost_arnmay be undefinedstroutpostArnmay be undefinedStringOutpostArnmay be undefinedstringOutpostArnmay be undefined*string #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 #snapshotIdmay be undefinedstringsnapshot_idmay be undefinedstrsnapshotIdmay be undefinedStringSnapshotIdmay be undefinedstringSnapshotIdmay be undefined*string #sourceVolumeIdmay be undefinedstringsource_volume_idmay be undefinedstrsourceVolumeIdmay be undefinedStringSourceVolumeIdmay be undefinedstringSourceVolumeIdmay be undefined*string #CfnElements must be defined within a stack scope (directly or indirectly).
tagsRawmay be undefinedCfnTag[]tags_rawmay be undefinedtyping.List[CfnTag]tagsRawmay be undefinedList<CfnTag>TagsRawmay be undefinedCfnTag[]TagsRawmay be undefined*[]CfnTag #throughputmay be undefinednumberthroughputmay be undefinedint | floatthroughputmay be undefinedNumberThroughputmay be undefineddoubleThroughputmay be undefined*float64 #volumeInitializationRatemay be undefinednumbervolume_initialization_ratemay be undefinedint | floatvolumeInitializationRatemay be undefinedNumberVolumeInitializationRatemay be undefineddoubleVolumeInitializationRatemay be undefined*float64 #volumeRefVolumeReferencevolume_refVolumeReferencevolumeRefVolumeReferenceVolumeRefVolumeReferenceVolumeRefVolumeReference #volumeTypemay be undefinedstringvolume_typemay be undefinedstrvolumeTypemay be undefinedStringVolumeTypemay be undefinedstringVolumeTypemay be undefined*string #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) #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 #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 #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{}) #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{}) #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,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"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) #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{}) #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) #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) #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) #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 #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 #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{} #inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector) #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 #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 #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 #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 #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{} #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) #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 #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) #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) #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
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 #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.