terraform-provider-aws: aws_codedeploy_deployment_group Blue/Green Deployment Error : InvalidAutoScalingGroupException: For ECS deployment group, autoScalingGroups can not be specified
Terraform Version
terraform --version
Terraform v0.11.11
+ provider.aws v1.52.0
+ provider.github v1.3.0
Affected Resource(s)
- aws_codedeploy_deployment_group
Terraform Configuration Files
resource "aws_codedeploy_app" "exmaple" {
compute_platform = "ECS"
name = "exmaple-fargate"
}
resource "aws_codedeploy_deployment_group" "example" {
app_name = "${aws_codedeploy_app.example.name}"
deployment_config_name = "CodeDeployDefault.ECSAllAtOnce"
deployment_group_name = "example-fargate-deployment-group"
service_role_arn = "${data.terraform_remote_state.iam.code_deploy.example_iam_arn}"
auto_rollback_configuration {
enabled = true
events = ["DEPLOYMENT_FAILURE"]
}
blue_green_deployment_config {
deployment_ready_option {
action_on_timeout = "STOP_DEPLOYMENT" # The value here was "CONTINUE_DEPLOYMENT" before I change
wait_time_in_minutes = 30 # did not set before I change
}
terminate_blue_instances_on_deployment_success {
action = "TERMINATE"
termination_wait_time_in_minutes = 30
}
}
deployment_style {
deployment_option = "WITH_TRAFFIC_CONTROL"
deployment_type = "BLUE_GREEN"
}
ecs_service {
cluster_name = "${data.terraform_remote_state.ecs.example.cluster_name}"
service_name = "${data.terraform_remote_state.ecs.example.service_name}"
}
load_balancer_info {
target_group_pair_info {
prod_traffic_route {
listener_arns = ["${data.terraform_remote_state.alb.example-alb-listener-https}"]
}
target_group {
name = "${data.terraform_remote_state.alb.example-tg-A.name}"
}
target_group {
name = "${data.terraform_remote_state.alb.example-tg-B.name}"
}
test_traffic_route {
listener_arns = ["${data.terraform_remote_state.alb.example-alb-listener-blue-green}"]
}
}
}
}
Debug Output
My debug output has lots of info that I do wanna show here. If need it, tell me and I may write example so that I can put here.
Expected Behavior
Terraform should work without any error.
Actual Behavior
When I changed with Terraform, it failed.
However, I changed the AWS Code Deploy settings from AWS console as it matches to my Terraform code and executed terraform apply it succeeded.
Steps to Reproduce
- Set up aws fargate with Blue/Green Deployment powered by AWS Code Deploy and related resources.
- Set up aws_codedeploy_deployment_group.
- action_on_timeout = “CONTINUE_DEPLOYMENT”
- Execute
terraform applyto AWS Code Deploy resources.
(in my case resources have already created)
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
- Change terraform code
- action_on_timeout = “STOP_DEPLOYMENT”
- wait_time_in_minutes = 30
- execute
terraform apply( It’ll fail )
terraform apply
(Refreshing state lines are deleted because these have info that I do not wanna show here)
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ aws_codedeploy_deployment_group.example
blue_green_deployment_config.0.deployment_ready_option.0.action_on_timeout: "CONTINUE_DEPLOYMENT" => "STOP_DEPLOYMENT"
blue_green_deployment_config.0.deployment_ready_option.0.wait_time_in_minutes: "0" => "30"
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions in workspace "dev"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_codedeploy_deployment_group.example: Modifying... (ID: 51b781fe-88dd-458d-b626-fc83cb2cff3f)
blue_green_deployment_config.0.deployment_ready_option.0.action_on_timeout: "CONTINUE_DEPLOYMENT" => "STOP_DEPLOYMENT"
blue_green_deployment_config.0.deployment_ready_option.0.wait_time_in_minutes: "0" => "30"
Error: Error applying plan:
1 error(s) occurred:
* aws_codedeploy_deployment_group.example: 1 error(s) occurred:
* aws_codedeploy_deployment_group.example: InvalidAutoScalingGroupException: For ECS deployment group, autoScalingGroups can not be specified
status code: 400, request id: a3c22ed5-168e-11e9-860d-abf465a0dc05
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
- Change AWS Code Deploy settings from AWS console as it matches to the terraform code.
- execute
terraform apply( It’ll success )
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 31
- Comments: 23 (2 by maintainers)
Commits related to this issue
- Added explicit autoscaling group empty set to try and workaround https://github.com/terraform-providers/terraform-provider-aws/issues/7128 — committed to yardbirdsax/codedeploy-ecs by deleted user 4 years ago
same issue here 😕
The fix for this has been merged and will release with version 2.56.0 of the Terraform AWS Provider, later this week. Thanks to @ImFlog for the implementation. 👍
For those still waiting for a fix you can add a +1 on the PR #11885 in order to get it merged 😉
I am also having this issue.