diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts index 56beb537969c8..c5f8227f9796b 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts @@ -12,6 +12,7 @@ interface MyNestedStackProps { readonly siblingTopic?: sns.Topic; // a topic defined in a sibling nested stack readonly topicCount: number; readonly topicNamePrefix: string; + readonly description?: string; } class MyNestedStack extends NestedStack { @@ -22,6 +23,7 @@ class MyNestedStack extends NestedStack { parameters: { [topicNamePrefixLogicalId]: props.topicNamePrefix, // pass in a parameter to the nested stack }, + description: props.description, }); const topicNamePrefixParameter = new CfnParameter(this, 'TopicNamePrefix', { type: 'String' }); @@ -57,7 +59,7 @@ class MyTestStack extends Stack { const queue = new sqs.Queue(this, 'SubscriberQueue'); new MyNestedStack(this, 'NestedStack1', { topicCount: 3, topicNamePrefix: 'Prefix1', subscriber: queue }); - new MyNestedStack(this, 'NestedStack2', { topicCount: 2, topicNamePrefix: 'Prefix2' }); + new MyNestedStack(this, 'NestedStack2', { topicCount: 2, topicNamePrefix: 'Prefix2', description: 'This is secound nested stack.' }); } } diff --git a/packages/@aws-cdk/core/README.md b/packages/@aws-cdk/core/README.md index 773c2802a839b..215365c730108 100644 --- a/packages/@aws-cdk/core/README.md +++ b/packages/@aws-cdk/core/README.md @@ -995,6 +995,16 @@ const stack = new Stack(app, 'StackName', { By default, termination protection is disabled. +### Description + +You can add a description of the stack in the same way as `StackProps`. + +```ts +const stack = new Stack(app, 'StackName', { + description: 'This is a description.', +}); +``` + ### CfnJson `CfnJson` allows you to postpone the resolution of a JSON blob from diff --git a/packages/@aws-cdk/core/lib/nested-stack.ts b/packages/@aws-cdk/core/lib/nested-stack.ts index ea24698ac2b28..3adb30e677800 100644 --- a/packages/@aws-cdk/core/lib/nested-stack.ts +++ b/packages/@aws-cdk/core/lib/nested-stack.ts @@ -68,6 +68,13 @@ export interface NestedStackProps { * @default RemovalPolicy.DESTROY */ readonly removalPolicy?: RemovalPolicy; + + /** + * A description of the stack. + * + * @default - No description. + */ + readonly description?: string; } /** @@ -112,6 +119,7 @@ export class NestedStack extends Stack { super(scope, id, { env: { account: parentStack.account, region: parentStack.region }, synthesizer: new NestedStackSynthesizer(parentStack.synthesizer), + description: props.description, }); this._parentStack = parentStack; diff --git a/packages/@aws-cdk/core/test/nested-stack.test.ts b/packages/@aws-cdk/core/test/nested-stack.test.ts index b1508e8bf148f..697253fe5f7fd 100644 --- a/packages/@aws-cdk/core/test/nested-stack.test.ts +++ b/packages/@aws-cdk/core/test/nested-stack.test.ts @@ -22,4 +22,13 @@ describe('nested-stack', () => { }, }); }); + test('a nested-stack has a description in templateOptions.', () => { + const description = 'This is a description.'; + const stack = new Stack(); + var nestedStack = new NestedStack(stack, 'MyNestedStack', { + description, + }); + + expect(nestedStack.templateOptions.description).toEqual(description); + }); }); \ No newline at end of file diff --git a/packages/aws-cdk-lib/README.md b/packages/aws-cdk-lib/README.md index a620a2aecc4ad..a8e26848a6112 100644 --- a/packages/aws-cdk-lib/README.md +++ b/packages/aws-cdk-lib/README.md @@ -1026,6 +1026,16 @@ const stack = new Stack(app, 'StackName', { By default, termination protection is disabled. +### Description + +You can add a description of the stack in the same way as `StackProps`. + +```ts +const stack = new Stack(app, 'StackName', { + description: 'This is a description.', +}); +``` + ### CfnJson `CfnJson` allows you to postpone the resolution of a JSON blob from