Skip to content

Commit a21731c

Browse files
authored
fix(appconfig): deployment recreated on every cdk deployment (#28782)
Every time I perform a CDK deployment, the logicalId hash of the deployment resource changes and causes the deployment resource to be deleted and recreated. I'm assuming it is because the configuration `content` is part of the hash creation and I am creating the content using `lazy` and at the time of the hash creation it is still a token. Looking at the [CloudFormation docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appconfig-deployment.html) for the deployment resource, a change to _any_ property causes a replacement so I don't think we need to control the recreation logic ourselves, we should just let CloudFormation do the resource replacement for us. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent fc8b955 commit a21731c

16 files changed

+122
-83
lines changed

packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts

+1-25
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE
203203
});
204204
}
205205

206-
protected abstract getDeploymentHash(environment: IEnvironment): string;
207-
208206
/**
209207
* Adds an extension defined by the action point and event destination
210208
* and also creates an extension association to the configuration profile.
@@ -312,8 +310,7 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE
312310
* please take a look into https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appconfig.CfnDeployment.html.
313311
*/
314312
public deploy(environment: IEnvironment) {
315-
const logicalId = `Deployment${this.getDeploymentHash(environment)}`;
316-
new CfnDeployment(this, logicalId, {
313+
new CfnDeployment(this, `Deployment${getHash(environment.name!)}`, {
317314
applicationId: this.application.applicationId,
318315
configurationProfileId: this.configurationProfileId,
319316
deploymentStrategyId: this.deploymentStrategy!.deploymentStrategyId,
@@ -485,16 +482,6 @@ export class HostedConfiguration extends ConfigurationBase {
485482
this.addExistingEnvironmentsToApplication();
486483
this.deployConfigToEnvironments();
487484
}
488-
489-
protected getDeploymentHash(environment: IEnvironment): string {
490-
const combinedString = `
491-
${this.application!.name!}
492-
${this.name!}
493-
${environment.name!}
494-
${this.content}
495-
`;
496-
return getHash(combinedString);
497-
}
498485
}
499486

500487
/**
@@ -626,17 +613,6 @@ export class SourcedConfiguration extends ConfigurationBase {
626613
this.deployConfigToEnvironments();
627614
}
628615

629-
protected getDeploymentHash(environment: IEnvironment): string {
630-
const combinedString = `
631-
${this.application!.name!}
632-
${this.name!}
633-
${environment.name!}
634-
${this.versionNumber}
635-
${this.location.type}
636-
`;
637-
return getHash(combinedString);
638-
}
639-
640616
private getPolicyForRole(): iam.PolicyDocument {
641617
const policy = new iam.PolicyStatement({
642618
effect: iam.Effect.ALLOW,

packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/appconfigconfigurationDefaultTestDeployAssert6752CD38.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/aws-appconfig-configuration.template.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
"UpdateReplacePolicy": "Retain",
169169
"DeletionPolicy": "Retain"
170170
},
171-
"MyHostedConfigDeploymentE4742E8E64DF4": {
171+
"MyHostedConfigDeployment8E5DB1FCC9183": {
172172
"Type": "AWS::AppConfig::Deployment",
173173
"Properties": {
174174
"ApplicationId": {
@@ -213,7 +213,7 @@
213213
"UpdateReplacePolicy": "Retain",
214214
"DeletionPolicy": "Retain"
215215
},
216-
"MyHostedConfigFromJsonDeploymentCD82E3049E374": {
216+
"MyHostedConfigFromJsonDeployment3AC6ED5A2933B": {
217217
"Type": "AWS::AppConfig::Deployment",
218218
"Properties": {
219219
"ApplicationId": {
@@ -233,7 +233,7 @@
233233
}
234234
}
235235
},
236-
"MyHostedConfigFromJsonDeploymentEFECDBC4087F1": {
236+
"MyHostedConfigFromJsonDeploymentFA00BC528601D": {
237237
"Type": "AWS::AppConfig::Deployment",
238238
"Properties": {
239239
"ApplicationId": {
@@ -278,7 +278,7 @@
278278
"UpdateReplacePolicy": "Retain",
279279
"DeletionPolicy": "Retain"
280280
},
281-
"MyHostedConfigFromYamlDeploymentFE9624CBE5FC6": {
281+
"MyHostedConfigFromYamlDeploymentD93A5BDCCAAB2": {
282282
"Type": "AWS::AppConfig::Deployment",
283283
"Properties": {
284284
"ApplicationId": {
@@ -472,7 +472,7 @@
472472
]
473473
}
474474
},
475-
"MyConfigFromParameterDeployment0C84B4B3BAD6B": {
475+
"MyConfigFromParameterDeployment28051DE6185BF": {
476476
"Type": "AWS::AppConfig::Deployment",
477477
"Properties": {
478478
"ApplicationId": {
@@ -593,7 +593,7 @@
593593
}
594594
}
595595
},
596-
"MyConfigFromDocumentDeployment1520EE7C916D3": {
596+
"MyConfigFromDocumentDeployment7A5BA9D7D69C3": {
597597
"Type": "AWS::AppConfig::Deployment",
598598
"Properties": {
599599
"ApplicationId": {

packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/manifest.json

+68-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/tree.json

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-appconfig-alpha/test/integ.extension.js.snapshot/aws-appconfig-extension.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)