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 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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Collaborator

teamterraform commented Aug 1, 2019

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 Aug 1, 2019
@pselle
pselle approved these changes Aug 1, 2019
@pselle

This comment has been minimized.

Copy link
Member

pselle commented Aug 1, 2019

Thanks @tmatias!

@pselle pselle merged commit 07ee88b into hashicorp:master Aug 1, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details
@omeid

This comment has been minimized.

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

This comment has been minimized.

Copy link
Collaborator

teamterraform commented Aug 19, 2019

@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

This comment has been minimized.

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.

@hashibot

This comment has been minimized.

Copy link

hashibot bot 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.

@hashibot hashibot bot 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.
Projects
None yet
5 participants
You can’t perform that action at this time.