From dee71c082b29475e87515cd1a91300d3e6fb3e4c Mon Sep 17 00:00:00 2001 From: Garvit Singh Date: Fri, 3 Feb 2023 15:28:33 -0500 Subject: [PATCH 1/4] Add stack name to service catalog application This allows multiple stack deployments in the same account, region --- .../lib/common-resources/common-resources-construct.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/constructs/lib/common-resources/common-resources-construct.ts b/source/constructs/lib/common-resources/common-resources-construct.ts index 5878398e9..40c41e5c3 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("-", [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); From 4e8d32f33cdd51a022e4d97b4ef4f557893b4dda Mon Sep 17 00:00:00 2001 From: Garvit Singh Date: Fri, 3 Feb 2023 15:39:07 -0500 Subject: [PATCH 2/4] Update cdk snapshot --- source/constructs/test/__snapshots__/constructs.test.ts.snap | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/constructs/test/__snapshots__/constructs.test.ts.snap b/source/constructs/test/__snapshots__/constructs.test.ts.snap index 02bbeaf95..12756b695 100644 --- a/source/constructs/test/__snapshots__/constructs.test.ts.snap +++ b/source/constructs/test/__snapshots__/constructs.test.ts.snap @@ -333,7 +333,9 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = ` "Fn::Join": [ "-", [ - "sih", + { + "Ref": "AWS::StackName", + }, { "Ref": "AWS::Region", }, From 53d3108f744d0a0723f03136561cced6944e08ec Mon Sep 17 00:00:00 2001 From: Garvit Singh Date: Fri, 3 Feb 2023 15:46:03 -0500 Subject: [PATCH 3/4] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 0c988bb5fc36571fb5787a006da0a511d1b392b1 Mon Sep 17 00:00:00 2001 From: Garvit Singh Date: Fri, 3 Feb 2023 16:20:24 -0500 Subject: [PATCH 4/4] 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-* --- .../common-resources/common-resources-construct.ts | 4 ++-- .../test/__snapshots__/constructs.test.ts.snap | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/source/constructs/lib/common-resources/common-resources-construct.ts b/source/constructs/lib/common-resources/common-resources-construct.ts index 40c41e5c3..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("-", [Aws.STACK_NAME, 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 12756b695..1546e1cc4 100644 --- a/source/constructs/test/__snapshots__/constructs.test.ts.snap +++ b/source/constructs/test/__snapshots__/constructs.test.ts.snap @@ -333,6 +333,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = ` "Fn::Join": [ "-", [ + "AppRegistry", { "Ref": "AWS::StackName", }, @@ -1825,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",