-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(ecs-patterns): add blue/green deployment support for application load balanced services #35505
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
base: main
Are you sure you want to change the base?
Conversation
Closes aws#35467. ### Reason for this change AWS CDK users need a high-level API to configure blue/green deployments for ApplicationLoadBalanced ECS patterns. Currently, users must manually configure low-level ECS service properties and alternate target groups, which is complex and error-prone. This feature request adds blue/green deployment support directly to the ECS patterns API, making it accessible through a simple, declarative interface. ### Description of changes Added optional blue/green deployment configuration to ApplicationLoadBalanced ECS patterns: - **New Interface**: `BlueGreenDeploymentConfiguration` interface with properties for alternate target group, production listener, optional test listener, and optional IAM role - **Extended Props**: Added optional `blueGreenDeployment` property to `ApplicationLoadBalancedServiceBaseProps` interface - **Enhanced Service Target**: Modified `addServiceAsTarget()` method to create `AlternateTarget` configuration when blue/green properties are specified - **CloudFormation Integration**: Generates `AdvancedConfiguration` in ECS Service LoadBalancers array with proper alternate target group and listener rule references - **Backward Compatibility**: All changes are additive and optional - existing applications continue to work unchanged The implementation leverages existing `AlternateTarget` infrastructure from the aws-ecs module, providing a clean separation between high-level pattern configuration and low-level ECS service setup. ### Describe any new or updated permissions being added N/A - No new IAM permissions are introduced. The feature leverages existing IAM role creation and managed policies from the underlying `AlternateTarget` class in the aws-ecs module. ### Description of how you validated changes - **Unit tests**: Added 4 comprehensive unit tests covering all blue/green deployment scenarios: - Basic blue/green configuration with production listener only - Blue/green configuration with both production and test listeners - Blue/green configuration with custom IAM role - Backward compatibility verification (services without blue/green work unchanged) - **Integration tests**: Leverages existing aws-ecs integration tests for `AlternateTarget` functionality - **CloudFormation validation**: Tests verify that `AdvancedConfiguration` is properly generated in ECS Service LoadBalancers with correct alternate target group ARN, role ARN, and listener rule configurations - **Regression testing**: Full test suite execution (15,928/15,937 tests passing) confirms no breaking changes to existing functionality - **JSII compatibility**: Fixed and verified JSII compilation by creating separate interface instead of inline object literal type ### 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*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter fails with the following errors:
❌ Features must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed, add Clarification Request
to a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi I raised the issue for this and so was working on it also, but since you have your PR up first I guess I'll leave it and you can finish the change.
I don't know the reviewer guidelines for this module but I thought I'd add my $0.02.
ecs-patterns
is meant to be a higher level library. Updating the interface to require load balancer listener rules and a target group to be passed in seems against that idea. That is to say, if the client must set up the load balancer themselves in order to pass in the listener then this reduces the usefulness of this library over using the ecs
module directly.
I would have expected ApplicationLoadBalancedServiceBase
to handle defining the alternate target group, and the production listener rule, possibly providing optional configuration/customisation props for the library client to use, e.g., optional production listener rule conditions that would override some default like pathPatterns['/*'].
This change also does not expose any ability to configure the Blue/Green deployment strategy properties for the Service: bakeInTime
or lifecycleHooks
.
I'd also be interested in knowing if you've managed to deploy a service using this change. As while my own attempt at this has different approach in the interface, the result is quite similar and I have not managed to get it to deploy successfully yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HI @walkley, thanks for the PR. I agree entirely with @eoin-betdex's comments regarding this approach. Fundamentally, ecs-patterns is different from the rest of aws-cdk-lib, it's an L3 construct with higher level patterns that only exists in the aws-cdk-lib for legacy reasons. In fact, at some point the ecs service team wanted users to migrate to a version of ecs-patterns outside of the aws-cdk-lib: https://github.com/cdklabs/cdk-ecs-service-extensions. I'm not sure how that's going in practice however :).
Since this is a submodule for L3 patterns for ecs, I think more design is necessary to nail down an incredible user experience. From a technical standpoint, there definitely needs to be an integ test to ensure that everything deploys propery.
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. Note that PRs with failing linting check or builds are not reviewed, please ensure your build is passing To prevent automatic closure:
This PR will automatically close in 14 days if no action is taken. |
Closes #35467.
Reason for this change
AWS CDK users need a high-level API to configure blue/green deployments for ApplicationLoadBalanced ECS patterns. Currently, users must manually configure low-level ECS service properties and alternate target groups, which is complex and error-prone. This feature request adds blue/green deployment support directly to the ECS patterns API, making it accessible through a simple, declarative interface.
Description of changes
Added optional blue/green deployment configuration to ApplicationLoadBalanced ECS patterns:
BlueGreenDeploymentConfiguration
interface with properties for alternate target group, production listener, optional test listener, and optional IAM roleblueGreenDeployment
property toApplicationLoadBalancedServiceBaseProps
interfaceaddServiceAsTarget()
method to createAlternateTarget
configuration when blue/green properties are specifiedAdvancedConfiguration
in ECS Service LoadBalancers array with proper alternate target group and listener rule referencesThe implementation leverages existing
AlternateTarget
infrastructure from the aws-ecs module, providing a clean separation between high-level pattern configuration and low-level ECS service setup.Describe any new or updated permissions being added
N/A - No new IAM permissions are introduced. The feature leverages existing IAM role creation and managed policies from the underlying
AlternateTarget
class in the aws-ecs module.Description of how you validated changes
AlternateTarget
functionalityAdvancedConfiguration
is properly generated in ECS Service LoadBalancers with correct alternate target group ARN, role ARN, and listener rule configurationsChecklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license