ECS-native blue/green
Configured via
deployment_configuration.strategy = "BLUE_GREEN". Managed entirely by ECS without CodeDeploy. Simpler to set up.CodeDeploy blue/green
Uses
ignore_task_definition_changes = true and an external aws_codedeploy_deployment_group. Required when CodeDeploy manages the deployment lifecycle.ECS-native blue/green
Thefargate example uses the ECS-native blue/green strategy with two ALB target groups:
CodeDeploy blue/green
For CodeDeploy-managed deployments, ECS hands off the deployment lifecycle to CodeDeploy. In this model, CodeDeploy (not Terraform) updates the service’s task definition and load balancer configuration during each deploy.The role of ignore_task_definition_changes
Set ignore_task_definition_changes = true to instruct the module to ignore changes to the service’s task_definition and load_balancer arguments. This is required because:
- CodeDeploy changes the task definition during each deployment to point to the new image.
- CodeDeploy shifts the load balancer from the blue target group to the green target group.
terraform apply.
Complete CodeDeploy example
Traffic shifting strategies
Thedeployment_config_name in the aws_codedeploy_deployment_group controls how traffic shifts:
You can also define a custom deployment configuration with finer control over step percentages and bake times.
Canary deployments (EC2 capacity)
Theec2-autoscaling example demonstrates a canary strategy using the ECS-native deployment configuration:

