Skip to content
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

make diagnose on for_each argument more precise #22279

Merged
merged 2 commits into from
Aug 1, 2019

Conversation

tmatias
Copy link
Contributor

@tmatias tmatias commented Jul 31, 2019

That condition would not diagnose other iterables, such as tuple argument values, causing a panic: not a string later on.

@hashicorp-cla
Copy link

hashicorp-cla commented Jul 31, 2019

CLA assistant check
All committers have signed the CLA.

@tmatias tmatias changed the title make validation on for_each argument more precise make diagnose on for_each argument more precise Jul 31, 2019
@tmatias tmatias changed the title make diagnose on for_each argument more precise make diagnose on for_each argument more strict Jul 31, 2019
@tmatias tmatias changed the title make diagnose on for_each argument more strict make diagnose on for_each argument more precise Jul 31, 2019
@teamterraform
Copy link
Contributor

Hi @tmatias, thanks for your contribution!

It looks like this change causes the TestContext2Plan_forEach test to fail - please take a look at the Travis build log for details.

@teamterraform teamterraform requested a review from pselle August 1, 2019 15:10
@pselle
Copy link
Contributor

pselle commented Aug 1, 2019

Thanks @tmatias!

@omeid
Copy link

omeid commented Aug 19, 2019

This doesn't seem right. Shouldn't you be able to use list type with for_each?

cc: @teamterraform

@teamterraform
Copy link
Contributor

@omeid resources created with for_each are identified by their string key, and as such, values must be unique. It's for that reason that Terraform enforces using sets rather than lists of strings, because it should not be ambiguous what resources will be created.

@omeid
Copy link

omeid commented Aug 19, 2019

In that case then the documentation needs to be updated accordingly, from the intro to the actual configuration document suggests that lists should work.

Intro: ...includes the idea of iterating over a list or map using the for_each argument, which is intended as a more.

expressions docs:
Since the for_each argument accepts any collection or structural value.

Other than the documentation, I think the general that for_each = resource.multiple.*.id should work is a very pragmatic expectation.

@ghost
Copy link

ghost commented Sep 1, 2019

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.

@ghost ghost locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants