aws-cdk-lib.aws_s3.CfnBucket

class CfnBucket (construct)

LanguageType name
.NETAmazon.CDK.AWS.S3.CfnBucket
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awss3#CfnBucket
Javasoftware.amazon.awscdk.services.s3.CfnBucket
Pythonaws_cdk.aws_s3.CfnBucket
TypeScript aws-cdk-lib » aws_s3 » CfnBucket

Implements IConstruct, IDependable, IInspectable

A CloudFormation AWS::S3::Bucket.

The AWS::S3::Bucket resource creates an Amazon S3 bucket in the same AWS Region where you create the AWS CloudFormation stack.

To control how AWS CloudFormation handles the bucket when the stack is deleted, you can set a deletion policy for your bucket. You can choose to retain the bucket or to delete the bucket. For more information, see DeletionPolicy Attribute .

You can only delete empty buckets. Deletion fails for buckets that have contents.

Example

declare const cfnTemplate: cfn_inc.CfnInclude;
const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;

const role = new iam.Role(this, 'Role', {
  assumedBy: new iam.AnyPrincipal(),
});
role.addToPolicy(new iam.PolicyStatement({
  actions: ['s3:*'],
  resources: [cfnBucket.attrArn],
}));

Initializer

new CfnBucket(scope: Construct, id: string, props?: CfnBucketProps)

Parameters

  • scope Construct — - scope in which this resource is defined.
  • id string — - scoped id of the resource.
  • props CfnBucketProps — - resource properties.

Create a new AWS::S3::Bucket.

Construct Props

NameTypeDescription
accelerateConfiguration?IResolvable | AccelerateConfigurationPropertyConfigures the transfer acceleration state for an Amazon S3 bucket.
accessControl?stringA canned access control list (ACL) that grants predefined permissions to the bucket.
analyticsConfigurations?IResolvable | IResolvable | AnalyticsConfigurationProperty[]Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket.
bucketEncryption?IResolvable | BucketEncryptionPropertySpecifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3), AWS KMS-managed keys (SSE-KMS), or dual-layer server-side encryption with KMS-managed keys (DSSE-KMS).
bucketName?stringA name for the bucket.
corsConfiguration?IResolvable | CorsConfigurationPropertyDescribes the cross-origin access configuration for objects in an Amazon S3 bucket.
intelligentTieringConfigurations?IResolvable | IResolvable | IntelligentTieringConfigurationProperty[]Defines how Amazon S3 handles Intelligent-Tiering storage.
inventoryConfigurations?IResolvable | IResolvable | InventoryConfigurationProperty[]Specifies the inventory configuration for an Amazon S3 bucket.
lifecycleConfiguration?IResolvable | LifecycleConfigurationPropertySpecifies the lifecycle configuration for objects in an Amazon S3 bucket.
loggingConfiguration?IResolvable | LoggingConfigurationPropertySettings that define where logs are stored.
metricsConfigurations?IResolvable | IResolvable | MetricsConfigurationProperty[]Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.
notificationConfiguration?IResolvable | NotificationConfigurationPropertyConfiguration that defines how Amazon S3 handles bucket notifications.
objectLockConfiguration?IResolvable | ObjectLockConfigurationPropertyPlaces an Object Lock configuration on the specified bucket.
objectLockEnabled?boolean | IResolvableIndicates whether this bucket has an Object Lock configuration enabled.
ownershipControls?IResolvable | OwnershipControlsPropertyConfiguration that defines how Amazon S3 handles Object Ownership rules.
publicAccessBlockConfiguration?IResolvable | PublicAccessBlockConfigurationPropertyConfiguration that defines how Amazon S3 handles public access.
replicationConfiguration?IResolvable | ReplicationConfigurationPropertyConfiguration for replicating objects in an S3 bucket.
tags?CfnTag[]An arbitrary set of tags (key-value pairs) for this S3 bucket.
versioningConfiguration?IResolvable | VersioningConfigurationPropertyEnables multiple versions of all objects in this bucket.
websiteConfiguration?IResolvable | WebsiteConfigurationPropertyInformation used to configure the bucket as a static website.

