Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(servicecatalogappregistry): applicationName can not be changed after deployment #24409

Merged
merged 8 commits into from
Mar 2, 2023
Merged
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { IApplication, Application } from './application';
import { hashValues } from './common';

/**
* Properties used to define targetapplication.
Expand Down Expand Up @@ -92,7 +93,7 @@ class CreateTargetApplication extends TargetApplication {
}
public bind(scope: Construct): BindTargetApplicationResult {
(this.applicationOptions.stackName as string) =
this.applicationOptions.stackName || `Application-${this.applicationOptions.applicationName}-Stack`;
this.applicationOptions.stackName || `ApplicationAssociator-${hashValues(scope.node.addr)}-Stack`;
const stackId = this.applicationOptions.stackName;
(this.applicationOptions.description as string) =
this.applicationOptions.description || 'Stack to create AppRegistry application';
Expand Down Expand Up @@ -120,10 +121,8 @@ class ExistingTargetApplication extends TargetApplication {
super();
}
public bind(scope: Construct): BindTargetApplicationResult {
const arnComponents = cdk.Arn.split(this.applicationOptions.applicationArnValue, cdk.ArnFormat.SLASH_RESOURCE_SLASH_RESOURCE_NAME);
const applicationId = arnComponents.resourceName;
(this.applicationOptions.stackName as string) =
this.applicationOptions.stackName || `Application-${applicationId}-Stack`;
this.applicationOptions.stackName || `ApplicationAssociator-${hashValues(scope.node.addr)}-Stack`;
const stackId = this.applicationOptions.stackName;
const applicationStack = new cdk.Stack(scope, stackId, this.applicationOptions);
const appRegApplication = Application.fromApplicationArn(applicationStack, 'ExistingApplication', this.applicationOptions.applicationArnValue);
Expand Down