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

-target does not source child modules #5190

Closed
Mongey opened this issue Feb 18, 2016 · 14 comments
Closed

-target does not source child modules #5190

Mongey opened this issue Feb 18, 2016 · 14 comments

Comments

@Mongey
Copy link
Contributor

Mongey commented Feb 18, 2016

We recently ran into an this issue as discussed in #1820 (comment) by @apparentlymart

... Nested modules don't target in the way I initially expected.

Given the following module tree:

  • root
    • foo
      • bar
      • baz

I initially expected that targeting module.foo would target all of the resources in bar and baz, but it appears that in fact it targets only the resources directly in foo. In my case there was actually nothing in foo except the declarations of bar and baz, so the -target plan appeared to do nothing, just like what is seen in the other examples above.

I suspect that this is at least what's going on for @maxenglander, since his dc0 module seems to have various sub-modules within.

The workaround for me was to target bar and baz explicitly by writing out their full names. This was easy (if annoying) in my case because I had relatively few nested modules, but it'd be more intuitive/consistent if targeting a module would also implicitly target all of its descendant modules, thus working on an entire sub-tree of the module hierarchy.

@phinze
Copy link
Contributor

phinze commented Feb 19, 2016

Thanks for filing this as a separate issue @Mongey - those long-tail threads have valuable details in them that can get lost in the cracks sometimes. 👍

Agreed that the behavior should definitely be that targeting a module implicitly targets its sub-modules. Treating this as a POLA violation and therefore a bug.

@BabakMN
Copy link
Contributor

BabakMN commented Sep 2, 2016

Any updates on this issue? I can confirm it's present in v0.7.0.

@ketzacoatl
Copy link
Contributor

@phinze, I am seeing this behavior for top-level modules as well as child-modules. Should I create a separate issue for the top-level modules escaping -target, or leave it all as one here?

@seanb4t
Copy link

seanb4t commented Sep 17, 2016

Some progress here would be great! Having to script terraform to do this sort of thing is certainly an anti-pattern.

@pikeas
Copy link
Contributor

pikeas commented Mar 3, 2017

Bug still present in 0.8.7.

@dcosson
Copy link
Contributor

dcosson commented Mar 22, 2017

Any chance of getting the fix in #9236 reviewed/merged?

@don-code
Copy link

I've found a workaround in the meantime: by exporting at least one parameter from the affected resources from a lower-level module, and consuming it from the higher-level module, --target works as expected.

In my case I'm creating TXT records in private DNS of those garbage outputs, but your use case may vary.

@pepov
Copy link

pepov commented Apr 27, 2017

@don-code true, but it only works for the resources that have been referenced from the higher level. All the non-referenced lower level resources are skipped in the plan/apply in my experience.

@pikeas
Copy link
Contributor

pikeas commented May 12, 2017

Bug still present in 0.9.4. According to #9236 this will "hopefully" be fixed in 0.10.

@ChristopheSchmitz
Copy link

Yea, very dangerous bug, we got bitten too. Hope this bug will get some love from the terraform team soon :)

@RulerOf
Copy link

RulerOf commented Jun 2, 2017

We just experienced this, too

15:21 $ terraform --version
Terraform v0.9.6

@camjackson
Copy link

In case anyone missed it, looks like this is resolved in #15314, but it constitutes a breaking change so it won't be released until 0.10. So good news and bad news.

Does anyone know when 0.10 is expected to land?

@grubernaut
Copy link
Contributor

Hey @camjackson we don't have a solid date set for the 0.10 release, but there are a couple beta releases and an RC release out if you wish to test this further!

Looks like this was fixed in #15314, closing.

@ghost
Copy link

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

Successfully merging a pull request may close this issue.