accelerateConfiguration?

Type: IResolvable | AccelerateConfigurationProperty (optional)

Configures the transfer acceleration state for an Amazon S3 bucket.

For more information, see Amazon S3 Transfer Acceleration in the Amazon S3 User Guide .


accessControl?

Type: string (optional)

A canned access control list (ACL) that grants predefined permissions to the bucket.

For more information about canned ACLs, see Canned ACL in the Amazon S3 User Guide .

Be aware that the syntax for this property differs from the information provided in the Amazon S3 User Guide . The AccessControl property is case-sensitive and must be one of the following values: Private, PublicRead, PublicReadWrite, AuthenticatedRead, LogDeliveryWrite, BucketOwnerRead, BucketOwnerFullControl, or AwsExecRead.


analyticsConfigurations?

Type: IResolvable | IResolvable | AnalyticsConfigurationProperty[] (optional)

Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket.


bucketEncryption?

Type: IResolvable | BucketEncryptionProperty (optional)

Specifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3), AWS KMS-managed keys (SSE-KMS), or dual-layer server-side encryption with KMS-managed keys (DSSE-KMS).

For information about the Amazon S3 default encryption feature, see Amazon S3 Default Encryption for S3 Buckets in the Amazon S3 User Guide .


bucketName?

Type: string (optional)

A name for the bucket.

If you don't specify a name, AWS CloudFormation generates a unique ID and uses that ID for the bucket name. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-) and must follow Amazon S3 bucket restrictions and limitations . For more information, see Rules for naming Amazon S3 buckets in the Amazon S3 User Guide .

If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you need to replace the resource, specify a new name.


corsConfiguration?

Type: IResolvable | CorsConfigurationProperty (optional)

Describes the cross-origin access configuration for objects in an Amazon S3 bucket.

For more information, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide .


intelligentTieringConfigurations?

Type: IResolvable | IResolvable | IntelligentTieringConfigurationProperty[] (optional)

Defines how Amazon S3 handles Intelligent-Tiering storage.


inventoryConfigurations?

Type: IResolvable | IResolvable | InventoryConfigurationProperty[] (optional)

Specifies the inventory configuration for an Amazon S3 bucket.

For more information, see GET Bucket inventory in the Amazon S3 API Reference .


lifecycleConfiguration?

Type: IResolvable | LifecycleConfigurationProperty (optional)

Specifies the lifecycle configuration for objects in an Amazon S3 bucket.

For more information, see Object Lifecycle Management in the Amazon S3 User Guide .


loggingConfiguration?

Type: IResolvable | LoggingConfigurationProperty (optional)

Settings that define where logs are stored.


metricsConfigurations?

Type: IResolvable | IResolvable | MetricsConfigurationProperty[] (optional)

Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.

If you're updating an existing metrics configuration, note that this is a full replacement of the existing metrics configuration. If you don't include the elements you want to keep, they are erased. For more information, see PutBucketMetricsConfiguration .


notificationConfiguration?

Type: IResolvable | NotificationConfigurationProperty (optional)

Configuration that defines how Amazon S3 handles bucket notifications.


objectLockConfiguration?

Type: IResolvable | ObjectLockConfigurationProperty (optional)

Places an Object Lock configuration on the specified bucket.

The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket. For more information, see Locking Objects .

  • The DefaultRetention settings require both a mode and a period.
  • The DefaultRetention period can be either Days or Years but you must select one. You cannot specify Days and Years at the same time.
  • You can only enable Object Lock for new buckets. If you want to turn on Object Lock for an existing bucket, contact AWS Support.

objectLockEnabled?

Type: boolean | IResolvable (optional)

Indicates whether this bucket has an Object Lock configuration enabled.

Enable ObjectLockEnabled when you apply ObjectLockConfiguration to a bucket.


ownershipControls?

Type: IResolvable | OwnershipControlsProperty (optional)

Configuration that defines how Amazon S3 handles Object Ownership rules.


publicAccessBlockConfiguration?

Type: IResolvable | PublicAccessBlockConfigurationProperty (optional)

Configuration that defines how Amazon S3 handles public access.


replicationConfiguration?

Type: IResolvable | ReplicationConfigurationProperty (optional)

Configuration for replicating objects in an S3 bucket.

To enable replication, you must also enable versioning by using the VersioningConfiguration property.

Amazon S3 can store replicated objects in a single destination bucket or multiple destination buckets. The destination bucket or buckets must already exist.


tags?

Type: CfnTag[] (optional)

An arbitrary set of tags (key-value pairs) for this S3 bucket.


versioningConfiguration?

Type: IResolvable | VersioningConfigurationProperty (optional)

Enables multiple versions of all objects in this bucket.

You might enable versioning to prevent objects from being deleted or overwritten by mistake or to archive objects so that you can retrieve previous versions of them.


websiteConfiguration?

Type: IResolvable | WebsiteConfigurationProperty (optional)

Information used to configure the bucket as a static website.

For more information, see Hosting Websites on Amazon S3 .

Properties

NameTypeDescription
attrArnstringReturns the Amazon Resource Name (ARN) of the specified bucket.
attrDomainNamestringReturns the IPv4 DNS name of the specified bucket.
attrDualStackDomainNamestringReturns the IPv6 DNS name of the specified bucket.
attrRegionalDomainNamestringReturns the regional domain name of the specified bucket.
attrWebsiteUrlstringReturns the Amazon S3 website endpoint for the specified bucket.
cfnOptionsICfnResourceOptionsOptions for this resource, such as condition, update policy etc.
cfnProperties{ [string]: any }
cfnResourceTypestringAWS resource type.
creationStackstring[]
logicalIdstringThe logical ID for this CloudFormation stack element.
nodeNodeThe tree node.
refstringReturn a string that will be resolved to a CloudFormation { Ref } for this element.
stackStackThe stack in which this element is defined.
tagsTagManagerAn arbitrary set of tags (key-value pairs) for this S3 bucket.
accelerateConfiguration?IResolvable | AccelerateConfigurationPropertyConfigures the transfer acceleration state for an Amazon S3 bucket.
accessControl?stringA canned access control list (ACL) that grants predefined permissions to the bucket.
analyticsConfigurations?IResolvable | IResolvable | AnalyticsConfigurationProperty[]Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket.
bucketEncryption?IResolvable | BucketEncryptionPropertySpecifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3), AWS KMS-managed keys (SSE-KMS), or dual-layer server-side encryption with KMS-managed keys (DSSE-KMS).
bucketName?stringA name for the bucket.
corsConfiguration?IResolvable | CorsConfigurationPropertyDescribes the cross-origin access configuration for objects in an Amazon S3 bucket.
intelligentTieringConfigurations?IResolvable | IResolvable | IntelligentTieringConfigurationProperty[]Defines how Amazon S3 handles Intelligent-Tiering storage.
inventoryConfigurations?IResolvable | IResolvable | InventoryConfigurationProperty[]Specifies the inventory configuration for an Amazon S3 bucket.
lifecycleConfiguration?IResolvable | LifecycleConfigurationPropertySpecifies the lifecycle configuration for objects in an Amazon S3 bucket.
loggingConfiguration?IResolvable | LoggingConfigurationPropertySettings that define where logs are stored.
metricsConfigurations?IResolvable | IResolvable | MetricsConfigurationProperty[]Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.
notificationConfiguration?IResolvable | NotificationConfigurationPropertyConfiguration that defines how Amazon S3 handles bucket notifications.
objectLockConfiguration?IResolvable | ObjectLockConfigurationPropertyPlaces an Object Lock configuration on the specified bucket.
objectLockEnabled?boolean | IResolvableIndicates whether this bucket has an Object Lock configuration enabled.
ownershipControls?IResolvable | OwnershipControlsPropertyConfiguration that defines how Amazon S3 handles Object Ownership rules.
publicAccessBlockConfiguration?IResolvable | PublicAccessBlockConfigurationPropertyConfiguration that defines how Amazon S3 handles public access.
replicationConfiguration?IResolvable | ReplicationConfigurationPropertyConfiguration for replicating objects in an S3 bucket.
versioningConfiguration?IResolvable | VersioningConfigurationPropertyEnables multiple versions of all objects in this bucket.
websiteConfiguration?IResolvable | WebsiteConfigurationPropertyInformation used to configure the bucket as a static website.
static CFN_RESOURCE_TYPE_NAMEstringThe CloudFormation resource type name for this resource class.

