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

terraform: orphaned grandchild module inherits provider config #9318

Merged
merged 1 commit into from
Oct 11, 2016

Conversation

mitchellh
Copy link
Contributor

@mitchellh mitchellh commented Oct 11, 2016

This fixes an issue where orphaned grandchild modules don't properly
inherit their provider configurations from grandparents. I found this
while working on shadow graphs (the shadow graph actually caught an
inconsistency between runs and exposed this bug!), so I'm unsure if this
affects any pre-existing issues.

To better explain the issue, I'll diagram things.

Here is a hierarchy that works (w/o this PR):

root
|-- child1 (orphan)
|-- child2
    |-- grandchild

All modules in this case will successfully inherit provider
configurations from "root".

Here is a hierarchy that doesn't work without this PR:

root
|-- child1 (orphan)
    |-- grandchild (orphan)

In this case, child1 does successfully inherit the provider from root,
but grandchild will not unless child1 had resources. If child1
has no resources, it wouldn't inherit anything. This PR fixes that.

This fixes an issue where orphaned grandchild modules don't properly
inherit their provider configurations from grandparents. I found this
while working on shadow graphs (the shadow graph actually caught an
inconsistency between runs and exposed this bug!), so I'm unsure if this
affects any issue.

To better explain the issue, I'll diagram things.

Here is a hierarchy that _works_ (w/o this PR):

```
root
|-- child1 (orphan)
|-- child2
    |-- grandchild
```

All modules in this case will successfully inherit provider
configurations from "root".

Here is a hierarchy that _doesn't work without this PR_:

```
root
|-- child1 (orphan)
    |-- grandchild (orphan)
```

In this case, `child1` does successfully inherit the provider from root,
but `grandchild` _will not_ unless `child1` had resources. If `child1`
has no resources, it wouldn't inherit anything. This PR fixes that.
@jbardin
Copy link
Member

jbardin commented Oct 11, 2016

You mentioned that this only "periodically" caught the inconsistency. Aren't the transform walk done without any concurrency, via a ReverseDepthFirstWalk? Do you have any idea why the output wasn't deterministic?

@mitchellh
Copy link
Contributor Author

Yep, because it didn't create a dependece so it'd walk the two providers in paralllel.

The transforms are sequential but the race was in the graph walk (since the edge wasn't made).

@mitchellh mitchellh merged commit 22c8a83 into master Oct 11, 2016
@mitchellh mitchellh deleted the b-provider-orphan-grandchild branch October 11, 2016 14:16
@martin-cossy-atwork
Copy link

I think this is related, see ticket 8680. There is an example in GitHub which is still failing: terraform-aws-region-prompt. In this example child modules are not properly inheriting the AWS provider, instead terraform tries to use my default profile in ~./aws (!). Running terraform 0.7.6 under Linux 4.7.6-1-ARCH 64 bits (ArchLinux).

@ghost
Copy link

ghost commented Apr 21, 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 21, 2020
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.

3 participants