diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integ-servicecatalog-product.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integ-servicecatalog-product.assets.json index b23771a1aec83..aca5de824e35d 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integ-servicecatalog-product.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integ-servicecatalog-product.assets.json @@ -99,7 +99,7 @@ } } }, - "dd2d087eeb6ede1d2a9166639ccbde7bd1b10eef9ba2b4cb3d9855faa4fe8c1f": { + "afd1257a565d91b3bdd02740160c6b1731533aef02f55ffdd9a865dce235414c": { "source": { "path": "integservicecatalogproductSNSTopicProduct3B51CF591.product.template.json", "packaging": "file" @@ -107,7 +107,7 @@ "destinations": { "12345678-test-region": { "bucketName": "cdk-hnb659fds-assets-12345678-test-region", - "objectKey": "dd2d087eeb6ede1d2a9166639ccbde7bd1b10eef9ba2b4cb3d9855faa4fe8c1f.json", + "objectKey": "afd1257a565d91b3bdd02740160c6b1731533aef02f55ffdd9a865dce235414c.json", "region": "test-region", "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-file-publishing-role-12345678-test-region" } @@ -127,7 +127,7 @@ } } }, - "c75ea4f5bdb2bfda76ea2719dff537b555df2597099f2ef66987bbf41f1e64ed": { + "25c8bf2bd5674bc63f61b476236ebb8a3dee96a55e7ed983b6f39c0b8a1f35bb": { "source": { "path": "integ-servicecatalog-product.template.json", "packaging": "file" @@ -135,7 +135,7 @@ "destinations": { "12345678-test-region": { "bucketName": "cdk-hnb659fds-assets-12345678-test-region", - "objectKey": "c75ea4f5bdb2bfda76ea2719dff537b555df2597099f2ef66987bbf41f1e64ed.json", + "objectKey": "25c8bf2bd5674bc63f61b476236ebb8a3dee96a55e7ed983b6f39c0b8a1f35bb.json", "region": "test-region", "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-file-publishing-role-12345678-test-region" } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integ-servicecatalog-product.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integ-servicecatalog-product.template.json index 040c2f52f34fc..082b56fe0b1be 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integ-servicecatalog-product.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integ-servicecatalog-product.template.json @@ -389,7 +389,7 @@ "DisableTemplateValidation": false, "Info": { "LoadTemplateFromURL": { - "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/dd2d087eeb6ede1d2a9166639ccbde7bd1b10eef9ba2b4cb3d9855faa4fe8c1f.json" + "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/afd1257a565d91b3bdd02740160c6b1731533aef02f55ffdd9a865dce235414c.json" } } }, @@ -397,7 +397,7 @@ "DisableTemplateValidation": false, "Info": { "LoadTemplateFromURL": { - "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/dd2d087eeb6ede1d2a9166639ccbde7bd1b10eef9ba2b4cb3d9855faa4fe8c1f.json" + "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/afd1257a565d91b3bdd02740160c6b1731533aef02f55ffdd9a865dce235414c.json" } } }, @@ -414,7 +414,7 @@ "DisableTemplateValidation": false, "Info": { "LoadTemplateFromURL": { - "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/dd2d087eeb6ede1d2a9166639ccbde7bd1b10eef9ba2b4cb3d9855faa4fe8c1f.json" + "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/afd1257a565d91b3bdd02740160c6b1731533aef02f55ffdd9a865dce235414c.json" } }, "Name": "v1" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct1B8D03934.product.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct1B8D03934.product.template.json index 2f2f4704a22ad..7a196f33bb792 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct1B8D03934.product.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct1B8D03934.product.template.json @@ -1,4 +1,5 @@ { + "Description": "foo bar", "Resources": { "TopicProductD757E287": { "Type": "AWS::SNS::Topic" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct24C7C16DA.product.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct24C7C16DA.product.template.json index 2f2f4704a22ad..7a196f33bb792 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct24C7C16DA.product.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct24C7C16DA.product.template.json @@ -1,4 +1,5 @@ { + "Description": "foo bar", "Resources": { "TopicProductD757E287": { "Type": "AWS::SNS::Topic" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct3B51CF591.product.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct3B51CF591.product.template.json index 2f2f4704a22ad..7a196f33bb792 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct3B51CF591.product.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/integservicecatalogproductSNSTopicProduct3B51CF591.product.template.json @@ -1,4 +1,5 @@ { + "Description": "foo bar", "Resources": { "TopicProductD757E287": { "Type": "AWS::SNS::Topic" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/manifest.json index 07208c33fb26c..00574274f4e18 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/manifest.json @@ -19,7 +19,7 @@ "notificationArns": [], "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-deploy-role-12345678-test-region", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-cfn-exec-role-12345678-test-region", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-12345678-test-region/c75ea4f5bdb2bfda76ea2719dff537b555df2597099f2ef66987bbf41f1e64ed.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-12345678-test-region/25c8bf2bd5674bc63f61b476236ebb8a3dee96a55e7ed983b6f39c0b8a1f35bb.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -68,10 +68,7 @@ "/integ-servicecatalog-product/TestAssetBucket/ProductAssetsDeployment/AwsCliLayer/Resource": [ { "type": "aws:cdk:logicalId", - "data": "TestAssetBucketProductAssetsDeploymentAwsCliLayerD1E52C82", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_REPLACE" - ] + "data": "TestAssetBucketProductAssetsDeploymentAwsCliLayerD1E52C82" } ], "/integ-servicecatalog-product/TestAssetBucket/ProductAssetsDeployment/CustomResource/Default": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/tree.json index e5b7f304b6cfb..ebca8462c4769 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.js.snapshot/tree.json @@ -896,13 +896,13 @@ "id": "TestProduct", "path": "integ-servicecatalog-product/TestProduct", "children": { - "Template8da2639f455b": { - "id": "Template8da2639f455b", - "path": "integ-servicecatalog-product/TestProduct/Template8da2639f455b", + "Template15af34b9c632": { + "id": "Template15af34b9c632", + "path": "integ-servicecatalog-product/TestProduct/Template15af34b9c632", "children": { "Stage": { "id": "Stage", - "path": "integ-servicecatalog-product/TestProduct/Template8da2639f455b/Stage", + "path": "integ-servicecatalog-product/TestProduct/Template15af34b9c632/Stage", "constructInfo": { "fqn": "aws-cdk-lib.AssetStaging", "version": "0.0.0" @@ -910,7 +910,7 @@ }, "AssetBucket": { "id": "AssetBucket", - "path": "integ-servicecatalog-product/TestProduct/Template8da2639f455b/AssetBucket", + "path": "integ-servicecatalog-product/TestProduct/Template15af34b9c632/AssetBucket", "constructInfo": { "fqn": "aws-cdk-lib.aws_s3.BucketBase", "version": "0.0.0" @@ -922,13 +922,13 @@ "version": "0.0.0" } }, - "Templatebf6a94bc96e6": { - "id": "Templatebf6a94bc96e6", - "path": "integ-servicecatalog-product/TestProduct/Templatebf6a94bc96e6", + "Template352ac991d470": { + "id": "Template352ac991d470", + "path": "integ-servicecatalog-product/TestProduct/Template352ac991d470", "children": { "Stage": { "id": "Stage", - "path": "integ-servicecatalog-product/TestProduct/Templatebf6a94bc96e6/Stage", + "path": "integ-servicecatalog-product/TestProduct/Template352ac991d470/Stage", "constructInfo": { "fqn": "aws-cdk-lib.AssetStaging", "version": "0.0.0" @@ -936,7 +936,7 @@ }, "AssetBucket": { "id": "AssetBucket", - "path": "integ-servicecatalog-product/TestProduct/Templatebf6a94bc96e6/AssetBucket", + "path": "integ-servicecatalog-product/TestProduct/Template352ac991d470/AssetBucket", "constructInfo": { "fqn": "aws-cdk-lib.aws_s3.BucketBase", "version": "0.0.0" @@ -983,7 +983,7 @@ "disableTemplateValidation": false, "info": { "LoadTemplateFromURL": { - "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/dd2d087eeb6ede1d2a9166639ccbde7bd1b10eef9ba2b4cb3d9855faa4fe8c1f.json" + "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/afd1257a565d91b3bdd02740160c6b1731533aef02f55ffdd9a865dce235414c.json" } } }, @@ -991,7 +991,7 @@ "disableTemplateValidation": false, "info": { "LoadTemplateFromURL": { - "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/dd2d087eeb6ede1d2a9166639ccbde7bd1b10eef9ba2b4cb3d9855faa4fe8c1f.json" + "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/afd1257a565d91b3bdd02740160c6b1731533aef02f55ffdd9a865dce235414c.json" } } }, @@ -1009,7 +1009,7 @@ "disableTemplateValidation": false, "info": { "LoadTemplateFromURL": { - "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/dd2d087eeb6ede1d2a9166639ccbde7bd1b10eef9ba2b4cb3d9855faa4fe8c1f.json" + "Fn::Sub": "https://s3.test-region.${AWS::URLSuffix}/cdk-hnb659fds-assets-12345678-test-region/afd1257a565d91b3bdd02740160c6b1731533aef02f55ffdd9a865dce235414c.json" } } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.ts index 9e8e1d36d8381..5dd4815a34fd5 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.product.ts @@ -70,7 +70,9 @@ const stack = new cdk.Stack(app, 'integ-servicecatalog-product', { class TestProductStack extends servicecatalog.ProductStack { constructor(scope: any, id: string) { - super(scope, id); + super(scope, id, { + description: 'foo bar', + }); new sns.Topic(this, 'TopicProduct'); } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/product-stack-snapshots/integservicecatalogproductProductStackHistory4D520FF1.integservicecatalogproductSNSTopicProduct3B51CF591.v1.product.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/product-stack-snapshots/integservicecatalogproductProductStackHistory4D520FF1.integservicecatalogproductSNSTopicProduct3B51CF591.v1.product.template.json index 2f2f4704a22ad..7a196f33bb792 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/product-stack-snapshots/integservicecatalogproductProductStackHistory4D520FF1.integservicecatalogproductSNSTopicProduct3B51CF591.v1.product.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/product-stack-snapshots/integservicecatalogproductProductStackHistory4D520FF1.integservicecatalogproductSNSTopicProduct3B51CF591.v1.product.template.json @@ -1,4 +1,5 @@ { + "Description": "foo bar", "Resources": { "TopicProductD757E287": { "Type": "AWS::SNS::Topic" diff --git a/packages/aws-cdk-lib/aws-servicecatalog/lib/product-stack.ts b/packages/aws-cdk-lib/aws-servicecatalog/lib/product-stack.ts index 7214cf1a913de..bf15815f69678 100644 --- a/packages/aws-cdk-lib/aws-servicecatalog/lib/product-stack.ts +++ b/packages/aws-cdk-lib/aws-servicecatalog/lib/product-stack.ts @@ -43,6 +43,21 @@ export interface ProductStackProps { * @default 128 */ readonly memoryLimit?: number; + + /** + * A description of the stack. + * + * @default - No description. + */ + readonly description?: string; + + /** + * Include runtime versioning information in this Stack + * + * @default - `analyticsReporting` setting of containing `App`, or value of + * 'aws:cdk:version-reporting' context key + */ + readonly analyticsReporting?: boolean; } /** @@ -64,6 +79,8 @@ export class ProductStack extends cdk.Stack { constructor(scope: Construct, id: string, props: ProductStackProps = {}) { const parentStack = findParentStack(scope); super(scope, id, { + analyticsReporting: props.analyticsReporting, + description: props.description, synthesizer: new ProductStackSynthesizer({ parentStack, assetBucket: props.assetBucket, diff --git a/packages/aws-cdk-lib/aws-servicecatalog/test/product-stack.test.ts b/packages/aws-cdk-lib/aws-servicecatalog/test/product-stack.test.ts index 6cfbe8f26a3da..ec1fccb038f41 100644 --- a/packages/aws-cdk-lib/aws-servicecatalog/test/product-stack.test.ts +++ b/packages/aws-cdk-lib/aws-servicecatalog/test/product-stack.test.ts @@ -69,6 +69,26 @@ describe('ProductStack', () => { expect(assembly.directory).toBe('/tmp/foobar'); }); + test.each([true, false])('Can enable or disable anlaytics reporting in product stack', (enabled) => { + // GIVEN + const app = new cdk.App(); + const mainStack = new cdk.Stack(app, 'MyStackAbsolutePath'); + const testAssetBucket = new s3.Bucket(mainStack, 'TestAssetBucket', { + bucketName: 'test-asset-bucket', + }); + const productStack = new ProductWithAnAsset(mainStack, 'MyProductStackAbsolutePath', { + assetBucket: testAssetBucket, + analyticsReporting: enabled, + description: 'foo bar', + }); + + // THEN + const assembly = app.synth(); + const stackTemplate = JSON.parse(fs.readFileSync(path.join(assembly.directory, productStack.templateFile), 'utf-8')); + Template.fromJSON(stackTemplate).resourceCountIs('AWS::CDK::Metadata', enabled ? 1 : 0); + expect(Template.fromJSON(stackTemplate).toJSON().Description).toEqual('foo bar'); + }); + test('Used defined Asset bucket in product stack with nested assets', () => { // GIVEN const app = new cdk.App(