fpco / terraform-aws-foundation

Establish a solid Foundation on AWS with these modules for Terraform
MIT License
203 stars 99 forks source link

add alb_target_group_arns to parameters #314

Closed JoseD92 closed 4 years ago

JoseD92 commented 4 years ago

name: add alb_target_group_arns to parameters about: adds alb_target_group_arns as a parameter to single-node-asg

Right now the aws provider has problems tracking the state of the aws_autoscaling_attachment which causes a that each time a plan is made terraform will detect a change even though no chage has been made.

try for example test1.txt and test2.txt.

for the test1 project (which uses terraform-aws-foundation//modules/asg in the way terraform-aws-foundation//modules/single-node-asg does) after applying the plan once and trying again you get the change:

      ~ target_group_arns         = [
          - "arn:aws:elasticloadbalancing:us-west-2:793514493597:targetgroup/test1-https-tg/a60467b421465538",
        ]

applying again you get

Terraform will perform the following actions:

  # aws_autoscaling_attachment.asg_alb will be created
  + resource "aws_autoscaling_attachment" "asg_alb" {
      + alb_target_group_arn   = "arn:aws:elasticloadbalancing:us-west-2:793514493597:targetgroup/test1-https-tg/a60467b421465538"
      + autoscaling_group_name = "jose-cluster20200327111722994700000003"
      + id                     = (known after apply)
    }

applying yet again it returns to the first change and applying will loop between the two changes

test2 on the other hand does uses correctly the alb_target_group_arns parameter and no changes are detected after applying once.

To fix that create destroy loop with single-node-asg we just need a small patch to pass that parameter down to asg module

JoseD92 commented 4 years ago

there is another MR https://github.com/fpco/terraform-aws-foundation/pull/296/files that solves the problem at the asg module level, closing this MR over that one

ketzacoatl commented 4 years ago

@mcgirr / @JoseD92 do we delete the branch as well?