-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Improve flexibility in defining the list of Load Balancers associated with an AWS Auto Scaling Group #2710
Comments
After #2504 we can almost do this: This does not yet work: variable "elb_names" {
description = "comma separated list of ELB names to associate with ASG"
default = ""
}
module "ami" {
source = "github.com/terraform-community-modules/tf_aws_ubuntu_ami/ebs"
instance_type = "t2.micro"
region = "us-west-2"
distribution = "trusty"
}
resource "aws_launch_configuration" "app" {
instance_type = "t2.micro"
image_id = "${module.ami.ami_id}"
}
resource "aws_autoscaling_group" "app" {
availability_zones = [ "us-west-2a" ]
launch_configuration = "${aws_launch_configuration.app.id}"
max_size = 1
min_size = 1
name = "GH-2710"
// results in [""], which AWS API treats as a validation error
load_balancers = ["${split(",", var.elb_names)}"]
} We need to either:
|
My initial sense was that the ASG resource would simply accept, but ignore an empty list of LB.. but I know very little about go or the tf codebase. |
@ketzacoatl yeah that's definitely the easier of the two options. seems to be a reasonable path to take for this particular issue. |
I'm looking at the code in https://github.com/hashicorp/terraform/blob/master/builtin/providers/aws/resource_aws_autoscaling_group.go, but am not familiar enough with Go to pick up on the edits to make this work, otherwise I would submit the PR for it :( |
Hi, I've hit this same issue. I've got this working in https://github.com/elblivion/terraform/tree/ignore-empty-lb-list-as-string, but |
@phinze is there a reason |
Ah, just noticed there is a PR open about this at #2973, will look at that |
This would be great. I'm running into the same issue outlined by @ketzacoatl . @elblivion I think this will remain an issue even after |
@ketzacoatl one workaround that may help you remove a duplicate module, is to do something like this:
then in your module, you default |
This should now be possible using |
This is true, |
Though I have to say, while I appreciate the power available through interpolation and built-in functions, I'm sometimes frustrated by the messy code that results:
|
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
As it is now, the ASG resource accepts one of two values for the
load_balancers
attribute, either:[ ]
or[ "name_of_an_elb"]
, but you cannot provide the empty list as the value in a variable.That might sound whacky, I know.. here is my reasoning.. first I don't want to have to maintain two modules if I want to optionally include an ELB with the ASG, but he lack of flexibility here forces one to do so. If support for conditional logic (via #1604) is not coming soon, I would like to propose a more immediate solution focused on improving flexibility in the ASG resource. Specifically, if the following code were to work correctly, we would be able to build modules which provide an ELB only if requested:
We could then provide
[ "foo", "bar" ]
as a value when calling the module, or leave the[ ]
empty default, and the ASG would accept our requests. Maybe this sounds whacky, but it is true, without the basic constructs provided by conditional logic, we're getting desperate in an effort to keep the code compact and minimal (maintaining two ASG modules - one with ELB, one without - is not really a reasonable option).The text was updated successfully, but these errors were encountered: