Skip to content

Commit

Permalink
feat(appconfig): constrain environments to a single deployment at a t…
Browse files Browse the repository at this point in the history
…ime (#29500)

### Issue # (if applicable)

Closes #29345.

### Reason for this change

The current L2 AppConfig constructs do not have any guardrails 
that prevent simultaneous Deployments to a single Environment. 
This is not allowed, and will result in Cfn deploy-time conflicts.

### Description of changes

This commit adds a pair of new public methods to IEnvironment that 
enable the addition of a new Deployment for a given IConfiguration.

It then updates the creation of new Deployments in ConfigurationBase 
to utilize these new methods instead of the current resource creation.

These new methods interact with an internal queue. 
This queue creates a chain of Cfn dependencies between Deployments 
in order to enforce that only a single Deployment can be in progress 
for the Environment at any given time.

### Description of how you validated changes

Added new unit and integ test coverage.  
Deployed the new integ test without these changes and confirmed that Cfn failed at deployment time. 

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
M-Hawkins committed Apr 19, 2024
1 parent 99041b2 commit 3dd834d
Show file tree
Hide file tree
Showing 13 changed files with 1,224 additions and 16 deletions.

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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"Resources": {
"MyApplicationForEnv1F597ED9": {
"Type": "AWS::AppConfig::Application",
"Properties": {
"Name": "awsappconfigmulticonfigenv-MyApplicationForEnv-1EE3EA95"
}
},
"MultiConfigEnvironment5F41B747": {
"Type": "AWS::AppConfig::Environment",
"Properties": {
"ApplicationId": {
"Ref": "MyApplicationForEnv1F597ED9"
},
"Name": "awsappconfigmulticonfigenv-MultiConfigEnvironment-59525230"
}
},
"QuickDeploymentStrategy980252EC": {
"Type": "AWS::AppConfig::DeploymentStrategy",
"Properties": {
"DeploymentDurationInMinutes": 1,
"GrowthFactor": 50,
"GrowthType": "LINEAR",
"Name": "awsappconfigmulticonfigenv-QuickDeploymentStrategy-CAB72574",
"ReplicateTo": "NONE"
}
},
"MyFirstConfigConfigurationProfileAB11F87A": {
"Type": "AWS::AppConfig::ConfigurationProfile",
"Properties": {
"ApplicationId": {
"Ref": "MyApplicationForEnv1F597ED9"
},
"LocationUri": "hosted",
"Name": "awsappconfigmulticonfigenv-MyFirstConfig-2FF7CAAB"
}
},
"MyFirstConfig117AFBAC": {
"Type": "AWS::AppConfig::HostedConfigurationVersion",
"Properties": {
"ApplicationId": {
"Ref": "MyApplicationForEnv1F597ED9"
},
"ConfigurationProfileId": {
"Ref": "MyFirstConfigConfigurationProfileAB11F87A"
},
"Content": "first config content",
"ContentType": "application/octet-stream"
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"MyFirstConfigDeployment5AEBAD52B8EE4": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
"Ref": "MyApplicationForEnv1F597ED9"
},
"ConfigurationProfileId": {
"Ref": "MyFirstConfigConfigurationProfileAB11F87A"
},
"ConfigurationVersion": {
"Ref": "MyFirstConfig117AFBAC"
},
"DeploymentStrategyId": {
"Ref": "QuickDeploymentStrategy980252EC"
},
"EnvironmentId": {
"Ref": "MultiConfigEnvironment5F41B747"
}
}
},
"MySecondConfigConfigurationProfileD0CC1BAA": {
"Type": "AWS::AppConfig::ConfigurationProfile",
"Properties": {
"ApplicationId": {
"Ref": "MyApplicationForEnv1F597ED9"
},
"LocationUri": "hosted",
"Name": "awsappconfigmulticonfigenv-MySecondConfig-4F837809"
}
},
"MySecondConfig28DEBAC4": {
"Type": "AWS::AppConfig::HostedConfigurationVersion",
"Properties": {
"ApplicationId": {
"Ref": "MyApplicationForEnv1F597ED9"
},
"ConfigurationProfileId": {
"Ref": "MySecondConfigConfigurationProfileD0CC1BAA"
},
"Content": "second config content",
"ContentType": "application/octet-stream"
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"MySecondConfigDeployment5AEBAD1470BE4": {
"Type": "AWS::AppConfig::Deployment",
"Properties": {
"ApplicationId": {
"Ref": "MyApplicationForEnv1F597ED9"
},
"ConfigurationProfileId": {
"Ref": "MySecondConfigConfigurationProfileD0CC1BAA"
},
"ConfigurationVersion": {
"Ref": "MySecondConfig28DEBAC4"
},
"DeploymentStrategyId": {
"Ref": "QuickDeploymentStrategy980252EC"
},
"EnvironmentId": {
"Ref": "MultiConfigEnvironment5F41B747"
}
},
"DependsOn": [
"MyFirstConfigDeployment5AEBAD52B8EE4"
]
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}

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.

0 comments on commit 3dd834d

Please sign in to comment.