Listener requirements for CodeDeploy Blue/Green Deployments

0

I would like to set up blue/green deployments for an ECS service. From the documentation it would seem that the target must be configured with the default action on each listener, but I would like more granular control over the traffic to our service using listener rules with specific conditions, so I prefer not to have the listeners default actions pointing at the service. Is there a way to use codedeploy for blue/green with specific listener rules as opposed to the default action? (I’d rather not have to implement my own blue-green deployment, but this seems like a pretty significant limitation IMO)

asked 4 months ago256 views
2 Answers
0
Accepted Answer

AWS CodeDeploy does not natively support direct integration with listener rules for routing traffic between blue/green environments. The service primarily works with the default listener action to switch traffic between target groups.

Workaround Approach:

  • Set up your ECS service with a load balancer and define your listener rules as needed. You should have two target groups: one for the blue environment and one for the green environment.
  • Deployment Process:
  1. Initially, your listener rules should direct traffic to the blue environment's target group.
  2. When you're ready to deploy the green environment, update it as needed (but don't change the listener rules yet).
  3. Once the green environment is ready and tested, manually update the listener rules to shift traffic from the blue target group to the green target group. This step does not involve CodeDeploy but is a manual process in the AWS Management Console or through the AWS CLI/API.
  • After successful traffic shifting and monitoring, decommission the old blue environment.

This approach requires manual intervention for traffic shifting, which is a deviation from the fully automated nature of blue/green deployments in CodeDeploy.

Alternative Solution:

Using a service mesh like Istio or AWS App Mesh can effectively address the need for granular control in blue/green deployments on ECS. A service mesh allows for precise traffic management, enabling you to route specific portions of traffic to different service versions. This approach is beneficial for blue/green deployments as it allows automated and controlled traffic shifting between the old (blue) and new (green) versions, with enhanced monitoring capabilities. While implementing a service mesh can add complexity to your system, it offers a robust solution for advanced deployment strategies without needing to manually adjust load balancer listener rules.

Let me know if you have any further questions to discuss.

Best regards!

Mina


edit: removed email address - Zack M

profile picture
EXPERT
answered 4 months ago
profile picture
EXPERT
reviewed 4 months ago
profile pictureAWS
EXPERT
reviewed 4 months ago
  • Thanks for confirming. So we essentially would have to re-implement blue-green deployments using the traffic switching capabilities of the LB. I found this project that operates along those lines, presumably it pre-dates CodeDeploy support for blue-green deployments on ECS: https://github.com/aws-samples/ecs-blue-green-deployment/blob/fargate/scripts/blue_green_flip.py I’m not familiar with App Mesh. I’ll look into it. We’re aiming to keep things simple, so probably we’ll look at other routing options.

0

Hello.

What is the default listener rule?
Are you referring to the port 80 listener rule?
ECS Blue/Green deployment creates two target groups and CodeDeploy switches between them to replace the old and new environments.
Therefore, it is possible to deploy by selecting a non-default listener associated with the target group using CodeDeploy.
https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-groups-create-ecs.html
https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-groups-create-load-balancer-for-ecs.html

profile picture
EXPERT
answered 4 months ago
  • sorry, I meant the default action on the listener. I updated my question.

  • I am selecting a listener to flow traffic with the settings mentioned in the document I shared below. I think it would be a good idea to select a listener other than the default in this setting. https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-groups-create-ecs.html

    From Production listener port, choose the port and protocol for the listener that serves production traffic to your Amazon ECS service.

  • Thank you. But it is still using the default action on the listener. I had hoped to limit traffic by host or path match in the LB using listener rules/conditions

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions