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

Using aws_autoscaling_attachment #19

Closed
lawliet89 opened this issue Feb 7, 2018 · 9 comments
Closed

Using aws_autoscaling_attachment #19

lawliet89 opened this issue Feb 7, 2018 · 9 comments

Comments

@lawliet89
Copy link
Contributor

lawliet89 commented Feb 7, 2018

I would like to be able to attach an ELB to the auto scaling group after the initial creation of the ASG using the aws_autoscaling_attachment resource.

However, the current implementation sets target_group_arns and load_balancers in the aws_autoscaling_group resource. These two usage would overwrite each other.

I would like to propose that we remove setting these two arguments in the aws_autoscaling_group and let users use the aws_autoscaling_attachment resource instead. (Sadly there is no "unset" functionality in Terraform AFAIK) I would argue that using aws_autoscaling_attachment is more flexible.

This would, unfortunately, be a breaking change.

lawliet89 added a commit to lawliet89/terraform-aws-nomad that referenced this issue Feb 7, 2018
Use `aws_autoscaling_attachment` instead.
Fixes hashicorp#19
lawliet89 added a commit to lawliet89/terraform-aws-nomad that referenced this issue Feb 7, 2018
Use `aws_autoscaling_attachment` instead.
Fixes hashicorp#19
@brikis98
Copy link
Collaborator

brikis98 commented Feb 8, 2018

I would like to be able to attach an ELB to the auto scaling group after the initial creation of the ASG using the aws_autoscaling_attachment resource.

Could you describe your use case?

However, the current implementation sets target_group_arns and load_balancers in the aws_autoscaling_group resource. These two usage would overwrite each other.

If you had both, yes, they would overwrite each other. Is there a reason you can't use the existing target_group_arns and load_balancers params?

@lawliet89
Copy link
Contributor Author

Currently, I have a module that provisions Consul and Nomad clusters using the this module and the other Consul module that you maintain.

I then have a separate module that provisions an ELB and that is backed by the Nomad clients ASG. I would like to be able to "attach" the ELB to the Nomad clients ASG without having to modify the module that provisions the Consul/Nomad clusters.

So instead of having the two modules have some sort of circular dependency (if that's even possible?), I would simply like the second module implicitly depend on the first module.

Hope this makes sense.

@lawliet89
Copy link
Contributor Author

@brikis98 May I know what your view on this is?

@brikis98
Copy link
Collaborator

I'm still a bit confused about why the existing approach doesn't work.

module "consule_and_nomad_servers" {
  source = "..."
}

module "nomad_clients" {
  source = "..."
}

Is this the general structure you have? Is the ELB defined in the nomad_clients module? Are you trying to associate it with both the servers and the clients?

@lawliet89
Copy link
Contributor Author

lawliet89 commented Feb 20, 2018

I have a module that sets up Nomad and Consul.

module "consule_and_nomad_servers" {
  source = "..."
}

module "nomad_clients" {
  source = "..."
}

Separately, I have a different module that sets up the ELB. This second module only accesses the first module via terraform_remote_state.

data "terraform_remote_state" "nomad" {
 // ...
}

resource "aws_elb" "nomad" {
  // ...
}

resource "aws_autoscaling_attachment" "nomad" {
  autoscaling_group_name = "${data.terraform_remote_state.nomad.nomad_asg_id}" // etc
  // ,,,
}

So basically, these two modules are provisioned via separate terraform appl[ies].

@brikis98
Copy link
Collaborator

So basically, these two modules are provisioned via separate terraform appl[ies].

Ah, that's the key info I was missing 👍

And I guess the issue you're hitting is if you attach an ELB using the existing load_balancers parameter in the Nomad module, the aws_autoscaling_attachment is no longer usable; on the other hand, if the Nomad module used aws_autoscaling_attachment resource itself, then you'd be able to use it too?

@lawliet89
Copy link
Contributor Author

Sorry I missed out some context earlier.

And I guess the issue you're hitting is if you attach an ELB using the existing load_balancers parameter in the Nomad module, the aws_autoscaling_attachment is no longer usable; on the other hand, if the Nomad module used aws_autoscaling_attachment resource itself, then you'd be able to use it too?

Yep. Basically, they are setting/unsetting each other during consecutive applies.

@brikis98
Copy link
Collaborator

OK, understood.

In that case, yes, I think a PR to switch to the aws_autoscaling_attachment resource in this module makes sense. It would be backwards incompatible, so we'll have to make that clear in the release notes.

Thx!

@lawliet89
Copy link
Contributor Author

lawliet89 commented Feb 20, 2018

I've opened #23 with some migration instruction.

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

No branches or pull requests

2 participants