Skip to content
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

aws_codedeploy_deployment_group issues with load_balancer_info #10836

Closed
apenney opened this issue Nov 11, 2019 · 4 comments · Fixed by #11648
Closed

aws_codedeploy_deployment_group issues with load_balancer_info #10836

apenney opened this issue Nov 11, 2019 · 4 comments · Fixed by #11648
Assignees
Labels
bug Addresses a defect in current functionality.

Comments

@apenney
Copy link

apenney commented Nov 11, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

❯ terraform -v
Terraform v0.12.13

  • provider.aws v2.35.0

Affected Resource(s)

  • aws_codedeploy_deployment_group

Terraform Configuration Files

Here's a direct cut and paste from my resource. Originally I was using the dynamic hack as you can see below (commented out). In order to rule this out I added a direct load_balancer_info{} block to make sure it wasn't that.

resource "aws_codedeploy_deployment_group" "app" {                                                                                          
  app_name              = "${aws_codedeploy_app.app.name}"                                                                                  
  deployment_group_name = var.role                                                                                                          
  service_role_arn      = "${aws_iam_role.codedeploy.arn}"                                                                                  
  # If we only have a single instance, use the AllAtOnce config                                                                             
  deployment_config_name = var.instance_count == 1 ? "CodeDeployDefault.AllAtOnce" : "${aws_codedeploy_deployment_config.app.id}"           
                                                                                                                                            
  autoscaling_groups = ["${aws_autoscaling_group.service.name}"]                                                                            
                                                                                                                                            
  auto_rollback_configuration {                                                                                                             
    enabled = true                                                                                                                          
    events  = ["DEPLOYMENT_FAILURE"]                                                                                                        
  }                                                                                                                                         
                                                                                                                                            
  # This is intended to be a conditional block (using a language hack)                                                                      
  # in order to do nothing for the case of load_balancer == None                                                                            
  #dynamic "load_balancer_info" {                                                                                                           
  #  for_each = var.load_balancer_type == "none" ? [] : [1]                                                                                 
  #  content {                                                                                                                              
  #    target_group_info {                                                                                                                  
  #      name = aws_lb_target_group.service[0].name                                                                                         
  #    }                                                                                                                                    
  #  }                                                                                                                                      
  #}                                                                                                                                        
  load_balancer_info {                                                                                                                      
    target_group_info {                                                                                                                     
      name = aws_lb_target_group.service[0].name                                                                                            
    }                                                                                                                                       
  }                                                                                                                                         
}                                                  

Debug Output

Sorry, the full output has a bunch of stuff I can't paste, but I assume this is the heart of what's going on:

2019/11/11 09:37:05 [WARN] Provider "aws" produced an invalid plan for module.web.aws_codedeploy_deployment_group.app, but we are tolerating it because it is using the legacy plugin SDK.
The following problems may be the cause of any confusing errors from downstream operations:
- .deployment_style: block count in plan (1) disagrees with count in config (0)

I can provide the full output privately if needed.

Expected Behavior

When I run this I expect it to associate the target group with the codedeploy group but this step is always skipped, no matter how much I mess around and tweak the config. Originally (I think?) this worked, I am pretty sure I manually verified this when I originally wrote this terraform, but somewhere along the way it stopped working.

I can no longer associate target groups with codedeploy, no matter what I do. Adding it by hand does not inspire terraform to try and remove it either, it completely ignores this block.

Actual Behavior

Nothing, a terraform plan is blank.

Steps to Reproduce

I'm hoping you can simply create a target group and attempt to associate it with codedeploy in any way and see it fail.

  1. terraform apply

Important Factoids

Nothing that I can think of, this is all new stuff.

  • #0000
@ghost ghost added the service/codedeploy label Nov 11, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 11, 2019
@gdavison
Copy link
Contributor

Thanks for submitting this issue, @apenney. Could you add some more detail to the example? Specifically:

  • deployment_config_name has a conditional. Have you tested with both a var.instance_count of 1 and higher?
  • Can you show the set of resources that this depends on in your example?

@apenney
Copy link
Author

apenney commented Nov 13, 2019

It does the same thing regardless of the instance_count; well, it tries to obviously change:

      ~ deployment_config_name = "web-staging-config" -> "CodeDeployDefault.AllAtOnce"                                                           

Other resources:

resource "aws_codedeploy_app" "app" {                                                                                                             
  compute_platform = "Server"                                                                                                                     
  name             = var.role                                                                                                                     
}                                                                                                                                                 
                                                                                                                                                  
resource "aws_codedeploy_deployment_config" "app" {                                                                                               
  deployment_config_name = "${var.role}-config"                                                                                                   
                                                                                                                                                  
  minimum_healthy_hosts {                                                                                                                         
    type  = "FLEET_PERCENT"                                                                                                                       
    value = 50                                                                                                                                    
  }                                                                                                                                               
} 

resource "aws_iam_role" "codedeploy" {                                                                                                            
  name = "${var.name}-${terraform.workspace}-codedeploy"                                                                                          
                                                                                                                                                  
  assume_role_policy = <<EOF                                                                                                                      
{                                                                                                                                                 
  "Version": "2012-10-17",                                                                                                                        
  "Statement": [                                                                                                                                  
    {                                                                                                                                             
      "Sid": "",                                                                                                                                  
      "Effect": "Allow",                                                                                                                          
      "Principal": {                                                                                                                              
        "Service": "codedeploy.amazonaws.com"                                                                                                     
      },                                                                                                                                          
      "Action": "sts:AssumeRole"                                                                                                                  
    }                                                                                                                                             
  ]                                                                                                                                               
}                                                                                                                                                 
EOF                                             

@gdavison gdavison added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Dec 18, 2019
@gdavison gdavison self-assigned this Jan 11, 2020
@gdavison
Copy link
Contributor

Hi @apenney, I'm finally getting back to this. I think I've located the error, and I will work on a fix for this.

@ghost
Copy link

ghost commented Mar 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality.
Projects
None yet
2 participants