From 4c9a0dc6dac59370f15cb43e90427d9f18e878a6 Mon Sep 17 00:00:00 2001 From: joe-king-sh Date: Thu, 30 Jun 2022 08:02:10 +0000 Subject: [PATCH 1/6] feat(core): Add a description parameter to nested stack. --- packages/@aws-cdk/core/lib/nested-stack.ts | 8 ++++++++ 1 file changed, 8 insertions(+) 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; From fffcb78937c83a4d31c3841e6d374b5bfa15d916 Mon Sep 17 00:00:00 2001 From: joe-king-sh Date: Thu, 30 Jun 2022 09:01:56 +0000 Subject: [PATCH 2/6] feat(core): Add a test for the nested stack description. --- packages/@aws-cdk/core/test/nested-stack.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/@aws-cdk/core/test/nested-stack.test.ts b/packages/@aws-cdk/core/test/nested-stack.test.ts index b1508e8bf148f..0bbf9f7f9bd58 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 From 60628347c04703379dcfb3900e08383943b37c6f Mon Sep 17 00:00:00 2001 From: joe-king-sh Date: Thu, 30 Jun 2022 09:28:20 +0000 Subject: [PATCH 3/6] feat(core): Add a description of this feature to README.md --- packages/@aws-cdk/core/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/@aws-cdk/core/README.md b/packages/@aws-cdk/core/README.md index 468620b150dc2..f006335c68c4f 100644 --- a/packages/@aws-cdk/core/README.md +++ b/packages/@aws-cdk/core/README.md @@ -988,6 +988,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 From 3ab1510a8f6d23c7b085867bb4f9bcb7f586261b Mon Sep 17 00:00:00 2001 From: joe-king-sh Date: Thu, 30 Jun 2022 12:38:00 +0000 Subject: [PATCH 4/6] feat(core): fix a lint issue. --- packages/@aws-cdk/core/test/nested-stack.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/core/test/nested-stack.test.ts b/packages/@aws-cdk/core/test/nested-stack.test.ts index 0bbf9f7f9bd58..697253fe5f7fd 100644 --- a/packages/@aws-cdk/core/test/nested-stack.test.ts +++ b/packages/@aws-cdk/core/test/nested-stack.test.ts @@ -23,7 +23,7 @@ describe('nested-stack', () => { }); }); test('a nested-stack has a description in templateOptions.', () => { - const description = 'This is a description.' + const description = 'This is a description.'; const stack = new Stack(); var nestedStack = new NestedStack(stack, 'MyNestedStack', { description, From 13920a262472a21cbb53b261a28688f30ddbf4fe Mon Sep 17 00:00:00 2001 From: joe-king-sh Date: Thu, 30 Jun 2022 14:23:43 +0000 Subject: [PATCH 5/6] feat(core): fix the integration test. --- .../@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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.' }); } } From 2b6703bc0d4f4a1e1e27a40c8c2a55cb36bcffad Mon Sep 17 00:00:00 2001 From: joe-king-sh Date: Thu, 30 Jun 2022 15:42:49 +0000 Subject: [PATCH 6/6] feat(core): Add a description of this feature to README.md in aws-cdk-lib. --- packages/aws-cdk-lib/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/aws-cdk-lib/README.md b/packages/aws-cdk-lib/README.md index 6f082fbbe2413..0249e6ca4acb6 100644 --- a/packages/aws-cdk-lib/README.md +++ b/packages/aws-cdk-lib/README.md @@ -1019,6 +1019,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