This project contains example code for my talk "Deep dive on CDK: Tradeoffs when developing constructs & libraries" on AWS Community Day Germany 2023.
The slides will be added after the talk.
Create a private / internal S3 Bucket with all required settings to be compliant The defaults can not be overriden out of the boy by a user in this example.
import { CustomBucket } from 'cdk-lib-examples'
new CustomBucket(scope: Construct, id: string, props?: CustomBucketProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
CustomBucketProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: CustomBucketProps
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
public toString(): stringReturns a string representation of this construct.
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
import { CustomBucket } from 'cdk-lib-examples'
CustomBucket.isConstruct(x: any)Checks if x is a construct.
- Type: any
Any object.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
bucket |
aws-cdk-lib.aws_s3.Bucket |
No description. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly bucket: Bucket;- Type: aws-cdk-lib.aws_s3.Bucket
Create a private / internal S3 Bucket with all required settings to be compliant The defaults can not be overriden out of the boy by a user in this example.
import { CustomBucketHidden } from 'cdk-lib-examples'
new CustomBucketHidden(scope: Construct, id: string, props?: CustomBucketPropsHidden)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
CustomBucketPropsHidden |
No description. |
- Type: constructs.Construct
- Type: string
- Type: CustomBucketPropsHidden
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
public toString(): stringReturns a string representation of this construct.
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
import { CustomBucketHidden } from 'cdk-lib-examples'
CustomBucketHidden.isConstruct(x: any)Checks if x is a construct.
- Type: any
Any object.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
bucket |
aws-cdk-lib.aws_s3.Bucket |
No description. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly bucket: Bucket;- Type: aws-cdk-lib.aws_s3.Bucket
Create a private / internal S3 Bucket with all required settings to be compliant The defaults can not be overriden out of the boy by a user in this example.
import { CustomBucketSeparated } from 'cdk-lib-examples'
new CustomBucketSeparated(scope: Construct, id: string, props?: CustomBucketPropsSeparated)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
CustomBucketPropsSeparated |
No description. |
- Type: constructs.Construct
- Type: string
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
public toString(): stringReturns a string representation of this construct.
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
import { CustomBucketSeparated } from 'cdk-lib-examples'
CustomBucketSeparated.isConstruct(x: any)Checks if x is a construct.
- Type: any
Any object.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
bucket |
aws-cdk-lib.aws_s3.Bucket |
No description. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly bucket: Bucket;- Type: aws-cdk-lib.aws_s3.Bucket
Example Custom Stack with custom naming Problems: Name pattern can never be changed, unless cached / stored somewhere.
import { CustomStack } from 'cdk-lib-examples'
new CustomStack(scope: Construct, id: string, props?: CustomStackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
CustomStackProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: CustomStackProps
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
addDependency |
Add a dependency between this stack and another stack. |
addMetadata |
Adds an arbitary key-value pair, with information you want to record about the stack. |
addTransform |
Add a Transform to this stack. A Transform is a macro that AWS CloudFormation uses to process your template. |
exportStringListValue |
Create a CloudFormation Export for a string list value. |
exportValue |
Create a CloudFormation Export for a string value. |
formatArn |
Creates an ARN from components. |
getLogicalId |
Allocates a stack-unique CloudFormation-compatible logical identity for a specific resource. |
regionalFact |
Look up a fact value for the given fact for the region of this stack. |
renameLogicalId |
Rename a generated logical identities. |
reportMissingContextKey |
Indicate that a context key was expected. |
resolve |
Resolve a tokenized value in the context of the current stack. |
splitArn |
Splits the provided ARN into its components. |
toJsonString |
Convert an object, potentially containing tokens, to a JSON string. |
toYamlString |
Convert an object, potentially containing tokens, to a YAML string. |
public toString(): stringReturns a string representation of this construct.
public addDependency(target: Stack, reason?: string): voidAdd a dependency between this stack and another stack.
This can be used to define dependencies between any two stacks within an app, and also supports nested stacks.
- Type: aws-cdk-lib.Stack
- Type: string
public addMetadata(key: string, value: any): voidAdds an arbitary key-value pair, with information you want to record about the stack.
These get translated to the Metadata section of the generated template.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
- Type: string
- Type: any
public addTransform(transform: string): voidAdd a Transform to this stack. A Transform is a macro that AWS CloudFormation uses to process your template.
Duplicate values are removed when stack is synthesized.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
Example
declare const stack: Stack;
stack.addTransform('AWS::Serverless-2016-10-31')- Type: string
The transform to add.
public exportStringListValue(exportedValue: any, options?: ExportValueOptions): string[]Create a CloudFormation Export for a string list value.
Returns a string list representing the corresponding Fn.importValue()
expression for this Export. The export expression is automatically wrapped with an
Fn::Join and the import value with an Fn::Split, since CloudFormation can only
export strings. You can control the name for the export by passing the name option.
If you don't supply a value for name, the value you're exporting must be
a Resource attribute (for example: bucket.bucketName) and it will be
given the same name as the automatic cross-stack reference that would be created
if you used the attribute in another Stack.
One of the uses for this method is to remove the relationship between two Stacks established by automatic cross-stack references. It will temporarily ensure that the CloudFormation Export still exists while you remove the reference from the consuming stack. After that, you can remove the resource and the manual export.
See exportValue for an example of this process.
- Type: any
- Type: aws-cdk-lib.ExportValueOptions
public exportValue(exportedValue: any, options?: ExportValueOptions): stringCreate a CloudFormation Export for a string value.
Returns a string representing the corresponding Fn.importValue()
expression for this Export. You can control the name for the export by
passing the name option.
If you don't supply a value for name, the value you're exporting must be
a Resource attribute (for example: bucket.bucketName) and it will be
given the same name as the automatic cross-stack reference that would be created
if you used the attribute in another Stack.
One of the uses for this method is to remove the relationship between two Stacks established by automatic cross-stack references. It will temporarily ensure that the CloudFormation Export still exists while you remove the reference from the consuming stack. After that, you can remove the resource and the manual export.
Here is how the process works. Let's say there are two stacks,
producerStack and consumerStack, and producerStack has a bucket
called bucket, which is referenced by consumerStack (perhaps because
an AWS Lambda Function writes into it, or something like that).
It is not safe to remove producerStack.bucket because as the bucket is being
deleted, consumerStack might still be using it.
Instead, the process takes two deployments:
- Make sure
consumerStackno longer referencesbucket.bucketName(maybe the consumer stack now uses its own bucket, or it writes to an AWS DynamoDB table, or maybe you just remove the Lambda Function altogether). - In the
ProducerStackclass, callthis.exportValue(this.bucket.bucketName). This will make sure the CloudFormation Export continues to exist while the relationship between the two stacks is being broken. - Deploy (this will effectively only change the
consumerStack, but it's safe to deploy both).
- You are now free to remove the
bucketresource fromproducerStack. - Don't forget to remove the
exportValue()call as well. - Deploy again (this time only the
producerStackwill be changed -- the bucket will be deleted).
- Type: any
- Type: aws-cdk-lib.ExportValueOptions
public formatArn(components: ArnComponents): stringCreates an ARN from components.
If partition, region or account are not specified, the stack's
partition, region and account will be used.
If any component is the empty string, an empty string will be inserted into the generated ARN at the location that component corresponds to.
The ARN will be formatted as follows:
arn:{partition}:{service}:{region}:{account}:{resource}{sep}{resource-name}
The required ARN pieces that are omitted will be taken from the stack that the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope can be 'undefined'.
- Type: aws-cdk-lib.ArnComponents
public getLogicalId(element: CfnElement): stringAllocates a stack-unique CloudFormation-compatible logical identity for a specific resource.
This method is called when a CfnElement is created and used to render the
initial logical identity of resources. Logical ID renames are applied at
this stage.
This method uses the protected method allocateLogicalId to render the
logical ID for an element. To modify the naming scheme, extend the Stack
class and override this method.
- Type: aws-cdk-lib.CfnElement
The CloudFormation element for which a logical identity is needed.
public regionalFact(factName: string, defaultValue?: string): stringLook up a fact value for the given fact for the region of this stack.
Will return a definite value only if the region of the current stack is resolved. If not, a lookup map will be added to the stack and the lookup will be done at CDK deployment time.
What regions will be included in the lookup map is controlled by the
@aws-cdk/core:target-partitions context value: it must be set to a list
of partitions, and only regions from the given partitions will be included.
If no such context key is set, all regions will be included.
This function is intended to be used by construct library authors. Application builders can rely on the abstractions offered by construct libraries and do not have to worry about regional facts.
If defaultValue is not given, it is an error if the fact is unknown for
the given region.
- Type: string
- Type: string
public renameLogicalId(oldId: string, newId: string): voidRename a generated logical identities.
To modify the naming scheme strategy, extend the Stack class and
override the allocateLogicalId method.
- Type: string
- Type: string
public reportMissingContextKey(report: MissingContext): voidIndicate that a context key was expected.
Contains instructions which will be emitted into the cloud assembly on how the key should be supplied.
- Type: aws-cdk-lib.cloud_assembly_schema.MissingContext
The set of parameters needed to obtain the context.
public resolve(obj: any): anyResolve a tokenized value in the context of the current stack.
- Type: any
public splitArn(arn: string, arnFormat: ArnFormat): ArnComponentsSplits the provided ARN into its components.
Works both if 'arn' is a string like 'arn:aws:s3:::bucket', and a Token representing a dynamic CloudFormation expression (in which case the returned components will also be dynamic CloudFormation expressions, encoded as Tokens).
- Type: string
the ARN to split into its components.
- Type: aws-cdk-lib.ArnFormat
the expected format of 'arn' - depends on what format the service 'arn' represents uses.
public toJsonString(obj: any, space?: number): stringConvert an object, potentially containing tokens, to a JSON string.
- Type: any
- Type: number
public toYamlString(obj: any): stringConvert an object, potentially containing tokens, to a YAML string.
- Type: any
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
isStack |
Return whether the given object is a Stack. |
of |
Looks up the first stack scope in which construct is defined. |
import { CustomStack } from 'cdk-lib-examples'
CustomStack.isConstruct(x: any)Checks if x is a construct.
- Type: any
Any object.
import { CustomStack } from 'cdk-lib-examples'
CustomStack.isStack(x: any)Return whether the given object is a Stack.
We do attribute detection since we can't reliably use 'instanceof'.
- Type: any
import { CustomStack } from 'cdk-lib-examples'
CustomStack.of(construct: IConstruct)Looks up the first stack scope in which construct is defined.
Fails if there is no stack up the tree.
- Type: constructs.IConstruct
The construct to start the search from.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
account |
string |
The AWS account into which this stack will be deployed. |
artifactId |
string |
The ID of the cloud assembly artifact for this stack. |
availabilityZones |
string[] |
Returns the list of AZs that are available in the AWS environment (account/region) associated with this stack. |
bundlingRequired |
boolean |
Indicates whether the stack requires bundling or not. |
dependencies |
aws-cdk-lib.Stack[] |
Return the stacks this stack depends on. |
environment |
string |
The environment coordinates in which this stack is deployed. |
nested |
boolean |
Indicates if this is a nested stack, in which case parentStack will include a reference to it's parent. |
notificationArns |
string[] |
Returns the list of notification Amazon Resource Names (ARNs) for the current stack. |
partition |
string |
The partition in which this stack is defined. |
region |
string |
The AWS region into which this stack will be deployed (e.g. us-west-2). |
stackId |
string |
The ID of the stack. |
stackName |
string |
The concrete CloudFormation physical stack name. |
synthesizer |
aws-cdk-lib.IStackSynthesizer |
Synthesis method for this stack. |
tags |
aws-cdk-lib.TagManager |
Tags to be applied to the stack. |
templateFile |
string |
The name of the CloudFormation template file emitted to the output directory during synthesis. |
templateOptions |
aws-cdk-lib.ITemplateOptions |
Options for CloudFormation template (like version, transform, description). |
urlSuffix |
string |
The Amazon domain suffix for the region in which this stack is defined. |
nestedStackParent |
aws-cdk-lib.Stack |
If this is a nested stack, returns it's parent stack. |
nestedStackResource |
aws-cdk-lib.CfnResource |
If this is a nested stack, this represents its AWS::CloudFormation::Stack resource. |
terminationProtection |
boolean |
Whether termination protection is enabled for this stack. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly account: string;- Type: string
The AWS account into which this stack will be deployed.
This value is resolved according to the following rules:
- The value provided to
env.accountwhen the stack is defined. This can either be a concrete account (e.g.585695031111) or theAws.ACCOUNT_IDtoken. Aws.ACCOUNT_ID, which represents the CloudFormation intrinsic reference{ "Ref": "AWS::AccountId" }encoded as a string token.
Preferably, you should use the return value as an opaque string and not
attempt to parse it to implement your logic. If you do, you must first
check that it is a concrete value an not an unresolved token. If this
value is an unresolved token (Token.isUnresolved(stack.account) returns
true), this implies that the user wishes that this stack will synthesize
into a account-agnostic template. In this case, your code should either
fail (throw an error, emit a synth error using Annotations.of(construct).addError()) or
implement some other region-agnostic behavior.
public readonly artifactId: string;- Type: string
The ID of the cloud assembly artifact for this stack.
public readonly availabilityZones: string[];- Type: string[]
Returns the list of AZs that are available in the AWS environment (account/region) associated with this stack.
If the stack is environment-agnostic (either account and/or region are
tokens), this property will return an array with 2 tokens that will resolve
at deploy-time to the first two availability zones returned from CloudFormation's
Fn::GetAZs intrinsic function.
If they are not available in the context, returns a set of dummy values and
reports them as missing, and let the CLI resolve them by calling EC2
DescribeAvailabilityZones on the target environment.
To specify a different strategy for selecting availability zones override this method.
public readonly bundlingRequired: boolean;- Type: boolean
Indicates whether the stack requires bundling or not.
public readonly dependencies: Stack[];- Type: aws-cdk-lib.Stack[]
Return the stacks this stack depends on.
public readonly environment: string;- Type: string
The environment coordinates in which this stack is deployed.
In the form
aws://account/region. Use stack.account and stack.region to obtain
the specific values, no need to parse.
You can use this value to determine if two stacks are targeting the same environment.
If either stack.account or stack.region are not concrete values (e.g.
Aws.ACCOUNT_ID or Aws.REGION) the special strings unknown-account and/or
unknown-region will be used respectively to indicate this stack is
region/account-agnostic.
public readonly nested: boolean;- Type: boolean
Indicates if this is a nested stack, in which case parentStack will include a reference to it's parent.
public readonly notificationArns: string[];- Type: string[]
Returns the list of notification Amazon Resource Names (ARNs) for the current stack.
public readonly partition: string;- Type: string
The partition in which this stack is defined.
public readonly region: string;- Type: string
The AWS region into which this stack will be deployed (e.g. us-west-2).
This value is resolved according to the following rules:
- The value provided to
env.regionwhen the stack is defined. This can either be a concrete region (e.g.us-west-2) or theAws.REGIONtoken. Aws.REGION, which is represents the CloudFormation intrinsic reference{ "Ref": "AWS::Region" }encoded as a string token.
Preferably, you should use the return value as an opaque string and not
attempt to parse it to implement your logic. If you do, you must first
check that it is a concrete value an not an unresolved token. If this
value is an unresolved token (Token.isUnresolved(stack.region) returns
true), this implies that the user wishes that this stack will synthesize
into a region-agnostic template. In this case, your code should either
fail (throw an error, emit a synth error using Annotations.of(construct).addError()) or
implement some other region-agnostic behavior.
public readonly stackId: string;- Type: string
The ID of the stack.
Example
// After resolving, looks like
'arn:aws:cloudformation:us-west-2:123456789012:stack/teststack/51af3dc0-da77-11e4-872e-1234567db123'public readonly stackName: string;- Type: string
The concrete CloudFormation physical stack name.
This is either the name defined explicitly in the stackName prop or
allocated based on the stack's location in the construct tree. Stacks that
are directly defined under the app use their construct id as their stack
name. Stacks that are defined deeper within the tree will use a hashed naming
scheme based on the construct path to ensure uniqueness.
If you wish to obtain the deploy-time AWS::StackName intrinsic,
you can use Aws.STACK_NAME directly.
public readonly synthesizer: IStackSynthesizer;- Type: aws-cdk-lib.IStackSynthesizer
Synthesis method for this stack.
public readonly tags: TagManager;- Type: aws-cdk-lib.TagManager
Tags to be applied to the stack.
public readonly templateFile: string;- Type: string
The name of the CloudFormation template file emitted to the output directory during synthesis.
Example value: MyStack.template.json
public readonly templateOptions: ITemplateOptions;- Type: aws-cdk-lib.ITemplateOptions
Options for CloudFormation template (like version, transform, description).
public readonly urlSuffix: string;- Type: string
The Amazon domain suffix for the region in which this stack is defined.
public readonly nestedStackParent: Stack;- Type: aws-cdk-lib.Stack
If this is a nested stack, returns it's parent stack.
public readonly nestedStackResource: CfnResource;- Type: aws-cdk-lib.CfnResource
If this is a nested stack, this represents its AWS::CloudFormation::Stack resource.
undefined for top-level (non-nested) stacks.
public readonly terminationProtection: boolean;- Type: boolean
Whether termination protection is enabled for this stack.
Will create a custom helper function to help lower casing strings within the template.
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
public toString(): stringReturns a string representation of this construct.
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
lower |
will return a lower cased string for the given input. |
import { LowerCaseHelper } from 'cdk-lib-examples'
LowerCaseHelper.isConstruct(x: any)Checks if x is a construct.
- Type: any
Any object.
import { LowerCaseHelper } from 'cdk-lib-examples'
LowerCaseHelper.lower(scope: Construct, id: string, inputString: string)will return a lower cased string for the given input.
- Type: constructs.Construct
- Type: string
- Type: string
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
lowerCaseProvider |
aws-cdk-lib.custom_resources.Provider |
No description. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly lowerCaseProvider: Provider;- Type: aws-cdk-lib.custom_resources.Provider
One way to add the Aspect to your setup and reach everything else in it.
Depending on your expectactions this should be set to another scope (eg construct or even App)
import { S3Checks } from 'cdk-lib-examples'
new S3Checks(scope: Construct, id: string)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
- Type: constructs.Construct
- Type: string
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
public toString(): stringReturns a string representation of this construct.
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
import { S3Checks } from 'cdk-lib-examples'
S3Checks.isConstruct(x: any)Checks if x is a construct.
- Type: any
Any object.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
public readonly node: Node;- Type: constructs.Node
The tree node.
Stack that has additional features, can be nice, but tricky.
import { SmartStack } from 'cdk-lib-examples'
new SmartStack(scope: Construct, id: string, props: SmartStackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
SmartStackProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: SmartStackProps
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
addDependency |
Add a dependency between this stack and another stack. |
addMetadata |
Adds an arbitary key-value pair, with information you want to record about the stack. |
addTransform |
Add a Transform to this stack. A Transform is a macro that AWS CloudFormation uses to process your template. |
exportStringListValue |
Create a CloudFormation Export for a string list value. |
exportValue |
Create a CloudFormation Export for a string value. |
formatArn |
Creates an ARN from components. |
getLogicalId |
Allocates a stack-unique CloudFormation-compatible logical identity for a specific resource. |
regionalFact |
Look up a fact value for the given fact for the region of this stack. |
renameLogicalId |
Rename a generated logical identities. |
reportMissingContextKey |
Indicate that a context key was expected. |
resolve |
Resolve a tokenized value in the context of the current stack. |
splitArn |
Splits the provided ARN into its components. |
toJsonString |
Convert an object, potentially containing tokens, to a JSON string. |
toYamlString |
Convert an object, potentially containing tokens, to a YAML string. |
coolFunction |
No description. |
public toString(): stringReturns a string representation of this construct.
public addDependency(target: Stack, reason?: string): voidAdd a dependency between this stack and another stack.
This can be used to define dependencies between any two stacks within an app, and also supports nested stacks.
- Type: aws-cdk-lib.Stack
- Type: string
public addMetadata(key: string, value: any): voidAdds an arbitary key-value pair, with information you want to record about the stack.
These get translated to the Metadata section of the generated template.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
- Type: string
- Type: any
public addTransform(transform: string): voidAdd a Transform to this stack. A Transform is a macro that AWS CloudFormation uses to process your template.
Duplicate values are removed when stack is synthesized.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
Example
declare const stack: Stack;
stack.addTransform('AWS::Serverless-2016-10-31')- Type: string
The transform to add.
public exportStringListValue(exportedValue: any, options?: ExportValueOptions): string[]Create a CloudFormation Export for a string list value.
Returns a string list representing the corresponding Fn.importValue()
expression for this Export. The export expression is automatically wrapped with an
Fn::Join and the import value with an Fn::Split, since CloudFormation can only
export strings. You can control the name for the export by passing the name option.
If you don't supply a value for name, the value you're exporting must be
a Resource attribute (for example: bucket.bucketName) and it will be
given the same name as the automatic cross-stack reference that would be created
if you used the attribute in another Stack.
One of the uses for this method is to remove the relationship between two Stacks established by automatic cross-stack references. It will temporarily ensure that the CloudFormation Export still exists while you remove the reference from the consuming stack. After that, you can remove the resource and the manual export.
See exportValue for an example of this process.
- Type: any
- Type: aws-cdk-lib.ExportValueOptions
public exportValue(exportedValue: any, options?: ExportValueOptions): stringCreate a CloudFormation Export for a string value.
Returns a string representing the corresponding Fn.importValue()
expression for this Export. You can control the name for the export by
passing the name option.
If you don't supply a value for name, the value you're exporting must be
a Resource attribute (for example: bucket.bucketName) and it will be
given the same name as the automatic cross-stack reference that would be created
if you used the attribute in another Stack.
One of the uses for this method is to remove the relationship between two Stacks established by automatic cross-stack references. It will temporarily ensure that the CloudFormation Export still exists while you remove the reference from the consuming stack. After that, you can remove the resource and the manual export.
Here is how the process works. Let's say there are two stacks,
producerStack and consumerStack, and producerStack has a bucket
called bucket, which is referenced by consumerStack (perhaps because
an AWS Lambda Function writes into it, or something like that).
It is not safe to remove producerStack.bucket because as the bucket is being
deleted, consumerStack might still be using it.
Instead, the process takes two deployments:
- Make sure
consumerStackno longer referencesbucket.bucketName(maybe the consumer stack now uses its own bucket, or it writes to an AWS DynamoDB table, or maybe you just remove the Lambda Function altogether). - In the
ProducerStackclass, callthis.exportValue(this.bucket.bucketName). This will make sure the CloudFormation Export continues to exist while the relationship between the two stacks is being broken. - Deploy (this will effectively only change the
consumerStack, but it's safe to deploy both).
- You are now free to remove the
bucketresource fromproducerStack. - Don't forget to remove the
exportValue()call as well. - Deploy again (this time only the
producerStackwill be changed -- the bucket will be deleted).
- Type: any
- Type: aws-cdk-lib.ExportValueOptions
public formatArn(components: ArnComponents): stringCreates an ARN from components.
If partition, region or account are not specified, the stack's
partition, region and account will be used.
If any component is the empty string, an empty string will be inserted into the generated ARN at the location that component corresponds to.
The ARN will be formatted as follows:
arn:{partition}:{service}:{region}:{account}:{resource}{sep}{resource-name}
The required ARN pieces that are omitted will be taken from the stack that the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope can be 'undefined'.
- Type: aws-cdk-lib.ArnComponents
public getLogicalId(element: CfnElement): stringAllocates a stack-unique CloudFormation-compatible logical identity for a specific resource.
This method is called when a CfnElement is created and used to render the
initial logical identity of resources. Logical ID renames are applied at
this stage.
This method uses the protected method allocateLogicalId to render the
logical ID for an element. To modify the naming scheme, extend the Stack
class and override this method.
- Type: aws-cdk-lib.CfnElement
The CloudFormation element for which a logical identity is needed.
public regionalFact(factName: string, defaultValue?: string): stringLook up a fact value for the given fact for the region of this stack.
Will return a definite value only if the region of the current stack is resolved. If not, a lookup map will be added to the stack and the lookup will be done at CDK deployment time.
What regions will be included in the lookup map is controlled by the
@aws-cdk/core:target-partitions context value: it must be set to a list
of partitions, and only regions from the given partitions will be included.
If no such context key is set, all regions will be included.
This function is intended to be used by construct library authors. Application builders can rely on the abstractions offered by construct libraries and do not have to worry about regional facts.
If defaultValue is not given, it is an error if the fact is unknown for
the given region.
- Type: string
- Type: string
public renameLogicalId(oldId: string, newId: string): voidRename a generated logical identities.
To modify the naming scheme strategy, extend the Stack class and
override the allocateLogicalId method.
- Type: string
- Type: string
public reportMissingContextKey(report: MissingContext): voidIndicate that a context key was expected.
Contains instructions which will be emitted into the cloud assembly on how the key should be supplied.
- Type: aws-cdk-lib.cloud_assembly_schema.MissingContext
The set of parameters needed to obtain the context.
public resolve(obj: any): anyResolve a tokenized value in the context of the current stack.
- Type: any
public splitArn(arn: string, arnFormat: ArnFormat): ArnComponentsSplits the provided ARN into its components.
Works both if 'arn' is a string like 'arn:aws:s3:::bucket', and a Token representing a dynamic CloudFormation expression (in which case the returned components will also be dynamic CloudFormation expressions, encoded as Tokens).
- Type: string
the ARN to split into its components.
- Type: aws-cdk-lib.ArnFormat
the expected format of 'arn' - depends on what format the service 'arn' represents uses.
public toJsonString(obj: any, space?: number): stringConvert an object, potentially containing tokens, to a JSON string.
- Type: any
- Type: number
public toYamlString(obj: any): stringConvert an object, potentially containing tokens, to a YAML string.
- Type: any
public coolFunction(): string| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
isStack |
Return whether the given object is a Stack. |
of |
Looks up the first stack scope in which construct is defined. |
import { SmartStack } from 'cdk-lib-examples'
SmartStack.isConstruct(x: any)Checks if x is a construct.
- Type: any
Any object.
import { SmartStack } from 'cdk-lib-examples'
SmartStack.isStack(x: any)Return whether the given object is a Stack.
We do attribute detection since we can't reliably use 'instanceof'.
- Type: any
import { SmartStack } from 'cdk-lib-examples'
SmartStack.of(construct: IConstruct)Looks up the first stack scope in which construct is defined.
Fails if there is no stack up the tree.
- Type: constructs.IConstruct
The construct to start the search from.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
account |
string |
The AWS account into which this stack will be deployed. |
artifactId |
string |
The ID of the cloud assembly artifact for this stack. |
availabilityZones |
string[] |
Returns the list of AZs that are available in the AWS environment (account/region) associated with this stack. |
bundlingRequired |
boolean |
Indicates whether the stack requires bundling or not. |
dependencies |
aws-cdk-lib.Stack[] |
Return the stacks this stack depends on. |
environment |
string |
The environment coordinates in which this stack is deployed. |
nested |
boolean |
Indicates if this is a nested stack, in which case parentStack will include a reference to it's parent. |
notificationArns |
string[] |
Returns the list of notification Amazon Resource Names (ARNs) for the current stack. |
partition |
string |
The partition in which this stack is defined. |
region |
string |
The AWS region into which this stack will be deployed (e.g. us-west-2). |
stackId |
string |
The ID of the stack. |
stackName |
string |
The concrete CloudFormation physical stack name. |
synthesizer |
aws-cdk-lib.IStackSynthesizer |
Synthesis method for this stack. |
tags |
aws-cdk-lib.TagManager |
Tags to be applied to the stack. |
templateFile |
string |
The name of the CloudFormation template file emitted to the output directory during synthesis. |
templateOptions |
aws-cdk-lib.ITemplateOptions |
Options for CloudFormation template (like version, transform, description). |
urlSuffix |
string |
The Amazon domain suffix for the region in which this stack is defined. |
nestedStackParent |
aws-cdk-lib.Stack |
If this is a nested stack, returns it's parent stack. |
nestedStackResource |
aws-cdk-lib.CfnResource |
If this is a nested stack, this represents its AWS::CloudFormation::Stack resource. |
terminationProtection |
boolean |
Whether termination protection is enabled for this stack. |
teamName |
string |
No description. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly account: string;- Type: string
The AWS account into which this stack will be deployed.
This value is resolved according to the following rules:
- The value provided to
env.accountwhen the stack is defined. This can either be a concrete account (e.g.585695031111) or theAws.ACCOUNT_IDtoken. Aws.ACCOUNT_ID, which represents the CloudFormation intrinsic reference{ "Ref": "AWS::AccountId" }encoded as a string token.
Preferably, you should use the return value as an opaque string and not
attempt to parse it to implement your logic. If you do, you must first
check that it is a concrete value an not an unresolved token. If this
value is an unresolved token (Token.isUnresolved(stack.account) returns
true), this implies that the user wishes that this stack will synthesize
into a account-agnostic template. In this case, your code should either
fail (throw an error, emit a synth error using Annotations.of(construct).addError()) or
implement some other region-agnostic behavior.
public readonly artifactId: string;- Type: string
The ID of the cloud assembly artifact for this stack.
public readonly availabilityZones: string[];- Type: string[]
Returns the list of AZs that are available in the AWS environment (account/region) associated with this stack.
If the stack is environment-agnostic (either account and/or region are
tokens), this property will return an array with 2 tokens that will resolve
at deploy-time to the first two availability zones returned from CloudFormation's
Fn::GetAZs intrinsic function.
If they are not available in the context, returns a set of dummy values and
reports them as missing, and let the CLI resolve them by calling EC2
DescribeAvailabilityZones on the target environment.
To specify a different strategy for selecting availability zones override this method.
public readonly bundlingRequired: boolean;- Type: boolean
Indicates whether the stack requires bundling or not.
public readonly dependencies: Stack[];- Type: aws-cdk-lib.Stack[]
Return the stacks this stack depends on.
public readonly environment: string;- Type: string
The environment coordinates in which this stack is deployed.
In the form
aws://account/region. Use stack.account and stack.region to obtain
the specific values, no need to parse.
You can use this value to determine if two stacks are targeting the same environment.
If either stack.account or stack.region are not concrete values (e.g.
Aws.ACCOUNT_ID or Aws.REGION) the special strings unknown-account and/or
unknown-region will be used respectively to indicate this stack is
region/account-agnostic.
public readonly nested: boolean;- Type: boolean
Indicates if this is a nested stack, in which case parentStack will include a reference to it's parent.
public readonly notificationArns: string[];- Type: string[]
Returns the list of notification Amazon Resource Names (ARNs) for the current stack.
public readonly partition: string;- Type: string
The partition in which this stack is defined.
public readonly region: string;- Type: string
The AWS region into which this stack will be deployed (e.g. us-west-2).
This value is resolved according to the following rules:
- The value provided to
env.regionwhen the stack is defined. This can either be a concrete region (e.g.us-west-2) or theAws.REGIONtoken. Aws.REGION, which is represents the CloudFormation intrinsic reference{ "Ref": "AWS::Region" }encoded as a string token.
Preferably, you should use the return value as an opaque string and not
attempt to parse it to implement your logic. If you do, you must first
check that it is a concrete value an not an unresolved token. If this
value is an unresolved token (Token.isUnresolved(stack.region) returns
true), this implies that the user wishes that this stack will synthesize
into a region-agnostic template. In this case, your code should either
fail (throw an error, emit a synth error using Annotations.of(construct).addError()) or
implement some other region-agnostic behavior.
public readonly stackId: string;- Type: string
The ID of the stack.
Example
// After resolving, looks like
'arn:aws:cloudformation:us-west-2:123456789012:stack/teststack/51af3dc0-da77-11e4-872e-1234567db123'public readonly stackName: string;- Type: string
The concrete CloudFormation physical stack name.
This is either the name defined explicitly in the stackName prop or
allocated based on the stack's location in the construct tree. Stacks that
are directly defined under the app use their construct id as their stack
name. Stacks that are defined deeper within the tree will use a hashed naming
scheme based on the construct path to ensure uniqueness.
If you wish to obtain the deploy-time AWS::StackName intrinsic,
you can use Aws.STACK_NAME directly.
public readonly synthesizer: IStackSynthesizer;- Type: aws-cdk-lib.IStackSynthesizer
Synthesis method for this stack.
public readonly tags: TagManager;- Type: aws-cdk-lib.TagManager
Tags to be applied to the stack.
public readonly templateFile: string;- Type: string
The name of the CloudFormation template file emitted to the output directory during synthesis.
Example value: MyStack.template.json
public readonly templateOptions: ITemplateOptions;- Type: aws-cdk-lib.ITemplateOptions
Options for CloudFormation template (like version, transform, description).
public readonly urlSuffix: string;- Type: string
The Amazon domain suffix for the region in which this stack is defined.
public readonly nestedStackParent: Stack;- Type: aws-cdk-lib.Stack
If this is a nested stack, returns it's parent stack.
public readonly nestedStackResource: CfnResource;- Type: aws-cdk-lib.CfnResource
If this is a nested stack, this represents its AWS::CloudFormation::Stack resource.
undefined for top-level (non-nested) stacks.
public readonly terminationProtection: boolean;- Type: boolean
Whether termination protection is enabled for this stack.
public readonly teamName: string;- Type: string
Stack that has additional features, can be nice, but tricky.
import { SmartStackIdentfieable } from 'cdk-lib-examples'
new SmartStackIdentfieable(scope: Construct, id: string, props: SmartStackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
SmartStackProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: SmartStackProps
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
addDependency |
Add a dependency between this stack and another stack. |
addMetadata |
Adds an arbitary key-value pair, with information you want to record about the stack. |
addTransform |
Add a Transform to this stack. A Transform is a macro that AWS CloudFormation uses to process your template. |
exportStringListValue |
Create a CloudFormation Export for a string list value. |
exportValue |
Create a CloudFormation Export for a string value. |
formatArn |
Creates an ARN from components. |
getLogicalId |
Allocates a stack-unique CloudFormation-compatible logical identity for a specific resource. |
regionalFact |
Look up a fact value for the given fact for the region of this stack. |
renameLogicalId |
Rename a generated logical identities. |
reportMissingContextKey |
Indicate that a context key was expected. |
resolve |
Resolve a tokenized value in the context of the current stack. |
splitArn |
Splits the provided ARN into its components. |
toJsonString |
Convert an object, potentially containing tokens, to a JSON string. |
toYamlString |
Convert an object, potentially containing tokens, to a YAML string. |
coolFunction |
No description. |
public toString(): stringReturns a string representation of this construct.
public addDependency(target: Stack, reason?: string): voidAdd a dependency between this stack and another stack.
This can be used to define dependencies between any two stacks within an app, and also supports nested stacks.
- Type: aws-cdk-lib.Stack
- Type: string
public addMetadata(key: string, value: any): voidAdds an arbitary key-value pair, with information you want to record about the stack.
These get translated to the Metadata section of the generated template.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
- Type: string
- Type: any
public addTransform(transform: string): voidAdd a Transform to this stack. A Transform is a macro that AWS CloudFormation uses to process your template.
Duplicate values are removed when stack is synthesized.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
Example
declare const stack: Stack;
stack.addTransform('AWS::Serverless-2016-10-31')- Type: string
The transform to add.
public exportStringListValue(exportedValue: any, options?: ExportValueOptions): string[]Create a CloudFormation Export for a string list value.
Returns a string list representing the corresponding Fn.importValue()
expression for this Export. The export expression is automatically wrapped with an
Fn::Join and the import value with an Fn::Split, since CloudFormation can only
export strings. You can control the name for the export by passing the name option.
If you don't supply a value for name, the value you're exporting must be
a Resource attribute (for example: bucket.bucketName) and it will be
given the same name as the automatic cross-stack reference that would be created
if you used the attribute in another Stack.
One of the uses for this method is to remove the relationship between two Stacks established by automatic cross-stack references. It will temporarily ensure that the CloudFormation Export still exists while you remove the reference from the consuming stack. After that, you can remove the resource and the manual export.
See exportValue for an example of this process.
- Type: any
- Type: aws-cdk-lib.ExportValueOptions
public exportValue(exportedValue: any, options?: ExportValueOptions): stringCreate a CloudFormation Export for a string value.
Returns a string representing the corresponding Fn.importValue()
expression for this Export. You can control the name for the export by
passing the name option.
If you don't supply a value for name, the value you're exporting must be
a Resource attribute (for example: bucket.bucketName) and it will be
given the same name as the automatic cross-stack reference that would be created
if you used the attribute in another Stack.
One of the uses for this method is to remove the relationship between two Stacks established by automatic cross-stack references. It will temporarily ensure that the CloudFormation Export still exists while you remove the reference from the consuming stack. After that, you can remove the resource and the manual export.
Here is how the process works. Let's say there are two stacks,
producerStack and consumerStack, and producerStack has a bucket
called bucket, which is referenced by consumerStack (perhaps because
an AWS Lambda Function writes into it, or something like that).
It is not safe to remove producerStack.bucket because as the bucket is being
deleted, consumerStack might still be using it.
Instead, the process takes two deployments:
- Make sure
consumerStackno longer referencesbucket.bucketName(maybe the consumer stack now uses its own bucket, or it writes to an AWS DynamoDB table, or maybe you just remove the Lambda Function altogether). - In the
ProducerStackclass, callthis.exportValue(this.bucket.bucketName). This will make sure the CloudFormation Export continues to exist while the relationship between the two stacks is being broken. - Deploy (this will effectively only change the
consumerStack, but it's safe to deploy both).
- You are now free to remove the
bucketresource fromproducerStack. - Don't forget to remove the
exportValue()call as well. - Deploy again (this time only the
producerStackwill be changed -- the bucket will be deleted).
- Type: any
- Type: aws-cdk-lib.ExportValueOptions
public formatArn(components: ArnComponents): stringCreates an ARN from components.
If partition, region or account are not specified, the stack's
partition, region and account will be used.
If any component is the empty string, an empty string will be inserted into the generated ARN at the location that component corresponds to.
The ARN will be formatted as follows:
arn:{partition}:{service}:{region}:{account}:{resource}{sep}{resource-name}
The required ARN pieces that are omitted will be taken from the stack that the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope can be 'undefined'.
- Type: aws-cdk-lib.ArnComponents
public getLogicalId(element: CfnElement): stringAllocates a stack-unique CloudFormation-compatible logical identity for a specific resource.
This method is called when a CfnElement is created and used to render the
initial logical identity of resources. Logical ID renames are applied at
this stage.
This method uses the protected method allocateLogicalId to render the
logical ID for an element. To modify the naming scheme, extend the Stack
class and override this method.
- Type: aws-cdk-lib.CfnElement
The CloudFormation element for which a logical identity is needed.
public regionalFact(factName: string, defaultValue?: string): stringLook up a fact value for the given fact for the region of this stack.
Will return a definite value only if the region of the current stack is resolved. If not, a lookup map will be added to the stack and the lookup will be done at CDK deployment time.
What regions will be included in the lookup map is controlled by the
@aws-cdk/core:target-partitions context value: it must be set to a list
of partitions, and only regions from the given partitions will be included.
If no such context key is set, all regions will be included.
This function is intended to be used by construct library authors. Application builders can rely on the abstractions offered by construct libraries and do not have to worry about regional facts.
If defaultValue is not given, it is an error if the fact is unknown for
the given region.
- Type: string
- Type: string
public renameLogicalId(oldId: string, newId: string): voidRename a generated logical identities.
To modify the naming scheme strategy, extend the Stack class and
override the allocateLogicalId method.
- Type: string
- Type: string
public reportMissingContextKey(report: MissingContext): voidIndicate that a context key was expected.
Contains instructions which will be emitted into the cloud assembly on how the key should be supplied.
- Type: aws-cdk-lib.cloud_assembly_schema.MissingContext
The set of parameters needed to obtain the context.
public resolve(obj: any): anyResolve a tokenized value in the context of the current stack.
- Type: any
public splitArn(arn: string, arnFormat: ArnFormat): ArnComponentsSplits the provided ARN into its components.
Works both if 'arn' is a string like 'arn:aws:s3:::bucket', and a Token representing a dynamic CloudFormation expression (in which case the returned components will also be dynamic CloudFormation expressions, encoded as Tokens).
- Type: string
the ARN to split into its components.
- Type: aws-cdk-lib.ArnFormat
the expected format of 'arn' - depends on what format the service 'arn' represents uses.
public toJsonString(obj: any, space?: number): stringConvert an object, potentially containing tokens, to a JSON string.
- Type: any
- Type: number
public toYamlString(obj: any): stringConvert an object, potentially containing tokens, to a YAML string.
- Type: any
public coolFunction(): string| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
isStack |
Return whether the given object is a Stack. |
of |
Looks up the first stack scope in which construct is defined. |
import { SmartStackIdentfieable } from 'cdk-lib-examples'
SmartStackIdentfieable.isConstruct(x: any)Checks if x is a construct.
- Type: any
Any object.
import { SmartStackIdentfieable } from 'cdk-lib-examples'
SmartStackIdentfieable.isStack(x: any)Return whether the given object is a Stack.
We do attribute detection since we can't reliably use 'instanceof'.
- Type: any
import { SmartStackIdentfieable } from 'cdk-lib-examples'
SmartStackIdentfieable.of(construct: IConstruct)Looks up the first stack scope in which construct is defined.
Fails if there is no stack up the tree.
- Type: constructs.IConstruct
The construct to start the search from.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
account |
string |
The AWS account into which this stack will be deployed. |
artifactId |
string |
The ID of the cloud assembly artifact for this stack. |
availabilityZones |
string[] |
Returns the list of AZs that are available in the AWS environment (account/region) associated with this stack. |
bundlingRequired |
boolean |
Indicates whether the stack requires bundling or not. |
dependencies |
aws-cdk-lib.Stack[] |
Return the stacks this stack depends on. |
environment |
string |
The environment coordinates in which this stack is deployed. |
nested |
boolean |
Indicates if this is a nested stack, in which case parentStack will include a reference to it's parent. |
notificationArns |
string[] |
Returns the list of notification Amazon Resource Names (ARNs) for the current stack. |
partition |
string |
The partition in which this stack is defined. |
region |
string |
The AWS region into which this stack will be deployed (e.g. us-west-2). |
stackId |
string |
The ID of the stack. |
stackName |
string |
The concrete CloudFormation physical stack name. |
synthesizer |
aws-cdk-lib.IStackSynthesizer |
Synthesis method for this stack. |
tags |
aws-cdk-lib.TagManager |
Tags to be applied to the stack. |
templateFile |
string |
The name of the CloudFormation template file emitted to the output directory during synthesis. |
templateOptions |
aws-cdk-lib.ITemplateOptions |
Options for CloudFormation template (like version, transform, description). |
urlSuffix |
string |
The Amazon domain suffix for the region in which this stack is defined. |
nestedStackParent |
aws-cdk-lib.Stack |
If this is a nested stack, returns it's parent stack. |
nestedStackResource |
aws-cdk-lib.CfnResource |
If this is a nested stack, this represents its AWS::CloudFormation::Stack resource. |
terminationProtection |
boolean |
Whether termination protection is enabled for this stack. |
smartStack |
string |
No description. |
teamName |
string |
No description. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly account: string;- Type: string
The AWS account into which this stack will be deployed.
This value is resolved according to the following rules:
- The value provided to
env.accountwhen the stack is defined. This can either be a concrete account (e.g.585695031111) or theAws.ACCOUNT_IDtoken. Aws.ACCOUNT_ID, which represents the CloudFormation intrinsic reference{ "Ref": "AWS::AccountId" }encoded as a string token.
Preferably, you should use the return value as an opaque string and not
attempt to parse it to implement your logic. If you do, you must first
check that it is a concrete value an not an unresolved token. If this
value is an unresolved token (Token.isUnresolved(stack.account) returns
true), this implies that the user wishes that this stack will synthesize
into a account-agnostic template. In this case, your code should either
fail (throw an error, emit a synth error using Annotations.of(construct).addError()) or
implement some other region-agnostic behavior.
public readonly artifactId: string;- Type: string
The ID of the cloud assembly artifact for this stack.
public readonly availabilityZones: string[];- Type: string[]
Returns the list of AZs that are available in the AWS environment (account/region) associated with this stack.
If the stack is environment-agnostic (either account and/or region are
tokens), this property will return an array with 2 tokens that will resolve
at deploy-time to the first two availability zones returned from CloudFormation's
Fn::GetAZs intrinsic function.
If they are not available in the context, returns a set of dummy values and
reports them as missing, and let the CLI resolve them by calling EC2
DescribeAvailabilityZones on the target environment.
To specify a different strategy for selecting availability zones override this method.
public readonly bundlingRequired: boolean;- Type: boolean
Indicates whether the stack requires bundling or not.
public readonly dependencies: Stack[];- Type: aws-cdk-lib.Stack[]
Return the stacks this stack depends on.
public readonly environment: string;- Type: string
The environment coordinates in which this stack is deployed.
In the form
aws://account/region. Use stack.account and stack.region to obtain
the specific values, no need to parse.
You can use this value to determine if two stacks are targeting the same environment.
If either stack.account or stack.region are not concrete values (e.g.
Aws.ACCOUNT_ID or Aws.REGION) the special strings unknown-account and/or
unknown-region will be used respectively to indicate this stack is
region/account-agnostic.
public readonly nested: boolean;- Type: boolean
Indicates if this is a nested stack, in which case parentStack will include a reference to it's parent.
public readonly notificationArns: string[];- Type: string[]
Returns the list of notification Amazon Resource Names (ARNs) for the current stack.
public readonly partition: string;- Type: string
The partition in which this stack is defined.
public readonly region: string;- Type: string
The AWS region into which this stack will be deployed (e.g. us-west-2).
This value is resolved according to the following rules:
- The value provided to
env.regionwhen the stack is defined. This can either be a concrete region (e.g.us-west-2) or theAws.REGIONtoken. Aws.REGION, which is represents the CloudFormation intrinsic reference{ "Ref": "AWS::Region" }encoded as a string token.
Preferably, you should use the return value as an opaque string and not
attempt to parse it to implement your logic. If you do, you must first
check that it is a concrete value an not an unresolved token. If this
value is an unresolved token (Token.isUnresolved(stack.region) returns
true), this implies that the user wishes that this stack will synthesize
into a region-agnostic template. In this case, your code should either
fail (throw an error, emit a synth error using Annotations.of(construct).addError()) or
implement some other region-agnostic behavior.
public readonly stackId: string;- Type: string
The ID of the stack.
Example
// After resolving, looks like
'arn:aws:cloudformation:us-west-2:123456789012:stack/teststack/51af3dc0-da77-11e4-872e-1234567db123'public readonly stackName: string;- Type: string
The concrete CloudFormation physical stack name.
This is either the name defined explicitly in the stackName prop or
allocated based on the stack's location in the construct tree. Stacks that
are directly defined under the app use their construct id as their stack
name. Stacks that are defined deeper within the tree will use a hashed naming
scheme based on the construct path to ensure uniqueness.
If you wish to obtain the deploy-time AWS::StackName intrinsic,
you can use Aws.STACK_NAME directly.
public readonly synthesizer: IStackSynthesizer;- Type: aws-cdk-lib.IStackSynthesizer
Synthesis method for this stack.
public readonly tags: TagManager;- Type: aws-cdk-lib.TagManager
Tags to be applied to the stack.
public readonly templateFile: string;- Type: string
The name of the CloudFormation template file emitted to the output directory during synthesis.
Example value: MyStack.template.json
public readonly templateOptions: ITemplateOptions;- Type: aws-cdk-lib.ITemplateOptions
Options for CloudFormation template (like version, transform, description).
public readonly urlSuffix: string;- Type: string
The Amazon domain suffix for the region in which this stack is defined.
public readonly nestedStackParent: Stack;- Type: aws-cdk-lib.Stack
If this is a nested stack, returns it's parent stack.
public readonly nestedStackResource: CfnResource;- Type: aws-cdk-lib.CfnResource
If this is a nested stack, this represents its AWS::CloudFormation::Stack resource.
undefined for top-level (non-nested) stacks.
public readonly terminationProtection: boolean;- Type: boolean
Whether termination protection is enabled for this stack.
public readonly smartStack: string;- Type: string
public readonly teamName: string;- Type: string
This extends the existing bucket properties with our own settings.
import { CustomBucketProps } from 'cdk-lib-examples'
const customBucketProps: CustomBucketProps = { ... }| Name | Type | Description |
|---|---|---|
accessControl |
aws-cdk-lib.aws_s3.BucketAccessControl |
Specifies a canned ACL that grants predefined permissions to the bucket. |
autoDeleteObjects |
boolean |
Whether all objects should be automatically deleted when the bucket is removed from the stack or when the stack is deleted. |
blockPublicAccess |
aws-cdk-lib.aws_s3.BlockPublicAccess |
The block public access configuration of this bucket. |
bucketKeyEnabled |
boolean |
Whether Amazon S3 should use its own intermediary key to generate data keys. |
bucketName |
string |
Physical name of this bucket. |
cors |
aws-cdk-lib.aws_s3.CorsRule[] |
The CORS configuration of this bucket. |
encryption |
aws-cdk-lib.aws_s3.BucketEncryption |
The kind of server-side encryption to apply to this bucket. |
encryptionKey |
aws-cdk-lib.aws_kms.IKey |
External KMS key to use for bucket encryption. |
enforceSSL |
boolean |
Enforces SSL for requests. |
eventBridgeEnabled |
boolean |
Whether this bucket should send notifications to Amazon EventBridge or not. |
intelligentTieringConfigurations |
aws-cdk-lib.aws_s3.IntelligentTieringConfiguration[] |
Inteligent Tiering Configurations. |
inventories |
aws-cdk-lib.aws_s3.Inventory[] |
The inventory configuration of the bucket. |
lifecycleRules |
aws-cdk-lib.aws_s3.LifecycleRule[] |
Rules that define how Amazon S3 manages objects during their lifetime. |
metrics |
aws-cdk-lib.aws_s3.BucketMetrics[] |
The metrics configuration of this bucket. |
notificationsHandlerRole |
aws-cdk-lib.aws_iam.IRole |
The role to be used by the notifications handler. |
objectLockDefaultRetention |
aws-cdk-lib.aws_s3.ObjectLockRetention |
The default retention mode and rules for S3 Object Lock. |
objectLockEnabled |
boolean |
Enable object lock on the bucket. |
objectOwnership |
aws-cdk-lib.aws_s3.ObjectOwnership |
The objectOwnership of the bucket. |
publicReadAccess |
boolean |
Grants public read access to all objects in the bucket. |
removalPolicy |
aws-cdk-lib.RemovalPolicy |
Policy to apply when the bucket is removed from this stack. |
serverAccessLogsBucket |
aws-cdk-lib.aws_s3.IBucket |
Destination bucket for the server access logs. |
serverAccessLogsPrefix |
string |
Optional log file prefix to use for the bucket's access logs. |
transferAcceleration |
boolean |
Whether this bucket should have transfer acceleration turned on or not. |
versioned |
boolean |
Whether this bucket should have versioning turned on or not. |
websiteErrorDocument |
string |
The name of the error document (e.g. "404.html") for the website. websiteIndexDocument must also be set if this is set. |
websiteIndexDocument |
string |
The name of the index document (e.g. "index.html") for the website. Enables static website hosting for this bucket. |
websiteRedirect |
aws-cdk-lib.aws_s3.RedirectTarget |
Specifies the redirect behavior of all requests to a website endpoint of a bucket. |
websiteRoutingRules |
aws-cdk-lib.aws_s3.RoutingRule[] |
Rules that define when a redirect is applied and the redirect behavior. |
dataAccessEnabled |
boolean |
Set to true if DataAccess can interact with the bucket. |
public readonly accessControl: BucketAccessControl;- Type: aws-cdk-lib.aws_s3.BucketAccessControl
- Default: BucketAccessControl.PRIVATE
Specifies a canned ACL that grants predefined permissions to the bucket.
public readonly autoDeleteObjects: boolean;- Type: boolean
- Default: false
Whether all objects should be automatically deleted when the bucket is removed from the stack or when the stack is deleted.
Requires the removalPolicy to be set to RemovalPolicy.DESTROY.
Warning if you have deployed a bucket with autoDeleteObjects: true,
switching this to false in a CDK version before 1.126.0 will lead to
all objects in the bucket being deleted. Be sure to update your bucket resources
by deploying with CDK version 1.126.0 or later before switching this value to false.
public readonly blockPublicAccess: BlockPublicAccess;- Type: aws-cdk-lib.aws_s3.BlockPublicAccess
- Default: CloudFormation defaults will apply. New buckets and objects don't allow public access, but users can modify bucket policies or object permissions to allow public access
The block public access configuration of this bucket.
https://docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html
public readonly bucketKeyEnabled: boolean;- Type: boolean
- Default: false
Whether Amazon S3 should use its own intermediary key to generate data keys.
Only relevant when using KMS for encryption.
- If not enabled, every object GET and PUT will cause an API call to KMS (with the attendant cost implications of that).
- If enabled, S3 will use its own time-limited key instead.
Only relevant, when Encryption is set to BucketEncryption.KMS or BucketEncryption.KMS_MANAGED.
public readonly bucketName: string;- Type: string
- Default: Assigned by CloudFormation (recommended).
Physical name of this bucket.
public readonly cors: CorsRule[];- Type: aws-cdk-lib.aws_s3.CorsRule[]
- Default: No CORS configuration.
The CORS configuration of this bucket.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-cors.html
public readonly encryption: BucketEncryption;- Type: aws-cdk-lib.aws_s3.BucketEncryption
- Default:
KMSifencryptionKeyis specified, orUNENCRYPTEDotherwise. But ifUNENCRYPTEDis specified, the bucket will be encrypted asS3_MANAGEDautomatically.
The kind of server-side encryption to apply to this bucket.
If you choose KMS, you can specify a KMS key via encryptionKey. If
encryption key is not specified, a key will automatically be created.
public readonly encryptionKey: IKey;- Type: aws-cdk-lib.aws_kms.IKey
- Default: If
encryptionis set toKMSand this property is undefined, a new KMS key will be created and associated with this bucket.
External KMS key to use for bucket encryption.
The encryption property must be either not specified or set to KMS or DSSE.
An error will be emitted if encryption is set to UNENCRYPTED or S3_MANAGED.
public readonly enforceSSL: boolean;- Type: boolean
- Default: false
Enforces SSL for requests.
S3.5 of the AWS Foundational Security Best Practices Regarding S3.
https://docs.aws.amazon.com/config/latest/developerguide/s3-bucket-ssl-requests-only.html
public readonly eventBridgeEnabled: boolean;- Type: boolean
- Default: false
Whether this bucket should send notifications to Amazon EventBridge or not.
public readonly intelligentTieringConfigurations: IntelligentTieringConfiguration[];- Type: aws-cdk-lib.aws_s3.IntelligentTieringConfiguration[]
- Default: No Intelligent Tiiering Configurations.
Inteligent Tiering Configurations.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/intelligent-tiering.html
public readonly inventories: Inventory[];- Type: aws-cdk-lib.aws_s3.Inventory[]
- Default: No inventory configuration
The inventory configuration of the bucket.
https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html
public readonly lifecycleRules: LifecycleRule[];- Type: aws-cdk-lib.aws_s3.LifecycleRule[]
- Default: No lifecycle rules.
Rules that define how Amazon S3 manages objects during their lifetime.
public readonly metrics: BucketMetrics[];- Type: aws-cdk-lib.aws_s3.BucketMetrics[]
- Default: No metrics configuration.
The metrics configuration of this bucket.
public readonly notificationsHandlerRole: IRole;- Type: aws-cdk-lib.aws_iam.IRole
- Default: a new role will be created.
The role to be used by the notifications handler.
public readonly objectLockDefaultRetention: ObjectLockRetention;- Type: aws-cdk-lib.aws_s3.ObjectLockRetention
- Default: no default retention period
The default retention mode and rules for S3 Object Lock.
Default retention can be configured after a bucket is created if the bucket already has object lock enabled. Enabling object lock for existing buckets is not supported.
public readonly objectLockEnabled: boolean;- Type: boolean
- Default: false, unless objectLockDefaultRetention is set (then, true)
Enable object lock on the bucket.
Enabling object lock for existing buckets is not supported. Object lock must be enabled when the bucket is created.
public readonly objectOwnership: ObjectOwnership;- Type: aws-cdk-lib.aws_s3.ObjectOwnership
- Default: No ObjectOwnership configuration, uploading account will own the object.
The objectOwnership of the bucket.
https://docs.aws.amazon.com/AmazonS3/latest/dev/about-object-ownership.html
public readonly publicReadAccess: boolean;- Type: boolean
- Default: false
Grants public read access to all objects in the bucket.
Similar to calling bucket.grantPublicAccess()
public readonly removalPolicy: RemovalPolicy;- Type: aws-cdk-lib.RemovalPolicy
- Default: The bucket will be orphaned.
Policy to apply when the bucket is removed from this stack.
public readonly serverAccessLogsBucket: IBucket;- Type: aws-cdk-lib.aws_s3.IBucket
- Default: If "serverAccessLogsPrefix" undefined - access logs disabled, otherwise - log to current bucket.
Destination bucket for the server access logs.
public readonly serverAccessLogsPrefix: string;- Type: string
- Default: No log file prefix
Optional log file prefix to use for the bucket's access logs.
If defined without "serverAccessLogsBucket", enables access logs to current bucket with this prefix.
public readonly transferAcceleration: boolean;- Type: boolean
- Default: false
Whether this bucket should have transfer acceleration turned on or not.
public readonly versioned: boolean;- Type: boolean
- Default: false (unless object lock is enabled, then true)
Whether this bucket should have versioning turned on or not.
public readonly websiteErrorDocument: string;- Type: string
- Default: No error document.
The name of the error document (e.g. "404.html") for the website. websiteIndexDocument must also be set if this is set.
public readonly websiteIndexDocument: string;- Type: string
- Default: No index document.
The name of the index document (e.g. "index.html") for the website. Enables static website hosting for this bucket.
public readonly websiteRedirect: RedirectTarget;- Type: aws-cdk-lib.aws_s3.RedirectTarget
- Default: No redirection.
Specifies the redirect behavior of all requests to a website endpoint of a bucket.
If you specify this property, you can't specify "websiteIndexDocument", "websiteErrorDocument" nor , "websiteRoutingRules".
public readonly websiteRoutingRules: RoutingRule[];- Type: aws-cdk-lib.aws_s3.RoutingRule[]
- Default: No redirection rules.
Rules that define when a redirect is applied and the redirect behavior.
public readonly dataAccessEnabled: boolean;- Type: boolean
- Default: false
Set to true if DataAccess can interact with the bucket.
This extends the existing bucket properties with our own settings, hiding the actual implementation.
import { CustomBucketPropsHidden } from 'cdk-lib-examples'
const customBucketPropsHidden: CustomBucketPropsHidden = { ... }| Name | Type | Description |
|---|---|---|
dataAccessEnabled |
boolean |
Set to true if DataAccess can interact with the bucket. |
versioned |
boolean |
Should bucket versioning be enabled. |
public readonly dataAccessEnabled: boolean;- Type: boolean
- Default: false
Set to true if DataAccess can interact with the bucket.
public readonly versioned: boolean;- Type: boolean
Should bucket versioning be enabled.
This extends the existing bucket properties with our own settings.
import { CustomBucketPropsSeparated } from 'cdk-lib-examples'
const customBucketPropsSeparated: CustomBucketPropsSeparated = { ... }| Name | Type | Description |
|---|---|---|
bucketProps |
aws-cdk-lib.aws_s3.BucketProps |
Properties of original Bucket. |
dataAccessEnabled |
boolean |
Set to true if DataAccess can interact with the bucket. |
public readonly bucketProps: BucketProps;- Type: aws-cdk-lib.aws_s3.BucketProps
Properties of original Bucket.
public readonly dataAccessEnabled: boolean;- Type: boolean
- Default: false
Set to true if DataAccess can interact with the bucket.
import { CustomStackProps } from 'cdk-lib-examples'
const customStackProps: CustomStackProps = { ... }| Name | Type | Description |
|---|---|---|
analyticsReporting |
boolean |
Include runtime versioning information in this Stack. |
crossRegionReferences |
boolean |
Enable this flag to allow native cross region stack references. |
description |
string |
A description of the stack. |
env |
aws-cdk-lib.Environment |
The AWS environment (account/region) where this stack will be deployed. |
permissionsBoundary |
aws-cdk-lib.PermissionsBoundary |
Options for applying a permissions boundary to all IAM Roles and Users created within this Stage. |
stackName |
string |
Name to deploy the stack with. |
suppressTemplateIndentation |
boolean |
Enable this flag to suppress indentation in generated CloudFormation templates. |
synthesizer |
aws-cdk-lib.IStackSynthesizer |
Synthesis method to use while deploying this stack. |
tags |
{[ key: string ]: string} |
Stack tags that will be applied to all the taggable resources and the stack itself. |
terminationProtection |
boolean |
Whether to enable termination protection for this stack. |
deploymentIdentifier |
string |
Optional. |
envName |
string |
Name of environment. |
teamName |
string |
Name of team ownig this. |
public readonly analyticsReporting: boolean;- Type: boolean
- Default:
analyticsReportingsetting of containingApp, or value of 'aws:cdk:version-reporting' context key
Include runtime versioning information in this Stack.
public readonly crossRegionReferences: boolean;- Type: boolean
- Default: false
Enable this flag to allow native cross region stack references.
Enabling this will create a CloudFormation custom resource in both the producing stack and consuming stack in order to perform the export/import
This feature is currently experimental
public readonly description: string;- Type: string
- Default: No description.
A description of the stack.
public readonly env: Environment;- Type: aws-cdk-lib.Environment
- Default: The environment of the containing
Stageif available, otherwise create the stack will be environment-agnostic.
The AWS environment (account/region) where this stack will be deployed.
Set the region/account fields of env to either a concrete value to
select the indicated environment (recommended for production stacks), or to
the values of environment variables
CDK_DEFAULT_REGION/CDK_DEFAULT_ACCOUNT to let the target environment
depend on the AWS credentials/configuration that the CDK CLI is executed
under (recommended for development stacks).
If the Stack is instantiated inside a Stage, any undefined
region/account fields from env will default to the same field on the
encompassing Stage, if configured there.
If either region or account are not set nor inherited from Stage, the
Stack will be considered "environment-agnostic"". Environment-agnostic
stacks can be deployed to any environment but may not be able to take
advantage of all features of the CDK. For example, they will not be able to
use environmental context lookups such as ec2.Vpc.fromLookup and will not
automatically translate Service Principals to the right format based on the
environment's AWS partition, and other such enhancements.
Example
// Use a concrete account and region to deploy this stack to:
// `.account` and `.region` will simply return these values.
new Stack(app, 'Stack1', {
env: {
account: '123456789012',
region: 'us-east-1'
},
});
// Use the CLI's current credentials to determine the target environment:
// `.account` and `.region` will reflect the account+region the CLI
// is configured to use (based on the user CLI credentials)
new Stack(app, 'Stack2', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION
},
});
// Define multiple stacks stage associated with an environment
const myStage = new Stage(app, 'MyStage', {
env: {
account: '123456789012',
region: 'us-east-1'
}
});
// both of these stacks will use the stage's account/region:
// `.account` and `.region` will resolve to the concrete values as above
new MyStack(myStage, 'Stack1');
new YourStack(myStage, 'Stack2');
// Define an environment-agnostic stack:
// `.account` and `.region` will resolve to `{ "Ref": "AWS::AccountId" }` and `{ "Ref": "AWS::Region" }` respectively.
// which will only resolve to actual values by CloudFormation during deployment.
new MyStack(app, 'Stack1');public readonly permissionsBoundary: PermissionsBoundary;- Type: aws-cdk-lib.PermissionsBoundary
- Default: no permissions boundary is applied
Options for applying a permissions boundary to all IAM Roles and Users created within this Stage.
public readonly stackName: string;- Type: string
- Default: Derived from construct path.
Name to deploy the stack with.
public readonly suppressTemplateIndentation: boolean;- Type: boolean
- Default: the value of
@aws-cdk/core:suppressTemplateIndentation, orfalseif that is not set.
Enable this flag to suppress indentation in generated CloudFormation templates.
If not specified, the value of the @aws-cdk/core:suppressTemplateIndentation
context key will be used. If that is not specified, then the
default value false will be used.
public readonly synthesizer: IStackSynthesizer;- Type: aws-cdk-lib.IStackSynthesizer
- Default: The synthesizer specified on
App, orDefaultStackSynthesizerotherwise.
Synthesis method to use while deploying this stack.
The Stack Synthesizer controls aspects of synthesis and deployment, like how assets are referenced and what IAM roles to use. For more information, see the README of the main CDK package.
If not specified, the defaultStackSynthesizer from App will be used.
If that is not specified, DefaultStackSynthesizer is used if
@aws-cdk/core:newStyleStackSynthesis is set to true or the CDK major
version is v2. In CDK v1 LegacyStackSynthesizer is the default if no
other synthesizer is specified.
public readonly tags: {[ key: string ]: string};- Type: {[ key: string ]: string}
- Default: {}
Stack tags that will be applied to all the taggable resources and the stack itself.
public readonly terminationProtection: boolean;- Type: boolean
- Default: false
Whether to enable termination protection for this stack.
public readonly deploymentIdentifier: string;- Type: string
Optional.
Identifier used for stack name
public readonly envName: string;- Type: string
Name of environment.
public readonly teamName: string;- Type: string
Name of team ownig this.
import { SmartStackProps } from 'cdk-lib-examples'
const smartStackProps: SmartStackProps = { ... }| Name | Type | Description |
|---|---|---|
analyticsReporting |
boolean |
Include runtime versioning information in this Stack. |
crossRegionReferences |
boolean |
Enable this flag to allow native cross region stack references. |
description |
string |
A description of the stack. |
env |
aws-cdk-lib.Environment |
The AWS environment (account/region) where this stack will be deployed. |
permissionsBoundary |
aws-cdk-lib.PermissionsBoundary |
Options for applying a permissions boundary to all IAM Roles and Users created within this Stage. |
stackName |
string |
Name to deploy the stack with. |
suppressTemplateIndentation |
boolean |
Enable this flag to suppress indentation in generated CloudFormation templates. |
synthesizer |
aws-cdk-lib.IStackSynthesizer |
Synthesis method to use while deploying this stack. |
tags |
{[ key: string ]: string} |
Stack tags that will be applied to all the taggable resources and the stack itself. |
terminationProtection |
boolean |
Whether to enable termination protection for this stack. |
teamName |
string |
Name of team ownig this. |
public readonly analyticsReporting: boolean;- Type: boolean
- Default:
analyticsReportingsetting of containingApp, or value of 'aws:cdk:version-reporting' context key
Include runtime versioning information in this Stack.
public readonly crossRegionReferences: boolean;- Type: boolean
- Default: false
Enable this flag to allow native cross region stack references.
Enabling this will create a CloudFormation custom resource in both the producing stack and consuming stack in order to perform the export/import
This feature is currently experimental
public readonly description: string;- Type: string
- Default: No description.
A description of the stack.
public readonly env: Environment;- Type: aws-cdk-lib.Environment
- Default: The environment of the containing
Stageif available, otherwise create the stack will be environment-agnostic.
The AWS environment (account/region) where this stack will be deployed.
Set the region/account fields of env to either a concrete value to
select the indicated environment (recommended for production stacks), or to
the values of environment variables
CDK_DEFAULT_REGION/CDK_DEFAULT_ACCOUNT to let the target environment
depend on the AWS credentials/configuration that the CDK CLI is executed
under (recommended for development stacks).
If the Stack is instantiated inside a Stage, any undefined
region/account fields from env will default to the same field on the
encompassing Stage, if configured there.
If either region or account are not set nor inherited from Stage, the
Stack will be considered "environment-agnostic"". Environment-agnostic
stacks can be deployed to any environment but may not be able to take
advantage of all features of the CDK. For example, they will not be able to
use environmental context lookups such as ec2.Vpc.fromLookup and will not
automatically translate Service Principals to the right format based on the
environment's AWS partition, and other such enhancements.
Example
// Use a concrete account and region to deploy this stack to:
// `.account` and `.region` will simply return these values.
new Stack(app, 'Stack1', {
env: {
account: '123456789012',
region: 'us-east-1'
},
});
// Use the CLI's current credentials to determine the target environment:
// `.account` and `.region` will reflect the account+region the CLI
// is configured to use (based on the user CLI credentials)
new Stack(app, 'Stack2', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION
},
});
// Define multiple stacks stage associated with an environment
const myStage = new Stage(app, 'MyStage', {
env: {
account: '123456789012',
region: 'us-east-1'
}
});
// both of these stacks will use the stage's account/region:
// `.account` and `.region` will resolve to the concrete values as above
new MyStack(myStage, 'Stack1');
new YourStack(myStage, 'Stack2');
// Define an environment-agnostic stack:
// `.account` and `.region` will resolve to `{ "Ref": "AWS::AccountId" }` and `{ "Ref": "AWS::Region" }` respectively.
// which will only resolve to actual values by CloudFormation during deployment.
new MyStack(app, 'Stack1');public readonly permissionsBoundary: PermissionsBoundary;- Type: aws-cdk-lib.PermissionsBoundary
- Default: no permissions boundary is applied
Options for applying a permissions boundary to all IAM Roles and Users created within this Stage.
public readonly stackName: string;- Type: string
- Default: Derived from construct path.
Name to deploy the stack with.
public readonly suppressTemplateIndentation: boolean;- Type: boolean
- Default: the value of
@aws-cdk/core:suppressTemplateIndentation, orfalseif that is not set.
Enable this flag to suppress indentation in generated CloudFormation templates.
If not specified, the value of the @aws-cdk/core:suppressTemplateIndentation
context key will be used. If that is not specified, then the
default value false will be used.
public readonly synthesizer: IStackSynthesizer;- Type: aws-cdk-lib.IStackSynthesizer
- Default: The synthesizer specified on
App, orDefaultStackSynthesizerotherwise.
Synthesis method to use while deploying this stack.
The Stack Synthesizer controls aspects of synthesis and deployment, like how assets are referenced and what IAM roles to use. For more information, see the README of the main CDK package.
If not specified, the defaultStackSynthesizer from App will be used.
If that is not specified, DefaultStackSynthesizer is used if
@aws-cdk/core:newStyleStackSynthesis is set to true or the CDK major
version is v2. In CDK v1 LegacyStackSynthesizer is the default if no
other synthesizer is specified.
public readonly tags: {[ key: string ]: string};- Type: {[ key: string ]: string}
- Default: {}
Stack tags that will be applied to all the taggable resources and the stack itself.
public readonly terminationProtection: boolean;- Type: boolean
- Default: false
Whether to enable termination protection for this stack.
public readonly teamName: string;- Type: string
Name of team ownig this.
- Implements: aws-cdk-lib.IAspect
Actual aspect that adds a tag to all S3 buckets.
import { S3Aspect } from 'cdk-lib-examples'
new S3Aspect()| Name | Type | Description |
|---|
| Name | Description |
|---|---|
visit |
All aspects can visit an IConstruct. |
public visit(node: IConstruct): voidAll aspects can visit an IConstruct.
- Type: constructs.IConstruct