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

return an error with an invalid resource index #22534

Closed
wants to merge 1 commit into from

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Aug 20, 2019

Invalid indexed references to other resources were silently returning
unknown values when the resource didn't exist. These were only caught by
extra validation in data sources when the config still contained unknown
values during ReadDataSource.

Also add a check for unknown values when applying managed resources to
prevent sending unknown values.

Have GetResourceInstance return full diagnostics pointing to the invalid
reference in the config to help users troubleshoot the issue. This is
currently only done during Apply, as there is some uncertainly about
all instances being resolved in time for plan evaluation. This will
still catch errors for both resources and data sources and report
diagnostic errors, but unfortunately that won't happen until the apply
phase.

The original output for a datasource with this error would only be

configuration for data.null_data_source.foo[0].id still contains unknown values during apply (this is a bug in Terraform; please report it!)

And now will report

Error: Invalid resource index

  on main.tf line 7, in data "null_data_source" "bar":
   7:     a = data.null_data_source.foo[0].id

Resource data.null_data_source.foo has no index [0].

Fixes #22424

@jbardin jbardin requested a review from a team August 20, 2019 18:41
@jbardin jbardin force-pushed the jbardin/invalid-index branch 3 times, most recently from c3c3abd to acd0375 Compare August 20, 2019 21:15
Invalid indexed references to other resources were silently returning
unknown values when the resource didn't exist. These were only caught by
extra validation in data sources when the config still contained unknown
values during ReadDataSource.

Also add a check for unknown values when applying managed resources to
prevent sending unknown values.

Have GetResourceInstance return full diagnostics pointing to the invalid
reference in the config to help users troubleshoot the issue. This is
currently only done during Apply, as there is some uncertainly about
all instances being resolved in time for plan evaluation. This will
still catch errors for both resources and data sources and report
diagnostic errors, but unfortunately that won't happen until the apply
phase.
@jbardin
Copy link
Member Author

jbardin commented Sep 19, 2019

Superseded by #22846 which fixes the evaluation as a whole, since terraform can't determine if the index evaluation will be needed at all (which is probably why it had to silently return unknown in the first place)

@jbardin jbardin closed this Sep 19, 2019
@teamterraform teamterraform deleted the jbardin/invalid-index branch September 19, 2019 16:23
@ghost
Copy link

ghost commented Oct 20, 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 Oct 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TF 0.12 data.aws_iam_policy_document still contains unknown values during apply
3 participants