-
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
when aws_instance
security_groups
is not a list, terraform crashes
#691
Comments
@bitglue that is correct, but that's inline with the docs and the schema of this resource. So this is actually by design I would say... Of course a user friendly error would be a lot better then a crash, but I guess that is a different issue right? |
No, that's the issue here. Crashing is never by design. Invalid user input should be punished by an error with a concise explanation and a line number, not a crash log spew. |
Agreed with @bitglue. We should fix the crash and show a user friendly error. Tagged as crashing. |
Check! So guess I misinterpreted your issue a little 😉 Was just thinking to myself I should double check anyway, as there is a validation being done which clearly misses this one. Thanks! |
I would also add as a related and relatively minor note: the syntax for making "a list" is arcane because:
Additionally it's called an "array" instead of a "list" in the page that defines the syntax, which so far as I've found is the only place to call it an "array". The inconsistency in terminology thwarted my Googling attempts and I thought the glob syntax was the only way to make a list until I performed an exhaustive read of the documentation and found the solution by coincidence. A little clarification of the docs probably would have avoided the mistake that caused me to discover this error in the first place. |
In fact, I believe this is not only for "security groups" in "aws_instance" but for all other attributes in resources which have their type as Set. There is validation for type "List" but not "Set". |
Yes, this is a generic issue that we should fix in the validation of the resource... |
@mitchellh, I investigated and it seems there is some issue with the below lines of code in resource.go (terraform/terraform/resource.go) file : func (c *ResourceConfig) IsComputed(k string) bool {
_, ok := c.get(k, c.Config)
_, okRaw := c.get(k, c.Raw)
return !ok && okRaw
} This is what is causing the crash. I changed the return condition to |
I'm not sure when this was fixed, but it was fixed in 0.3.6:
|
Yes, it is fixed. Thanks! |
@mitchellh It was never fixed? I can reproduce this on both Terraform v0.3.6 and Terraform v0.3.7.dev (a909ce8) by running
|
@ceh Sure, opening it. It was fixed for the repro case in the root comment, but this is new. :) |
Fixed by #773 |
This seems to be happening still.
Module:
Output:
Change security groups as a list, explicitly in module:
And it works!
|
Hi @bitglue (Phil) would you mind sharing your findings by any example or the link that you follow. I'm in the same situation. |
I don't think I have any configs left still using |
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. |
It seems that if
aws_instance
is provided a string (not a list) forsecurity_groups
, terraform crashes onplan
orapply
.Example:
if that's changed to
then there is no crash.
The text was updated successfully, but these errors were encountered: