ecs: Add ability to export target group created by FargateService (EC2Service etc..)
Describe the feature
An option to export target group from FargateService. Needed for CodeDeploy ECS blue green deployment
Use Case
I'm having trouble when create CodeDeploy EcsDeploymentGroup, it needs to specify 2 target groups for deployment config.
One of them is a secondary target group, which could be created by new lines of code. But one of them should be a target group that was created by FargateService. Currently there is no option to export the target group FargateService created.
Proposed Solution
Maybe we can do this could be via property or method
const service = new cdk.aws_ecs.FargateService(this, 'fargate-cluster', {
cluster: this.cluster,
taskDefinition: taskDefinition,
serviceName: "fargate-service-ex",
deploymentController: {
type: cdk.aws_ecs.DeploymentControllerType.CODE_DEPLOY,
},
});
const ecsDeployGroup = new cdk.aws_codedeploy.EcsDeploymentGroup(this, 'blueGreenDG', {
service: service,
blueGreenDeploymentConfig: {
blueTargetGroup: service.targetgroup, //Or service.targetgroup(), need ITargetGroup return
greenTargetGroup: secondaryTargetGroup,
listener: httpsListener,
},
deploymentConfig: cdk.aws_codedeploy.EcsDeploymentConfig.ALL_AT_ONCE,
});
Other Information
I know we can get target group of service if using ApplicationLoadBalancedFargateService. Since ApplicationLoadBalancedFargateService doesn't have priority option. Which is important to some cases Can we do it with FargateService as well ?
Acknowledgements
- [ ] I may be able to implement this feature request
- [X] This feature might incur a breaking change
CDK version used
2.103.1
Environment details (OS name and version, etc.)
MacOS
Looks like you need to provide a elbv2.ITargetGroup but looking at the FargateService, does it always come with a target group?
@pahud yes, sorry about that. addTargets() do return TargetGroup so I am able to config CodeDeploy now.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.