-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Error: security_groups: should be a list. in AWS_LAUNCH_CONFIGURATION API #13869
Comments
Same behavior on aws_auto_scaling_group too. |
Hi @cheburakshu , to better understand the issue & make it easier to reproduce for anyone else would you mind sharing more details? e.g.
Thanks. |
Please clone this repo -- github.com/cheburakshu/terrakube. I am on Terrform v0.9.2
Module:
Output:
Change security groups as a list, explicitly in module:
And it works!
|
Hey @cheburakshu – the second example is how you are required to reference lists example: |
@catsby See the example below - This works. Note domain_name_servers is a list.
security_groups = ["${module.minion_security_group.id}"]
|
@catsby Can this be re-opened. I am not setting a wrong value here. Need help. You can see the code here- github.com/cheburakshu/terrakube |
Hey @cheburakshu if you can extract from your example repo a minimal configuration ( a default map value, with something like I sincerely want to help, but I need a more narrow, specific example to be provided. |
@catsby I had this problem as well and I agree with @cheburakshu that it is a problem, either with the documentation or the implementation, depending on which one is right. The documentation you linked to (https://www.terraform.io/docs/configuration/interpolation.html#user-list-variables) says:
But it appears that in this case at least we are required to reference a list as |
On further consideration, I think the docs are right and the behavior is wrong. The way we apparently need to surround some list interpolations with square brackets would hide real problems in case the variable passed into the module mistakenly is not a list (i.e. it would convert a string variable into a list of length one rather than giving an error). |
Not just lists, if you use auto scaling groups or ebs in modules, you
cannot pass list of maps, lists too.
…On Tue, May 30, 2017 at 10:43 AM, Joshua C. Randall < ***@***.***> wrote:
On further consideration, I think the docs are right and the behavior is
wrong. The way we apparently need to surround some list interpolations with
square brackets would hide real problems in case the variable passed into
the module mistakenly is not a list (i.e. it would convert a string
variable into a list of length one rather than giving an error).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#13869 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AaEF0prEfEbAflneHy11Ol4B-SUcwFj-ks5r_Ec3gaJpZM4NFMSY>
.
|
I have just experienced the same issue and agree with @jrandall 's previous 2 comments. Moreover, the issue does not appear when the initial list is created in place, without any variables. Using: terraform v0.10.2 @catsby I've created a minimal working example repo: https://github.com/rszalski/terraform_list_var_inconsistency I hope it's minimal enough for you to consider reopening and investigating. |
This is at the very least a documentation issue and, I agree, if the documentation were updated to match the only thing that works (e.g. Problem occurs with Terraform v0.10.3 as well. |
+1 this problem makes using modules stupid, coupled with issue for just-in-time count expansion: #1497 (comment) |
I can confirm being befuddled for several minutes by this bug. |
just got this confusing error too. the right way to reference a variable is |
this is a bug and should be reopened. my list variable inside a module works without brackets unless the list that's passed in contains a variable, then i have to put brackets around the reference in the module. weird stuff. |
I just faced this too. This is definitely confusing and I believe the issue should be reopened. |
+1 this is a definite bug seemingly when passing lists into modules. Simple example:
I also tried a couple of things like calling trimspace() on the interpolated variable to see if that would resolve some kind of typing mismatch, but nope. Something deeper going on that's not self-evident. I disagree that the module definition should be a list to which a string value is passed - not a good workaround and horrible if you have existing module instantiations. |
It's trivial to reproduce this as @petewilcock has shown - you'd expect "sg-123456" to be equivalent to "${var.sg}" if var.sg is equal to "sg-123456". It's a one-line terraform plan, what other repo steps are needed? |
@catsby Unfortunately this is still an issue. The docs say this:
It would be great if this were true, but it's not This can be demonstrated in the minimal repro that @rszalski kindly took the time to put together last August. Here's the important file (it's only 7 lines long). Since the docs don't match the behavior, there are two possible resolutions here:
I would strongly prefer the former, but if you guys choose the latter, at least your intent will be clear and this inconsistency could still be navigated by reading the docs. In the meantime, could you please reopen this, add tags Sorry for tagging you, but I just want this to be solved before 1.0 so Terraform is the best it can be ❤️ |
After I met with this bug, I consciously moved away from writing modules since they are very brittle in behavior (due to parsing of list, list of maps etc) when compared to the resources themselves. Another major missing feature, though un-related to my original filing of this bug report, is the inability of modules to be used for creating multiple resources. The explosion operation '*', works with resources like a charm and the hope for it to be available in modules is just a distant dream. Anyway, hope this gets fixed. |
I faced this issue too... cannot pass type = "list" in the modules... I like the whole modules, how they work.. these little things need to be fixed for better reusability. |
@catsby why have typed variables if the type isn't respected. app/alb.tf
module alb/alb.tf
Error: module.alb.aws_alb.alb: security_groups: should be a list |
I also just hit this issue again. |
This fixes a mismatch between docs and behavior. Although the described behavior is unintuitive, it matches the reality of how Terraform currently works. hashicorp#13869 has further details and a small repo where you can quickly verify the behavior we're seeing. I hope that the bug is fixed and this commit can be rolled back, but in the meantime, I think it would be good for the docs to be accurate to prevent confusion.
I submitted a PR to describe the current behavior in the docs in lieu of a bugfix. While I'm here, I'd also like to once again bring attention to the minimal repro that @rszalski kindly took the time to put together last August. Here's the key file in its entirety: resource "aws_instance" "list-example-ec2" {
ami = "ami-d7b9a2b1"
instance_type = "t2.nano"
vpc_security_group_ids = "${var.security_group_ids}"
# However the following works (notice the surrounding square brackets)
# vpc_security_group_ids = ["${var.security_group_ids}"]
} Here is a link to the full repo: https://github.com/rszalski/terraform_list_var_inconsistency |
Looks like a fix for this issue is in the works: #18062 (comment) |
I'm glad they're doing a real fix, although I'm also glad that your PR turned up more information on what's going on. ;) |
My devious plan worked perfectly :) |
`Error: module.internetless.google_compute_firewall.cf-internal-egress: destination_ranges: should be a list` Terraform issue: hashicorp/terraform#13869 Signed-off-by: Elena Sharma <[email protected]>
`Error: module.internetless.google_compute_firewall.cf-internal-egress: destination_ranges: should be a list` Terraform issue: hashicorp/terraform#13869 Signed-off-by: Elena Sharma <[email protected]>
Workaround: I can't believe the number of really obvious issues with terraform that have been declared not to be issues. This is like the 5th problem I've run into that was misunderstood by the hashicorp team and determined (incorrectly) to be user error for over a year. The symptoms are that the type is a list and the expected type is a list, but terraform simply states 'should be a list' and does not mention what type was actually passed. When a variable of incorrect type is actually passed, the incorrect type is stated. for example ', got string' |
Also why have the 11.x docs not been updated since this issue was reported, verified (and even fixed in .12)? |
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. |
I am on Terraform v0.9.2.
I get error security_groups: should be a list eventhough it is supplied as a list. Seems the issue was addressed with #691 but it is surfacing now for me. I have added my snippets to #691 for reproducing the error.
The text was updated successfully, but these errors were encountered: