Skip to content

Commit

Permalink
feat(ecs): enable alarm-based rollbacks (#25840)
Browse files Browse the repository at this point in the history
This PR enables the new Deployment Alarms feature in ECS for Service L2s [blog post](https://aws.amazon.com/blogs/containers/automate-rollbacks-for-amazon-ecs-rolling-deployments-with-cloudwatch-alarms/).

This PR contains changes after the first round of revision by the CDK team. 

Continuation of #25346

**Why are so many integration tests impacted by this change? There are 2 reasons:**
1. This PR changes the ECS L2s to set the default configuration for the `CfnService.deploymentConfiguration.alarms` property to:
```
alarmNames: [],
rollback: false,
enable: false,
```
This is necessary, because adding deployment alarms, deploying your CFN stack, then removing the deployment alarms from the CFN template, and deploying again WILL NOT remove the deployment alarms from the service. To remove previously configured deployment alarms, you must explicitly use the configuration shown above. Making this update will cause no interruption to existing ECS services, and does not trigger any update to the service itself during the CFN update.

The ECS UpdateService API is stateful, meaning that if a field is not present in the CloudFormation object, it will be ignored in the update. This was originally implemented due to the problems with desiredCount resetting to bad values after autoscaling changed it, but requires us to set an explicit disableDeploymentAlarms() method to cause the service update to behave correctly.

2. Most ECS integ tests have not been executed in a long time. So, many of the changes are bring the snapshots up to date with the latest integ test format, or lambda layers, etc.


**Detailed list of changes:**
- entire alarm based rollback task into single commit
- resolving merge conflicts
- integ files modules updated to resolve merge conflicts
- regarding merge conflicts issue
- integ files import changes for merge conflicts
- adding this change for PR not to abondended
- chore: refactor createAlarm & remove unnecessary unit tests
- chore: fix api but failing unit tests
- chore: fix validation
- chore: readme changes
- chore: fix integ test, remove unnecessary ec2 test
- chore: refactor enableAlarms for clarity
- test: fix integ test, finally
- docs: update docstrings for new props and methods

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
bvtujo committed Jul 5, 2023
1 parent 3a1837a commit 1a44f69
Show file tree
Hide file tree
Showing 305 changed files with 40,893 additions and 5,353 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "32.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "21.0.0",
"version": "32.0.0",
"files": {
"8058932a68b7558432685502c7b88e62d0ce087e3a6648b189ef5cda358e4f75": {
"146a3a0178544a80f025b470e820a77ec783a43b2a5ae0a2590037423ed16a6b": {
"source": {
"path": "aws-cdk-codedeploy-ecs-dg.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "8058932a68b7558432685502c7b88e62d0ce087e3a6648b189ef5cda358e4f75.json",
"objectKey": "146a3a0178544a80f025b470e820a77ec783a43b2a5ae0a2590037423ed16a6b.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@
"Ref": "EcsCluster97242B84"
},
"DeploymentConfiguration": {
"Alarms": {
"AlarmNames": [],
"Enable": false,
"Rollback": false
},
"MaximumPercent": 200,
"MinimumHealthyPercent": 50
},
Expand Down Expand Up @@ -1091,15 +1096,6 @@
}
}
},
"BlueGreenDGApplication3649479D": {
"Type": "AWS::CodeDeploy::Application",
"Properties": {
"ComputePlatform": "ECS"
},
"DependsOn": [
"CanaryConfig039778DD"
]
},
"BlueGreenDGServiceRole33E3BCAC": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -1134,6 +1130,15 @@
"CanaryConfig039778DD"
]
},
"BlueGreenDGApplication3649479D": {
"Type": "AWS::CodeDeploy::Application",
"Properties": {
"ComputePlatform": "ECS"
},
"DependsOn": [
"CanaryConfig039778DD"
]
},
"BlueGreenDG373AB9B0": {
"Type": "AWS::CodeDeploy::DeploymentGroup",
"Properties": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"21.0.0"}
{"version":"32.0.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "32.0.0",
"testCases": {
"EcsDeploymentGroupTest/DefaultTest": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "32.0.0",
"artifacts": {
"aws-cdk-codedeploy-ecs-dg.assets": {
"type": "cdk:asset-manifest",
Expand All @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/8058932a68b7558432685502c7b88e62d0ce087e3a6648b189ef5cda358e4f75.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/146a3a0178544a80f025b470e820a77ec783a43b2a5ae0a2590037423ed16a6b.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -291,16 +291,16 @@
"data": "CanaryConfig039778DD"
}
],
"/aws-cdk-codedeploy-ecs-dg/BlueGreenDG/Application/Resource": [
"/aws-cdk-codedeploy-ecs-dg/BlueGreenDG/ServiceRole/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "BlueGreenDGApplication3649479D"
"data": "BlueGreenDGServiceRole33E3BCAC"
}
],
"/aws-cdk-codedeploy-ecs-dg/BlueGreenDG/ServiceRole/Resource": [
"/aws-cdk-codedeploy-ecs-dg/BlueGreenDG/Application/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "BlueGreenDGServiceRole33E3BCAC"
"data": "BlueGreenDGApplication3649479D"
}
],
"/aws-cdk-codedeploy-ecs-dg/BlueGreenDG/Resource": [
Expand Down
Loading

0 comments on commit 1a44f69

Please sign in to comment.