attrArn

Type: string

Returns the Amazon Resource Name (ARN) of the specified bucket.

Example: arn:aws:s3:::DOC-EXAMPLE-BUCKET


attrDomainName

Type: string

Returns the IPv4 DNS name of the specified bucket.

Example: DOC-EXAMPLE-BUCKET.s3.amazonaws.com


attrDualStackDomainName

Type: string

Returns the IPv6 DNS name of the specified bucket.

Example: DOC-EXAMPLE-BUCKET.s3.dualstack.us-east-2.amazonaws.com

For more information about dual-stack endpoints, see Using Amazon S3 Dual-Stack Endpoints .


attrRegionalDomainName

Type: string

Returns the regional domain name of the specified bucket.

Example: DOC-EXAMPLE-BUCKET.s3.us-east-2.amazonaws.com


attrWebsiteUrl

Type: string

Returns the Amazon S3 website endpoint for the specified bucket.

Example (IPv4): http://DOC-EXAMPLE-BUCKET.s3-website.us-east-2.amazonaws.com

Example (IPv6): http://DOC-EXAMPLE-BUCKET.s3.dualstack.us-east-2.amazonaws.com


cfnOptions

Type: ICfnResourceOptions

Options for this resource, such as condition, update policy etc.


cfnProperties

Type: { [string]: any }


cfnResourceType

Type: string

AWS resource type.


creationStack

Type: string[]


logicalId

Type: 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).


node

Type: Node

The tree node.


ref

Type: 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 }).


stack

Type: Stack

The stack in which this element is defined.

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


tags

Type: TagManager

An arbitrary set of tags (key-value pairs) for this S3 bucket.


accelerateConfiguration?

Type: IResolvable | AccelerateConfigurationProperty (optional)

Configures the transfer acceleration state for an Amazon S3 bucket.

For more information, see Amazon S3 Transfer Acceleration in the Amazon S3 User Guide .


accessControl?

Type: string (optional)

A canned access control list (ACL) that grants predefined permissions to the bucket.

For more information about canned ACLs, see Canned ACL in the Amazon S3 User Guide .

Be aware that the syntax for this property differs from the information provided in the Amazon S3 User Guide . The AccessControl property is case-sensitive and must be one of the following values: Private, PublicRead, PublicReadWrite, AuthenticatedRead, LogDeliveryWrite, BucketOwnerRead, BucketOwnerFullControl, or AwsExecRead.


analyticsConfigurations?

Type: IResolvable | IResolvable | AnalyticsConfigurationProperty[] (optional)

Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket.


bucketEncryption?

Type: IResolvable | BucketEncryptionProperty (optional)

Specifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3), AWS KMS-managed keys (SSE-KMS), or dual-layer server-side encryption with KMS-managed keys (DSSE-KMS).

For information about the Amazon S3 default encryption feature, see Amazon S3 Default Encryption for S3 Buckets in the Amazon S3 User Guide .


bucketName?

Type: string (optional)

A name for the bucket.

If you don't specify a name, AWS CloudFormation generates a unique ID and uses that ID for the bucket name. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-) and must follow Amazon S3 bucket restrictions and limitations . For more information, see Rules for naming Amazon S3 buckets in the Amazon S3 User Guide .

If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you need to replace the resource, specify a new name.


corsConfiguration?

Type: IResolvable | CorsConfigurationProperty (optional)

Describes the cross-origin access configuration for objects in an Amazon S3 bucket.

For more information, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide .


intelligentTieringConfigurations?

Type: IResolvable | IResolvable | IntelligentTieringConfigurationProperty[] (optional)

Defines how Amazon S3 handles Intelligent-Tiering storage.


inventoryConfigurations?

Type: IResolvable | IResolvable | InventoryConfigurationProperty[] (optional)

Specifies the inventory configuration for an Amazon S3 bucket.

For more information, see GET Bucket inventory in the Amazon S3 API Reference .


lifecycleConfiguration?

Type: IResolvable | LifecycleConfigurationProperty (optional)

Specifies the lifecycle configuration for objects in an Amazon S3 bucket.

For more information, see Object Lifecycle Management in the Amazon S3 User Guide .


loggingConfiguration?

Type: IResolvable | LoggingConfigurationProperty (optional)

Settings that define where logs are stored.


metricsConfigurations?

Type: IResolvable | IResolvable | MetricsConfigurationProperty[] (optional)

Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.

If you're updating an existing metrics configuration, note that this is a full replacement of the existing metrics configuration. If you don't include the elements you want to keep, they are erased. For more information, see PutBucketMetricsConfiguration .


notificationConfiguration?

Type: IResolvable | NotificationConfigurationProperty (optional)

Configuration that defines how Amazon S3 handles bucket notifications.


objectLockConfiguration?

Type: IResolvable | ObjectLockConfigurationProperty (optional)

Places an Object Lock configuration on the specified bucket.

The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket. For more information, see Locking Objects .

  • The DefaultRetention settings require both a mode and a period.
  • The DefaultRetention period can be either Days or Years but you must select one. You cannot specify Days and Years at the same time.
  • You can only enable Object Lock for new buckets. If you want to turn on Object Lock for an existing bucket, contact AWS Support.

objectLockEnabled?

Type: boolean | IResolvable (optional)

Indicates whether this bucket has an Object Lock configuration enabled.

Enable ObjectLockEnabled when you apply ObjectLockConfiguration to a bucket.


ownershipControls?

Type: IResolvable | OwnershipControlsProperty (optional)

Configuration that defines how Amazon S3 handles Object Ownership rules.


publicAccessBlockConfiguration?

Type: IResolvable | PublicAccessBlockConfigurationProperty (optional)

Configuration that defines how Amazon S3 handles public access.


replicationConfiguration?

Type: IResolvable | ReplicationConfigurationProperty (optional)

Configuration for replicating objects in an S3 bucket.

To enable replication, you must also enable versioning by using the VersioningConfiguration property.

Amazon S3 can store replicated objects in a single destination bucket or multiple destination buckets. The destination bucket or buckets must already exist.


versioningConfiguration?

Type: IResolvable | VersioningConfigurationProperty (optional)

Enables multiple versions of all objects in this bucket.

You might enable versioning to prevent objects from being deleted or overwritten by mistake or to archive objects so that you can retrieve previous versions of them.


websiteConfiguration?

Type: IResolvable | WebsiteConfigurationProperty (optional)

Information used to configure the bucket as a static website.

For more information, see Hosting Websites on Amazon S3 .


static CFN_RESOURCE_TYPE_NAME

Type: string

The CloudFormation resource type name for this resource class.

Methods

NameDescription
addDeletionOverride(path)Syntactic sugar for addOverride(path, undefined).
addDependency(target)Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
addDependsOn(target)⚠️Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
addMetadata(key, value)Add a value to the CloudFormation Resource Metadata.
addOverride(path, value)Adds an override to the synthesized CloudFormation resource.
addPropertyDeletionOverride(propertyPath)Adds an override that deletes the value of a property from the resource definition.
addPropertyOverride(propertyPath, value)Adds an override to a resource property.
applyRemovalPolicy(policy?, options?)Sets the deletion policy of the resource based on the removal policy specified.
getAtt(attributeName, typeHint?)Returns a token for an runtime attribute of this resource.
getMetadata(key)Retrieve a value value from the CloudFormation Resource Metadata.
inspect(inspector)Examines the CloudFormation resource and discloses attributes.
obtainDependencies()Retrieves an array of resources this resource depends on.
obtainResourceDependencies()Get a shallow copy of dependencies between this resource and other resources in the same stack.
overrideLogicalId(newLogicalId)Overrides the auto-generated logical ID with a specific ID.
removeDependency(target)Indicates that this resource no longer depends on another resource.
replaceDependency(target, newTarget)Replaces one dependency with another.
toString()Returns a string representation of this construct.
protected renderProperties(props)

addDeletionOverride(path)

public addDeletionOverride(path: string): void

Parameters

  • path string — The path of the value to delete.

Syntactic sugar for addOverride(path, undefined).


addDependency(target)

public addDependency(target: CfnResource): void

Parameters

  • target CfnResource

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.

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


addDependsOn(target)⚠️

public addDependsOn(target: CfnResource): void

⚠️ Deprecated: use addDependency

Parameters

  • target CfnResource

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.


addMetadata(key, value)

public addMetadata(key: string, value: any): void

Parameters

  • key string
  • value any

Add a value to the CloudFormation Resource Metadata.

See also: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)


addOverride(path, value)

public addOverride(path: string, value: any): void

Parameters

  • path string — - The path of the property, you can use dot notation to override values in complex types.
  • value any — - The value.

Adds an override to the synthesized CloudFormation resource.

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.


addPropertyDeletionOverride(propertyPath)

public addPropertyDeletionOverride(propertyPath: string): void

Parameters

  • propertyPath string — The path to the property.

Adds an override that deletes the value of a property from the resource definition.


addPropertyOverride(propertyPath, value)

public addPropertyOverride(propertyPath: string, value: any): void

Parameters

  • propertyPath string — The path of the property.
  • value any — The value.

Adds an override to a resource property.

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


applyRemovalPolicy(policy?, options?)

public applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): void

Parameters

  • policy RemovalPolicy
  • options RemovalPolicyOptions

Sets the deletion policy of the resource based on the removal policy specified.

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:

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html#aws-attribute-deletionpolicy-options


getAtt(attributeName, typeHint?)

public getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Reference

Parameters

  • attributeName string — The name of the attribute.
  • typeHint ResolutionTypeHint

Returns

  • 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.


getMetadata(key)

public getMetadata(key: string): any

Parameters

  • key string

Returns

  • any

Retrieve a value value from the CloudFormation Resource Metadata.

See also: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)


inspect(inspector)

public inspect(inspector: TreeInspector): void

Parameters

  • inspector TreeInspector — - tree inspector to collect and process attributes.

Examines the CloudFormation resource and discloses attributes.


obtainDependencies()

public obtainDependencies(): Stack &#124; CfnResource[]

Returns

  • Stack | CfnResource[]

Retrieves an array of resources this resource depends on.

This assembles dependencies on resources across stacks (including nested stacks) automatically.


obtainResourceDependencies()

public obtainResourceDependencies(): CfnResource[]

Returns

  • CfnResource[]

Get a shallow copy of dependencies between this resource and other resources in the same stack.


overrideLogicalId(newLogicalId)

public overrideLogicalId(newLogicalId: string): void

Parameters

  • newLogicalId string — The new logical ID to use for this stack element.

Overrides the auto-generated logical ID with a specific ID.


removeDependency(target)

public removeDependency(target: CfnResource): void

Parameters

  • 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, newTarget)

public replaceDependency(target: CfnResource, newTarget: CfnResource): void

Parameters

  • target CfnResource — The dependency to replace.
  • newTarget CfnResource — The new dependency to add.

Replaces one dependency with another.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


protected renderProperties(props)

protected renderProperties(props: { [string]: any }): { [string]: any }

Parameters

  • props { [string]: any }

Returns

  • { [string]: any }