feat(ecs): add built-in Linear and Canary deployments #35981
feat(ecs): add built-in Linear and Canary deployments #35981mergify[bot] merged 15 commits intoaws:mainfrom
Conversation
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
kg-aws
left a comment
There was a problem hiding this comment.
Thank you for the contribution. I have added my opinion to how we can implement this features in CDK L2 construct.
| */ | ||
| readonly canaryBakeTime?: Duration; | ||
| } | ||
|
|
There was a problem hiding this comment.
Given how similar these two interfaces are we can combine them in to single interface as following.
/**
* Configuration for ECS service deployments (linear and canary)
*/
export interface TrafficShiftConfig {
/**
* The percentage of traffic to shift
* @minimum 0.1 for canary, 3 for linear
* @maximum 100
*/
readonly stepPercent: number;
/**
* The number of minutes to wait between each step
* @minimum 0
* @maximum 1440
*/
readonly stepBakeTime: Duration;
}
| canaryConfiguration: props.canaryConfiguration ? { | ||
| canaryPercent: props.canaryConfiguration.canaryPercent, | ||
| canaryBakeTimeInMinutes: props.canaryConfiguration.canaryBakeTime?.toMinutes(), | ||
| } : undefined, |
There was a problem hiding this comment.
Instead of setting values directly in the constructor, we can add methods that automatically configure the strategy along with the provided config. This way, existing users would only need to call these methods without modifying the constructor.
public configureLinearDeployment(config: TrafficShiftConfig): void {
if (!this.isEcsDeploymentController) {
throw new ValidationError('Linear configuration requires the ECS deployment controller.', this);
}
this.validateLinearConfiguration(config);
// Update the deployment configuration with linear settings and set strategy to LINEAR
const currentConfig = this.resource.deploymentConfiguration || {};
this.resource.deploymentConfiguration = {
...currentConfig,
strategy: DeploymentStrategy.LINEAR,
linearConfiguration: {
stepPercent: config.stepPercent,
stepBakeTimeInMinutes: config.stepBakeTime.toMinutes(),
},
};
}
public configureCanaryDeployment(config: TrafficShiftConfig): void {
if (!this.isEcsDeploymentController) {
throw new ValidationError('Canary configuration requires the ECS deployment controller.', this);
}
this.validateCanaryConfiguration(config);
// Update the deployment configuration with canary settings and set strategy to CANARY
const currentConfig = this.resource.deploymentConfiguration || {};
this.resource.deploymentConfiguration = {
...currentConfig,
strategy: DeploymentStrategy.CANARY,
canaryConfiguration: {
canaryPercent: config.stepPercent,
canaryBakeTimeInMinutes: config.stepBakeTime.toMinutes(),
},
};
}
|
Thanks. I've updated. |
badmintoncryer
left a comment
There was a problem hiding this comment.
Thanks! I've added a minor comment.
| } | ||
|
|
||
| if (config.stepBakeTime !== undefined && !Token.isUnresolved(config.stepBakeTime)) { | ||
| const minutes = config.stepBakeTime.toMinutes(); |
There was a problem hiding this comment.
It might be better to consider the case that stepBakeTime is set less than a minute such as 10 seconds.
I think this condition causes synth error.
There was a problem hiding this comment.
Thanks.
I've added a validation.
85ae667 to
be9b40e
Compare
345127a to
0b245dc
Compare
9e97232 to
baf67dd
Compare
.../@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.linear-deployment-strategy.ts
Show resolved
Hide resolved
Pull request has been modified.
leonmk-aws
left a comment
There was a problem hiding this comment.
Thank you for your contribution !
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Merge Queue Status✅ The pull request has been merged at e8afe59 This pull request spent 44 minutes 58 seconds in the queue, including 29 minutes 12 seconds running CI. Required conditions to merge
|
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #35986
Closes #35987
Reason for this change
Add new built-in Linear and Canary deployment strategies for ECS services to enable progressive and controlled production deployments.
Ref: Amazon ECS now supports built-in Linear and Canary deployments
Description of changes
CanaryConfigurationandLinearConfigurationinterfaces toBaseServiceOptionsDeploymentStrategyenum withLINEARandCANARYvaluesDescribe any new or updated permissions being added
N/A
Description of how you validated changes
Add unit tests and integ tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license