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

core: treat refs to unknown set resource attrs as unknown #4840

Merged
merged 1 commit into from
Jan 27, 2016

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Jan 26, 2016

References to computed list-ish attributes (set, list, map) were being
improperly resolved as an empty list [] during the plan phase (when
the value of the reference is not yet known) instead of as an
UnknownValue.

A "diffs didn't match" failure in an AWS DirectoryServices test led to
this discovery (and this commit fixes the failing test):

https://travis-ci.org/hashicorp/terraform/jobs/104812951

Refs #2157 which has the original work to support computed list
attributes at all. This is just a simple tweak to that work.

/cc @radeksimko

@@ -519,6 +519,10 @@ func (i *Interpolater) interpolateListAttribute(
log.Printf("[DEBUG] Interpolating computed list attribute %s (%s)",
resourceID, attr)

if attr == config.UnknownVariableValue {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a comment help here? Maybe slightly rhetorical since I'm unsure at first glance as an outsider to this PR why this behavior needs to be here. At least covered by tests! :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - done in 48b172a

References to computed list-ish attributes (set, list, map) were being
improperly resolved as an empty list `[]` during the plan phase (when
the value of the reference is not yet known) instead of as an
UnknownValue.

A "diffs didn't match" failure in an AWS DirectoryServices test led to
this discovery (and this commit fixes the failing test):

https://travis-ci.org/hashicorp/terraform/jobs/104812951

Refs #2157 which has the original work to support computed list
attributes at all. This is just a simple tweak to that work.

/cc @radeksimko
@phinze phinze force-pushed the phinze/interpolate-computed-set-references-properly branch from 65d000d to 48b172a Compare January 26, 2016 19:50
@phinze
Copy link
Contributor Author

phinze commented Jan 27, 2016

@mitchellh look better w/ the comments?

}

// Otherwise we gather the values from the list-like attribute and return
// them.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the above guard, we'd plow right into the list building below even when the whole list was computed and end up returning an empty list, which was wrong.

@mitchellh
Copy link
Contributor

LGTM

phinze added a commit that referenced this pull request Jan 27, 2016
…et-references-properly

core: treat refs to unknown set resource attrs as unknown
@phinze phinze merged commit 6576adb into master Jan 27, 2016
@phinze phinze deleted the phinze/interpolate-computed-set-references-properly branch January 27, 2016 20:03
@ghost
Copy link

ghost commented Apr 28, 2020

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 Apr 28, 2020
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.

2 participants