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

feat(appconfig): add deploy method to configuration constructs #28174

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5f1030b
feat(appconfig): add deploy method to configuration constructs
chenjane-dev Nov 28, 2023
9b1e2c8
Update packages/@aws-cdk/aws-appconfig-alpha/README.md
chenjane-dev Nov 30, 2023
540b3c4
Add unit tests
chenjane-dev Nov 30, 2023
2c37eb7
Refactor deployment code to common method
chenjane-dev Dec 1, 2023
38c3adf
chore(apigatewayv2-integrations-alpha): turn on awslint (#28173)
sumupitchayan Nov 28, 2023
147420e
chore(codebuild): added validation when using Windows Image (#27946)
sakurai-ryo Nov 28, 2023
80be312
chore(dynamodb): migrate replica handler (#27798)
colifran Nov 29, 2023
1cd58e0
chore(route53): add directions for running cross account zone delegat…
colifran Nov 29, 2023
670fb61
feat(scheduler-targets-alpha): `SnsPublish` scheduler target (#27838)
ymhiroki Nov 29, 2023
4595c86
chore(core): isCfnResource allows any type as input (#28001)
tmokmss Nov 29, 2023
a069c89
chore(docs): update scheduler-targets-alpha readme (#28182)
vinayak-kukreja Nov 29, 2023
cfcbc59
chore(route53): migrate cross account zone handler (#28134)
colifran Nov 29, 2023
94be576
docs(s3): bad type definition for objectsKeyPattern parameter (#28176)
paulhcsun Nov 29, 2023
1714db2
feat(scheduler-targets): eventBridge putEvents target (#27629)
WtfJoke Nov 29, 2023
707f94a
feat(apigatewayv2): graduate to stable 🚀 (#28094)
sumupitchayan Nov 29, 2023
55a1511
fix(cli): IAM Policy changes not deploying with --hotswap-fallback (#…
mrgrain Nov 30, 2023
df9c622
fix(cli-lib): deploy fails with "no such file or directory, open 'nod…
mrgrain Nov 30, 2023
d045bd7
feat(scheduler-targets-alpha): `InspectorStartAssessmentRun` Target (…
go-to-k Nov 30, 2023
f3a7744
feat(ecs): add instance warmup period prop (#28194)
msambol Nov 30, 2023
67d9d27
chore: update Contributors File (#28210)
aws-cdk-automation Dec 1, 2023
0d5ea8e
chore(release): 2.112.0
Dec 1, 2023
a822559
chore: fixup changelog to mention graduation of supporting apigateway…
mrgrain Dec 1, 2023
185d1e8
feat(msk-alpha): MSK Kafka versions 2.8.2.tiered and 3.5.1 and Storag…
chrispidcock Dec 1, 2023
9bacdfc
chore: add changelog items that were missed during the 2.122.0 releas…
mrgrain Dec 1, 2023
dd59233
feat: update AWS Service Spec (#28222)
aws-cdk-automation Dec 1, 2023
fb64d5b
chore(release): 2.113.0
Dec 1, 2023
fa2481a
chore(spec2cdk): remove temporary patch schema aws-logs-loggroup.json…
mikewrighton Dec 1, 2023
09d882c
chore(codebuild): fix formatting errors (#28226)
kaizencc Dec 1, 2023
d36092f
chore(redshift-alpha): formatting typos (#28224)
kaizencc Dec 1, 2023
9cb2b9f
chore(deps): Bump tj-actions/changed-files from 40.2.0 to 40.2.1 (#28…
dependabot[bot] Dec 4, 2023
19ec804
feat(scheduler-targets-alpha): `KinesisStreamPutRecord` Target (#27845)
go-to-k Dec 4, 2023
02990fd
chore(apigateway): improve docs and default value settings for identi…
go-to-k Dec 4, 2023
d13557f
fix(apigatewayv2): export newly graduated apigatewayv2 modules (#28250)
jgreenbow Dec 4, 2023
995beb1
feat(appconfig-alpha): support for relative file paths when importing…
chenjane-dev Dec 5, 2023
9aa0377
fix(iam): attaching a policy is not idempotent with imported resource…
lpizzinidev Dec 5, 2023
37cac37
feat(appconfig-alpha): support for composite alarms (#28156)
chenjane-dev Dec 5, 2023
a85e058
feat(rds): grantConnect method enables iam auth to rds cluster (#28118)
corymhall Dec 5, 2023
b2e1c89
fix(apigateway): move url property to RestApiBase (#27742)
hariprakash-j Dec 5, 2023
9482952
fix(stepfunctions-tasks): mwaa service generates wrong action in role…
tam0ri Dec 5, 2023
562ce9b
feat(scheduler-targets-alpha): `KinesisDataFirehosePutRecord` Target …
go-to-k Dec 5, 2023
8ea14d9
chore(kms): prefer new `aliasArn` to `keyArn` for getting arn of an a…
rafaelrcamargo Dec 5, 2023
93ddf2b
feat: update AWS Service Spec (#28259)
aws-cdk-automation Dec 5, 2023
03e3684
feat(appconfig): add deploy method to configuration constructs
chenjane-dev Nov 28, 2023
ce5244e
Fix merge conflicts
chenjane-dev Dec 5, 2023
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
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-appconfig-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', {
});
```

To deploy a configuration to an environment after initialization use the `deployTo` method:

```ts
declare const application: appconfig.Application;
declare const env: appconfig.Environment;

const config = new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', {
application,
content: appconfig.ConfigurationContent.fromInlineText('This is my configuration content.'),
});

config.deploy(env);
```

### SourcedConfiguration

A sourced configuration represents configuration stored in an Amazon S3 bucket, AWS Secrets Manager secret, Systems Manager
Expand Down
33 changes: 23 additions & 10 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE
this.extensible.addExtension(extension);
}

/**
* Deploys the configuration to the specified environment.
*
* @param environment The environment to deploy the configuration to
*/
public deploy(environment: IEnvironment) {
Copy link
Contributor

@lpizzinidev lpizzinidev Nov 30, 2023

Choose a reason for hiding this comment

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

I think we should use this function to create the deployment in deployConfigToEnvironments as well to avoid code repetitions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm yeah I had this change, but it wouldn't allow this naming convention because the deployTo object already exists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't see the edit on the comment above. deployConfigToEnvironments has different behavior and shouldn't be used here. I can however create another method to reference to avoid the duplicate code.

this.createDeployment(environment);
}

protected addExistingEnvironmentsToApplication() {
this.deployTo?.forEach((environment) => {
if (!this.application.environments.includes(environment)) {
Expand All @@ -319,16 +328,20 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE
if ((this.deployTo && !this.deployTo.includes(environment))) {
return;
}
const logicalId = `Deployment${this.getDeploymentHash(environment)}`;
new CfnDeployment(this, logicalId, {
applicationId: this.application.applicationId,
configurationProfileId: this.configurationProfileId,
deploymentStrategyId: this.deploymentStrategy!.deploymentStrategyId,
environmentId: environment.environmentId,
configurationVersion: this.versionNumber!,
description: this.description,
kmsKeyIdentifier: this.deploymentKey?.keyArn,
});
this.createDeployment(environment);
});
}

private createDeployment(environment: IEnvironment) {
const logicalId = `Deployment${this.getDeploymentHash(environment)}`;
new CfnDeployment(this, logicalId, {
applicationId: this.application.applicationId,
configurationProfileId: this.configurationProfileId,
deploymentStrategyId: this.deploymentStrategy!.deploymentStrategyId,
environmentId: environment.environmentId,
configurationVersion: this.versionNumber!,
description: this.description,
kmsKeyIdentifier: this.deploymentKey?.keyArn,
});
}
}
Expand Down
115 changes: 115 additions & 0 deletions packages/@aws-cdk/aws-appconfig-alpha/test/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,121 @@ describe('configuration', () => {
Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 1);
});

test('configuration using deploy method and no environment associated', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
});
app.addEnvironment('MyEnv1');
const env = app.addEnvironment('MyEnv2');
const config = new HostedConfiguration(stack, 'MyHostedConfig', {
content: ConfigurationContent.fromInlineText('This is my content'),
application: app,
deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
rolloutStrategy: RolloutStrategy.linear({
growthFactor: 15,
deploymentDuration: cdk.Duration.minutes(30),
}),
}),
});
config.deploy(env);

Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Deployment', {
ApplicationId: {
Ref: 'MyAppConfigB4B63E75',
},
EnvironmentId: {
Ref: 'MyAppConfigMyEnv2350437D6',
},
ConfigurationVersion: {
Ref: 'MyHostedConfig51D3877D',
},
ConfigurationProfileId: {
Ref: 'MyHostedConfigConfigurationProfile2E1A2BBC',
},
DeploymentStrategyId: {
Ref: 'MyDeploymentStrategy60D31FB0',
},
});
Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 1);
});

test('configuration using deploy method with environment associated', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
});
const env1 = app.addEnvironment('MyEnv1');
const env2 = app.addEnvironment('MyEnv2');
const config = new HostedConfiguration(stack, 'MyHostedConfig', {
content: ConfigurationContent.fromInlineText('This is my content'),
application: app,
deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
rolloutStrategy: RolloutStrategy.linear({
growthFactor: 15,
deploymentDuration: cdk.Duration.minutes(30),
}),
}),
deployTo: [env1],
});
config.deploy(env2);

Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Deployment', {
ApplicationId: {
Ref: 'MyAppConfigB4B63E75',
},
EnvironmentId: {
Ref: 'MyAppConfigMyEnv1B9120FA1',
},
ConfigurationVersion: {
Ref: 'MyHostedConfig51D3877D',
},
ConfigurationProfileId: {
Ref: 'MyHostedConfigConfigurationProfile2E1A2BBC',
},
DeploymentStrategyId: {
Ref: 'MyDeploymentStrategy60D31FB0',
},
});
Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Deployment', {
ApplicationId: {
Ref: 'MyAppConfigB4B63E75',
},
EnvironmentId: {
Ref: 'MyAppConfigMyEnv2350437D6',
},
ConfigurationVersion: {
Ref: 'MyHostedConfig51D3877D',
},
ConfigurationProfileId: {
Ref: 'MyHostedConfigConfigurationProfile2E1A2BBC',
},
DeploymentStrategyId: {
Ref: 'MyDeploymentStrategy60D31FB0',
},
});
Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 2);
});

test('configuration with no environment associated and no deploy method used', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
});
new HostedConfiguration(stack, 'MyHostedConfig', {
content: ConfigurationContent.fromInlineText('This is my content'),
application: app,
deploymentStrategy: new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
rolloutStrategy: RolloutStrategy.linear({
growthFactor: 15,
deploymentDuration: cdk.Duration.minutes(30),
}),
}),
});

Template.fromStack(stack).resourceCountIs('AWS::AppConfig::Deployment', 0);
});

test('configuration with two configurations specified', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
Expand Down
Binary file not shown.

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

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 @@ -33,6 +33,15 @@
"Name": "awsappconfigconfiguration-MyAppConfig-HostedEnvFromYaml-BB2C802A"
}
},
"MyAppConfigEnvDeployLater26FA1032": {
"Type": "AWS::AppConfig::Environment",
"Properties": {
"ApplicationId": {
"Ref": "MyAppConfigB4B63E75"
},
"Name": "awsappconfigconfiguration-MyAppConfig-EnvDeployLater-91038922"
}
},
"MyAppConfigParameterEnvD769FB19": {
"Type": "AWS::AppConfig::Environment",
"Properties": {
Expand Down Expand Up @@ -184,6 +193,26 @@
}
}
},
"MyHostedConfigFromJsonDeploymentEFECDBC4087F1": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
"Ref": "MyAppConfigB4B63E75"
},
"ConfigurationProfileId": {
"Ref": "MyHostedConfigFromJsonConfigurationProfile863E1E42"
},
"ConfigurationVersion": {
"Ref": "MyHostedConfigFromJsonD8CF9BE4"
},
"DeploymentStrategyId": {
"Ref": "MyDeployStrategy062CAEA2"
},
"EnvironmentId": {
"Ref": "MyAppConfigEnvDeployLater26FA1032"
}
}
},
"MyHostedConfigFromYamlConfigurationProfile7C77A435": {
"Type": "AWS::AppConfig::ConfigurationProfile",
"Properties": {
Expand Down Expand Up @@ -565,7 +594,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "e2277687077a2abf9ae1af1cc9565e6715e2ebb62f79ec53aa75a1af9298f642.zip"
"S3Key": "3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3.zip"
},
"Description": "/opt/awscli/aws"
}
Expand Down Expand Up @@ -736,7 +765,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "9eb41a5505d37607ac419321497a4f8c21cf0ee1f9b4a6b29aa04301aea5c7fd.zip"
"S3Key": "e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00.zip"
},
"Environment": {
"Variables": {
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.

Loading
Loading