From b5bed5904ec3f28069193c918157c48f203b933d Mon Sep 17 00:00:00 2001 From: garvit singh Date: Mon, 6 Feb 2023 12:02:19 -0500 Subject: [PATCH] Use stack name in Service Catalog Application name for multiple cfn stack deployments (#438) * Add stack name to service catalog application This allows multiple stack deployments in the same account, region * Update cdk snapshot * Add changelog entry * Prepend AppRegistry application name with static name Stack name is used in naming AppRegistry application and attribute group; which must not begin with aws. The change adds support for stack names starting with aws-* --- CHANGELOG.md | 1 + .../common-resources-construct.ts | 4 ++-- .../test/__snapshots__/constructs.test.ts.snap | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c39e24f09..cdbcba1ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - package-lock.json for all modules [#426](https://github.com/aws-solutions/serverless-image-handler/pull/426) - github workflows for running unit test, eslint and prettier formatting, cdk nag, security scans [#402](https://github.com/aws-solutions/serverless-image-handler/pull/402) - demo-ui unicode support [#416](https://github.com/aws-solutions/serverless-image-handler/issues/416) +- support for multiple cloudformation stack deployments in the same region ### Changed diff --git a/source/constructs/lib/common-resources/common-resources-construct.ts b/source/constructs/lib/common-resources/common-resources-construct.ts index 5878398e9..20b7e9f70 100644 --- a/source/constructs/lib/common-resources/common-resources-construct.ts +++ b/source/constructs/lib/common-resources/common-resources-construct.ts @@ -93,7 +93,7 @@ export class CommonResources extends Construct { const applicationType = "AWS-Solutions"; const application = new appreg.Application(stack, "AppRegistry", { - applicationName: Fn.join("-", [props.applicationName, Aws.REGION, Aws.ACCOUNT_ID]), + applicationName: Fn.join("-", ["AppRegistry", Aws.STACK_NAME, Aws.REGION, Aws.ACCOUNT_ID]), description: `Service Catalog application to track and manage all your resources for the solution ${props.applicationName}`, }); application.associateStack(stack); @@ -104,7 +104,7 @@ export class CommonResources extends Construct { Tags.of(application).add("Solutions:ApplicationType", applicationType); const attributeGroup = new appreg.AttributeGroup(stack, "DefaultApplicationAttributes", { - attributeGroupName: Aws.STACK_NAME, + attributeGroupName: `AppRegistry-${Aws.STACK_NAME}`, description: "Attribute group for solution information", attributes: { applicationType, diff --git a/source/constructs/test/__snapshots__/constructs.test.ts.snap b/source/constructs/test/__snapshots__/constructs.test.ts.snap index 02bbeaf95..1546e1cc4 100644 --- a/source/constructs/test/__snapshots__/constructs.test.ts.snap +++ b/source/constructs/test/__snapshots__/constructs.test.ts.snap @@ -333,7 +333,10 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = ` "Fn::Join": [ "-", [ - "sih", + "AppRegistry", + { + "Ref": "AWS::StackName", + }, { "Ref": "AWS::Region", }, @@ -1823,7 +1826,15 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = ` }, "Description": "Attribute group for solution information", "Name": { - "Ref": "AWS::StackName", + "Fn::Join": [ + "", + [ + "AppRegistry-", + { + "Ref": "AWS::StackName", + }, + ], + ], }, "Tags": { "SolutionId": "S0ABC",