From a21731c9b1f34525433fbee668ebb2321debf5b8 Mon Sep 17 00:00:00 2001 From: Cory Hall <43035978+corymhall@users.noreply.github.com> Date: Tue, 13 Feb 2024 18:30:07 -0500 Subject: [PATCH] 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* --- .../aws-appconfig-alpha/lib/configuration.ts | 26 +----- ...cfb5a961df08d8dbf7cd37e60bf216fb982a00.zip | Bin 4640 -> 0 bytes ...efaultTestDeployAssert6752CD38.assets.json | 2 +- .../aws-appconfig-configuration.assets.json | 6 +- .../aws-appconfig-configuration.template.json | 12 +-- .../integ.configuration.js.snapshot/cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 82 +++++++++++++++--- .../integ.configuration.js.snapshot/tree.json | 36 ++++---- .../aws-appconfig-extension.assets.json | 6 +- .../aws-appconfig-extension.template.json | 2 +- ...efaultTestDeployAssert64BA6C4E.assets.json | 2 +- .../test/integ.extension.js.snapshot/cdk.out | 2 +- .../integ.extension.js.snapshot/integ.json | 2 +- .../integ.extension.js.snapshot/manifest.json | 17 +++- .../integ.extension.js.snapshot/tree.json | 6 +- 16 files changed, 122 insertions(+), 83 deletions(-) delete mode 100644 packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/.cache/e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00.zip diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts index fc84fa491c85c..409567835c46d 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts @@ -203,8 +203,6 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE }); } - protected abstract getDeploymentHash(environment: IEnvironment): string; - /** * Adds an extension defined by the action point and event destination * and also creates an extension association to the configuration profile. @@ -312,8 +310,7 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE * please take a look into https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appconfig.CfnDeployment.html. */ public deploy(environment: IEnvironment) { - const logicalId = `Deployment${this.getDeploymentHash(environment)}`; - new CfnDeployment(this, logicalId, { + new CfnDeployment(this, `Deployment${getHash(environment.name!)}`, { applicationId: this.application.applicationId, configurationProfileId: this.configurationProfileId, deploymentStrategyId: this.deploymentStrategy!.deploymentStrategyId, @@ -485,16 +482,6 @@ export class HostedConfiguration extends ConfigurationBase { this.addExistingEnvironmentsToApplication(); this.deployConfigToEnvironments(); } - - protected getDeploymentHash(environment: IEnvironment): string { - const combinedString = ` - ${this.application!.name!} - ${this.name!} - ${environment.name!} - ${this.content} - `; - return getHash(combinedString); - } } /** @@ -626,17 +613,6 @@ export class SourcedConfiguration extends ConfigurationBase { this.deployConfigToEnvironments(); } - protected getDeploymentHash(environment: IEnvironment): string { - const combinedString = ` - ${this.application!.name!} - ${this.name!} - ${environment.name!} - ${this.versionNumber} - ${this.location.type} - `; - return getHash(combinedString); - } - private getPolicyForRole(): iam.PolicyDocument { const policy = new iam.PolicyStatement({ effect: iam.Effect.ALLOW, diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/.cache/e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00.zip b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.configuration.js.snapshot/.cache/e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00.zip deleted file mode 100644 index ed9129d5ece9cc8eb6f4265188d5561ec5a5f8cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4640 zcmV+*65s7mO9KQH00;mG0000X00000000000000000;m80BLSyWq2-ddBs~%Z`;Tb ze)q4~$~cg^$Vv+Lp)jBVK1aD4No?1O8?O_l52{l z!XcK(+1Z)dnb~h<_tMq6C@V29@=88cSvosP^^;#zk=yTCv0SG4(*7)z{ig2gD$SZ- z^=w@hbE%s5m0YbCX(o>rWw8=s%-<)5*8^5N< z`dja4eD&Ap?f7re`|G=_57Eu}hdW9N78=;-|81aB{+ zi|ea5mp?~uFcDF`tXAun@kT{ZBEl*!(j`Q>n|!!_AKi{8*LSxUWLqO8P{({5KATVq%-S4 z(7I@=4@4;PpVjY%o@xC1NH;t?;HQ zL=~^rvTW2m7MrxX2OkM#G;47|uKT7aS8V5Ly+5e3ElSZ;=lh zrpDT7z9_4g;H zSm^j^yBjNPF!Lqgy7p z&R?@rgI|xB^q8Oi>hVibRh8+CW0SmQhu>?5;4;~x8gfP%tuQNMDdzDV)$Ty>-n_?n z*I$WTZ586$=ir%U!USL7urBLdnwjk%kHZZSw5A+}EaFVTP4?*Gt?#jz#q)ezk_v z&(bWdw&H~HXwQqJ9_AotvHdeJ3#!KWzJPomG+N z<*>m$f^Rp#yAqQn4ssY`+gG$LhP{_P2Sivk4h|GA2r2dcv&mEym({mT$FqqShc)pe z`LftQ0-sq0*}hJ4h{&$Z2BGt`n>=plH97vlDV$(J49aySkW$Bl*a*dRT%|>Gy;Z6d zDh6!88tZpA;w|9YQ14q7$%V*zq3i>U(Z<~OqZm21F7sAXfCt(Z&c0Sji{~Tm%hdJioURHa0|95Zr}jhVluvRN+2=yBi}IRLWKH zDEHF4?A^4o%ZIUgv04EHhP_6~9ySf=Lw}44Lv;!%w^a`i&C|1&FMm+@kMMoiyn<)!$uG@A2h}*fgPBP>Oxfk@3a#gGpJ>apK1cxY zFs}w4a)|X_@53^*C_U)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