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(appconfig): deployment recreated on every cdk deployment #28782

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { IApplication } from './application';
import { DeploymentStrategy, IDeploymentStrategy, RolloutStrategy } from './deployment-strategy';
import { IEnvironment } from './environment';
import { ActionPoint, IEventDestination, ExtensionOptions, IExtension, IExtensible, ExtensibleBase } from './extension';
import { getHash } from './private/hash';

/**
* Options for the Configuration construct
Expand Down Expand Up @@ -203,8 +202,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.
Expand Down Expand Up @@ -309,8 +306,7 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE
* @param environment The environment to deploy the configuration to
*/
public deploy(environment: IEnvironment) {
const logicalId = `Deployment${this.getDeploymentHash(environment)}`;
new CfnDeployment(this, logicalId, {
new CfnDeployment(this, `Deployment${environment.name!}`, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! One small change - can we hash the environment name instead of appending the name itself to the logical id? This might look better for reading the logical id's in the template.

new CfnDeployment(this, `Deployment${getHash(environment.name!)}`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense, updated!

applicationId: this.application.applicationId,
configurationProfileId: this.configurationProfileId,
deploymentStrategyId: this.deploymentStrategy!.deploymentStrategyId,
Expand Down Expand Up @@ -482,16 +478,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);
}
}

/**
Expand Down Expand Up @@ -623,17 +609,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,
Expand Down
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"MyHostedConfigDeploymentE4742E8E64DF4": {
"MyHostedConfigDeploymentawsappconfigconfigurationMyAppConfigHostedEnvD1EED3BE0F97C0D3": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
Expand Down Expand Up @@ -213,7 +213,7 @@
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"MyHostedConfigFromJsonDeploymentCD82E3049E374": {
"MyHostedConfigFromJsonDeploymentawsappconfigconfigurationMyAppConfigHostedEnvFromJson140D2DDD244BF117": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
Expand All @@ -233,7 +233,7 @@
}
}
},
"MyHostedConfigFromJsonDeploymentEFECDBC4087F1": {
"MyHostedConfigFromJsonDeploymentawsappconfigconfigurationMyAppConfigEnvDeployLater91038922BE3B2B72": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
Expand Down Expand Up @@ -278,7 +278,7 @@
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"MyHostedConfigFromYamlDeploymentFE9624CBE5FC6": {
"MyHostedConfigFromYamlDeploymentawsappconfigconfigurationMyAppConfigHostedEnvFromYamlBB2C802A4CD2FE75": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
Expand Down Expand Up @@ -472,7 +472,7 @@
]
}
},
"MyConfigFromParameterDeployment0C84B4B3BAD6B": {
"MyConfigFromParameterDeploymentawsappconfigconfigurationMyAppConfigParameterEnv803E803A981AE384": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
Expand Down Expand Up @@ -593,7 +593,7 @@
}
}
},
"MyConfigFromDocumentDeployment1520EE7C916D3": {
"MyConfigFromDocumentDeploymentawsappconfigconfigurationMyAppConfigDocumentEnv5B0DCEC50DD481E9": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading