Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Module consul-cluster : aws_autoscaling_attachment broken #183

Open
LeComptoirDesPharmacies opened this issue Aug 4, 2020 · 3 comments
Open
Labels

Comments

@LeComptoirDesPharmacies
Copy link

Hi,

Since terraform AWS provider 2.21.0, it seems that we can no more use safely aws_autoscaling_attachment as described in your consul-cluster README. (See issue : hashicorp/terraform-provider-aws#9513)

Indeed, if we use aws_autoscaling_attachment to attach target groups to ASG created by consul-cluster, next apply on consul cluster remove the target groups of load balancer.

Documentation (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_attachment) recommends that you put ignore_changes on aws_autoscaling_group ressources :

to prevent unintended resource updates, the aws_autoscaling_group resource must be configured to ignore changes to the load_balancers and target_group_arns arguments within a lifecycle configuration block.

Do you agree with this ? Do you have any workaround ?

Thanks in advance for your answer.
Yours faithfully,
LCDP

LeComptoirDesPharmacies pushed a commit to LeComptoirDesPharmacies/terraform-aws-consul that referenced this issue Aug 4, 2020
Solution :
On ASG, ignore load_balancers and targetgroup_arns modifications according to recommandations.

References :
hashicorp/terraform-provider-aws#9513
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_attachment
@brikis98
Copy link
Collaborator

brikis98 commented Aug 6, 2020

Are you seeing an issue if you use both target_groups param on aws_autoscaling_group and the aws_autoscaling_attachment resource? Or you get an issue if you use just one of them? Could you share the code and issue you're seeing?

@LeComptoirDesPharmacies
Copy link
Author

Hi @brikis98,

In fact consul_cluster do not use target_groups field so it is always omitted in module. (

resource "aws_autoscaling_group" "autoscaling_group" {
)

I just use the aws_autoscaling_attachment as the documentation describe. (https://github.com/hashicorp/terraform-aws-consul/blob/master/modules/consul-cluster/README.md#how-do-you-connect-load-balancers-to-the-auto-scaling-group-asg)

Here is a "simple" reproducer :
https://gist.github.com/LeComptoirDesPharmacies/3022db2067c3a98ba7d64fab1d17ab5b

If you apply once : ASG > Load Balancing menu will show the LB target groups.
If you apply twice : ASG > Load balancing menu show nothing
If you apply thrice : ASG > Load Balancing menu will show the LB target groups.
etc...

Then, you can check the fix by replacing the module source to : github.com/LeComptoirDesPharmacies/terraform-aws-consul//modules/consul-cluster?ref=bugfix%2Fconsul-cluster-asg-attachment

Yours faithfully,
LCDP

@brikis98
Copy link
Collaborator

Understood, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant