Commit Graph

17 Commits

Author SHA1 Message Date
Martin Atkins
c937c06a03 terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.

The three main goals here are:
- Use the configuration models from the "configs" package instead of the
  older models in the "config" package, which is now deprecated and
  preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
  new "lang" package, instead of the Interpolator type and related
  functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
  rather than hand-constructed strings. This is not critical to support
  the above, but was a big help during the implementation of these other
  points since it made it much more explicit what kind of address is
  expected in each context.

Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.

I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-10-16 18:46:46 -07:00
James Bardin
49e6ecfd7a pass providers into modules via config
Implement the adding of provider through the module/providers map in the
configuration.

The way this works is that we start walking the module tree from the
top, and for any instance of a provider that can accept a configuration
through the parent's module/provider map, we add a proxy node that
provides the real name and a pointer to the actual parent provider node.
Multiple proxies can be chained back to the original provider.  When
connecting resources to providers, if that provider is a proxy, we can
then connect the resource directly to the proxied node. The proxies are
later removed by the DisabledProviderTransformer.

This should re-instate the 0.11 beta inheritance behavior, but will
allow us to later store the actual concrete provider used by a resource,
so that it can be re-connected if it's orphaned by removing its module
configuration.
2017-11-06 21:57:06 -05:00
James Bardin
0986d01223 add providers directly from the configuration
The first step in only using the required provider nodes in a graph is
to be able to specifically add them from the configuration.

The MissingProviderTransformer was previously responsible for adding
all providers. Now it is really just adding any that are missing from
the config.
2017-11-02 15:00:06 -04:00
Mitchell Hashimoto
9c16489887
terraform: ConfigTransformer has Unique and mode filters 2017-01-22 12:58:18 -08:00
Mitchell Hashimoto
7557e6e70a
terraform: ConfigTransformer 2016-11-08 13:59:25 -08:00
Mitchell Hashimoto
4f0d68dda4
terraform: PlanGraphBuilder 2016-11-08 13:59:17 -08:00
James Nugent
d7d39702c0 Type check variables between modules (#6185)
These tests demonstrates a problem where the types to a module input are 
not checked. For example, if a module - inner - defines a variable
"should_be_a_map" as a map, or with a default variable of map, we do not
fail if the user sets the variable value in the outer module to a string
value. This is also a problem in nested modules.

The implementation changes add a type checking step into the graph
evaluation process to ensure invalid types are not passed.
2016-04-15 12:07:54 -07:00
Paul Hinze
5d50264c31 core: module targeting
Adds the ability to target resources within modules, like:

module.mymod.aws_instance.foo

And the ability to target all resources inside a module, like:

module.mymod

Closes #1434
2015-05-05 21:58:48 -05:00
Mitchell Hashimoto
a0d9bc0f19 terraform: outputs connect properly 2015-05-01 11:26:58 -07:00
Mitchell Hashimoto
15ca84a682 terraform: module dependencies in graph use full name (FOR THE FUTURE) 2015-04-30 17:19:01 -07:00
Mitchell Hashimoto
1152ff562b terraform: add variables as graph nodes (no eval yet) 2015-04-30 16:27:20 -07:00
Mitchell Hashimoto
84cf7f1179 terraform: outputs show up in the graph 2015-02-19 12:08:02 -08:00
Mitchell Hashimoto
e45308fa6d terraform: module orphans are properly expanded and planned for destroy 2015-02-19 12:08:01 -08:00
Mitchell Hashimoto
4692f9809f terraform: module nodes expand 2015-02-19 12:07:57 -08:00
Mitchell Hashimoto
02bedd6850 terraform: transformers operate on root structures 2015-02-19 12:07:54 -08:00
Mitchell Hashimoto
8bf725e746 terraform: GraphNodeDependent 2015-02-19 12:07:53 -08:00
Mitchell Hashimoto
3820aea513 terraform: make adding config nodes a transformer 2015-02-19 12:07:52 -08:00