Commit Graph

11 Commits

Author SHA1 Message Date
James Bardin d217a9cbf8 core: fix NodePlannableResourceInstance data reads
The state after EvalReadDataDiff is no longer nil during plan, which
means that we can't use that as a proxy for requiring the diff.

Rather than exiting early to save the EvalWriteState and EvalWriteDiff
evaluations, continue normally regardless to ensure we have the latest
diff and state after the plan. This also aligns the data data source
handling with that of the managed resource.
2018-10-16 18:49:20 -07:00
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 b79adeae02 save resolved providers for resources to state
Use the ResourceState.Provider field to store the full name of the
provider used during apply. This field is only used when a resource is
removed from the config, and will allow that resource to be removed by
the exact same provider with which it was created.

Modify the locations which might accept the alue of the
ResourceState.Provider field to detect that the name is resolved.
2017-11-07 13:09:36 -05:00
James Bardin a14fd0344c WIP reference providers by full name
This turned out to be a big messy commit, since the way providers are
referenced is tightly coupled throughout the code. That starts to unify
how providers are referenced, using the format output node Name method.

Add a new field to the internal resource data types called
ResolvedProvider. This is set by a new setter method SetProvider when a
resource is connected to a provider during graph creation. This allows
us to later lookup the provider instance a resource is connected to,
without requiring it to have the same module path.

The InitProvider context method now takes 2 arguments, one if the
provider type and the second is the full name of the provider. While the
provider type could still be parsed from the full name, this makes it
more explicit and, and changes to the name format won't effect this
code.
2017-11-02 15:00:06 -04:00
Mitchell Hashimoto d59725e9fd
terraform: convert StateDeps to use new structs 2017-01-26 20:47:20 -08:00
Mitchell Hashimoto a2f3259e51 Merge pull request #10404 from hashicorp/b-plan-deposed
terraform: diff shows pure deposed destroy
2016-11-30 16:57:44 -08:00
Mitchell Hashimoto 3b2282ca57
terraform: Destroy node should only include deposed for specific index
Fixes #10338

The destruction step for a resource was included the deposed resources
for _all_ resources with that name (ignoring the "index"). For example:
`aws_instance.foo.0` was including destroying deposed for
`aws_instance.foo.1`.

This changes the config to the deposed transformer to properly include
that index.

This change includes a larger change of changing `stateId` to include
the index. This affected more parts but was ultimately the issue in
question.
2016-11-29 09:16:18 -08:00
Mitchell Hashimoto 80457b689c
terraform: do the deposed check within EvalDiff
There is never any reason to separate the two.
2016-11-28 14:34:24 -08:00
Mitchell Hashimoto 6ee3a08799
terraform: deposed shows up in plan, tests 2016-11-28 14:32:42 -08:00
Mitchell Hashimoto 337abe3f62
terraform: enable plan shadow graph 2016-11-08 13:59:30 -08:00
Mitchell Hashimoto 4cdaf6f687
terraform: ResourceTransformer to ResourceTransformerOld 2016-11-08 13:59:26 -08:00