Skip to content

Commit 6aa763f

Browse files
authored
fix(servicecatalogappregistry): applicationName can not be changed after deployment (#24409)
Background: * Customers wish to control or modify the stack id of the Application stack to follow their project conventions within CDK. * In previous [fix](#24171), we had deprecated the stack id to push users towards using stack name as the main mechanism for stack identification. * Default stack name as per this [fix](#24171) has `Application Name` embedded in it. If customers wants to **update the application name**, then a new stack name as well as new stack id will be generated, which will eventually create a new Application in a new stack. Problem: * Application associator associates all stacks in scope to an application. * With `ApplicationName` in stack name, we will create an application within a stack. When customers attempt to update the name of the application, we will create a new stack and eventually create a new application, which is the first problem. * In this new application within the new stack, we will try to associate all stacks within the `app` scope, which is already associated to the original application in the original stack and hence cannot be further associated to the new application which will make the deployment of the stack with updated name fail. Fix: * We will continue to honor customer provided stack Name. * If no stack name is provided, then we will default it to `ApplicationAssociator-${hashValues(scope.node.addr)}-Stack`, which doesnt contain `Application Name`. Related Links: * Previous PR which introduced this bug: #24171 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 0ebbf58 commit 6aa763f

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

packages/@aws-cdk/aws-servicecatalogappregistry/lib/target-application.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as cdk from '@aws-cdk/core';
22
import { Construct } from 'constructs';
33
import { IApplication, Application } from './application';
4+
import { hashValues } from './common';
45

56
/**
67
* Properties used to define targetapplication.
@@ -92,7 +93,7 @@ class CreateTargetApplication extends TargetApplication {
9293
}
9394
public bind(scope: Construct): BindTargetApplicationResult {
9495
(this.applicationOptions.stackName as string) =
95-
this.applicationOptions.stackName || `Application-${this.applicationOptions.applicationName}-Stack`;
96+
this.applicationOptions.stackName || `ApplicationAssociator-${hashValues(scope.node.addr)}-Stack`;
9697
const stackId = this.applicationOptions.stackName;
9798
(this.applicationOptions.description as string) =
9899
this.applicationOptions.description || 'Stack to create AppRegistry application';
@@ -120,10 +121,8 @@ class ExistingTargetApplication extends TargetApplication {
120121
super();
121122
}
122123
public bind(scope: Construct): BindTargetApplicationResult {
123-
const arnComponents = cdk.Arn.split(this.applicationOptions.applicationArnValue, cdk.ArnFormat.SLASH_RESOURCE_SLASH_RESOURCE_NAME);
124-
const applicationId = arnComponents.resourceName;
125124
(this.applicationOptions.stackName as string) =
126-
this.applicationOptions.stackName || `Application-${applicationId}-Stack`;
125+
this.applicationOptions.stackName || `ApplicationAssociator-${hashValues(scope.node.addr)}-Stack`;
127126
const stackId = this.applicationOptions.stackName;
128127
const applicationStack = new cdk.Stack(scope, stackId, this.applicationOptions);
129128
const appRegApplication = Application.fromApplicationArn(applicationStack, 'ExistingApplication', this.applicationOptions.applicationArnValue);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"29.0.0"}
1+
{"version":"30.1.0"}

packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "29.0.0",
2+
"version": "30.1.0",
33
"files": {
4-
"8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e": {
4+
"6a426aab2239a5fb580c074adbf5b8e3acefa04209423d2b53989c73aed3f95b": {
55
"source": {
66
"path": "integ-servicecatalogappregistry-application.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e.json",
12+
"objectKey": "6a426aab2239a5fb580c074adbf5b8e3acefa04209423d2b53989c73aed3f95b.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"TestApplication2FBC585F": {
44
"Type": "AWS::ServiceCatalogAppRegistry::Application",
55
"Properties": {
6-
"Name": "TestApplication",
6+
"Name": "MyTestApplication",
77
"Description": "Test application description"
88
}
99
},
@@ -132,7 +132,7 @@
132132
{
133133
"Ref": "AWS::Region"
134134
},
135-
".console.aws.amazon.com/systems-manager/appmanager/application/AWS_AppRegistry_Application-TestApplication"
135+
".console.aws.amazon.com/systems-manager/appmanager/application/AWS_AppRegistry_Application-MyTestApplication"
136136
]
137137
]
138138
}

packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "29.0.0",
2+
"version": "30.1.0",
33
"testCases": {
44
"integ.application": {
55
"stacks": [

packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "29.0.0",
2+
"version": "30.1.0",
33
"artifacts": {
44
"integ-servicecatalogappregistry-application.assets": {
55
"type": "cdk:asset-manifest",
@@ -17,7 +17,7 @@
1717
"validateOnSynth": false,
1818
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
1919
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/6a426aab2239a5fb580c074adbf5b8e3acefa04209423d2b53989c73aed3f95b.json",
2121
"requiresBootstrapStackVersion": 6,
2222
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2323
"additionalDependencies": [

packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"attributes": {
1919
"aws:cdk:cloudformation:type": "AWS::ServiceCatalogAppRegistry::Application",
2020
"aws:cdk:cloudformation:props": {
21-
"name": "TestApplication",
21+
"name": "MyTestApplication",
2222
"description": "Test application description"
2323
}
2424
},
@@ -249,7 +249,7 @@
249249
"path": "Tree",
250250
"constructInfo": {
251251
"fqn": "constructs.Construct",
252-
"version": "10.1.209"
252+
"version": "10.1.252"
253253
}
254254
}
255255
},

packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const app = new cdk.App();
66
const stack = new cdk.Stack(app, 'integ-servicecatalogappregistry-application');
77

88
const application = new appreg.Application(stack, 'TestApplication', {
9-
applicationName: 'TestApplication',
9+
applicationName: 'MyTestApplication',
1010
description: 'Test application description',
1111
});
1212

0 commit comments

Comments
 (0)