Commit Graph

23286 Commits

Author SHA1 Message Date
Nick Fagerlund 9f85e6d5cc website: Update configuration language section page titles 2018-12-20 14:20:42 -08:00
Nick Fagerlund d2abdc23ac website: Structural edit of configuration language docs
This commit is a wide-ranging set of edits to the pages under
/docs/configuration. Among other things, it

- Separates style conventions out into their own page.
- Separates type constraints and conversion info into their own page.
- Conflates similar complex types a little more freely, since the distinction is
  only relevant when restricting inputs for a reusable module or resource.
- Clarifies several concepts that confused me during edits.
2018-12-20 14:20:42 -08:00
James Bardin 41002e1a24 there is always an implied workspace of "default"
Fetching a state requires a workspace name, which should default to
"default"
2018-12-20 17:17:11 -05:00
Martin Atkins e39c69750c core: Specialized errors for incorrect indexes in resource reference
In prior versions of Terraform we permitted inconsistent use of indexes
in resource references, but in as of 0.12 the index usage must correlate
properly with whether "count" is set on the resource.

Since users are likely to have existing configurations with incorrect
usage, here we introduce some specialized error messages for situations
where we can detect such issues statically. This seems to cover all of the
common patterns we've seen in practice.

Some usage patterns will fall back on a less-helpful dynamic error here,
but no configurations coming from 0.11 can end up that way because 0.11
did not permit forms such as aws_instance.no_count[count.index].bar that
this validation would not be able to "see".

Our configuration upgrade tool also contains a fix for this already, but
it takes a more conservative approach of adding the index [1] rather than
[count.index] because it can't be sure (without human help) if correlation
of indices is what was intended.
2018-12-20 13:55:42 -08:00
Chris Griggs b50ac168d9
Merge pull request #19730 from cgriggs01/cgriggs01-hedvig
[Website] Hedvig provider doc links
2018-12-20 13:54:19 -08:00
cgriggs01 da370cd689 fix spacing in website docs 2018-12-20 13:27:15 -08:00
James Bardin 5ab9c049e3 update CHANGELOG.md 2018-12-20 15:37:20 -05:00
James Bardin 5ff003594e
Merge pull request #19726 from hashicorp/jbardin/destroy-plan
Don't fail decoding null values from plan changes
2018-12-20 15:35:28 -05:00
James Bardin f3fe6184a0 test for destroy plan round trip 2018-12-20 15:11:08 -05:00
cgriggs01 9df6e2df42 add hedvig provider links 2018-12-20 10:54:20 -08:00
James Bardin 1b8617cef0 don't attempt to decode empty changes values
An empty DynamicValue can't be decoded but indicates no state, so just
return a NullVal.
2018-12-20 13:06:53 -05:00
James Bardin a915f3f13e don't convert empty DynamicValue to nil 2018-12-20 10:28:26 -05:00
Martin Atkins c7c73bcfc2
Update CHANGELOG.md 2018-12-19 18:21:13 -08:00
Martin Atkins d627987e70 vendor: upgrade github.com/hashicorp/hcl2
This includes a change to accept and ignore a UTF-8 BOM at the start of
any given native syntax configuration.

Although a BOM is redundant in UTF-8, we learned in #18618 that several
software products on Windows will produce a BOM whenever they save as
UTF-8, so accepting it avoids friction when using those tools to author
or generate Terraform configuration files.

This fixes #18618.
2018-12-19 16:18:29 -08:00
Martin Atkins 2c17558446 configs: New test cases for invalid interpolations in block labels
The parent commit fixes an issue where this would previously have led to
a crash. These new test cases verify that parsing is now able to complete
without crashing, though the result is still invalid.
2018-12-19 15:54:33 -08:00
Martin Atkins 62481963b4 vendor: upgrade github.com/hashicorp/hcl2
This includes a fix to prevent the creation of an invalid block object
when the configuration contains invalid template sequences in block
labels.
2018-12-19 15:54:33 -08:00
Martin Atkins cf9499cb78 core: path.module, path.root, path.cwd use fwd slashes on all platforms
Previously we used the native slash type for the host platform, but that
leads to issues if the same configuration is applied on both Windows and
non-Windows systems.

Since Windows supports slashes and backslashes, we can safely return
always slashes here and require that users combine the result with
subsequent path parts using slashes, like:

    "${path.module}/foo/bar"

Previously the above would lead to an error on Windows if path.module
contained any backslashes.

This is not really possible to unit test directly right now since we
always run our tests on Unix systems and filepath.ToSlash is a no-op on
Unix. However, this does include some tests for the basic behavior to
verify that it's not regressed as a result of this change.

This will need to be reported in the changelog as a potential breaking
change, since anyone who was using Terraform _exclusively_ on Windows may
have been using expressions like "${path.module}foo\\bar" which they will
now need to update.

This fixes #14986.
2018-12-19 13:47:42 -08:00
Martin Atkins 2cf63d068f command: Always normalize config path before operations
Previously we were doing this rather inconsistently: some commands would
do it and others would not. By doing it here we ensure we always apply the
same normalization, regardless of which operation we're running.

This normalization is mostly for cosmetic purposes in error messages, but
it also ends up being used to populate path.module and path.root and so
it's important that we always produce consistent results here so that
we don't produce flappy changes as users work with different commands.

The fact that thus mutates a data structure as a side-effect is not ideal
but this is the best place to ensure it always gets applied without doing
any significant refactoring, since everything after this point happens in
the backend package where the normalizePath method is not available.
2018-12-19 13:47:42 -08:00
Chris Griggs 80a9c145d8
Merge pull request #19710 from cgriggs01/cgriggs01-ucloud
[Website] links for new UCloud provider
2018-12-19 13:46:57 -08:00
Martin Atkins 176ae6e95f core: Detect and reject self-referencing local values
We already catch indirect cycles through the normal cycle detector, but
we never create self-edges in the graph so we need to handle a direct
self-reference separately here.

The prior behavior was simply to produce an incorrect result (since the
local value wasn't assigned a new value yet).

This fixes #18503.
2018-12-19 13:46:01 -08:00
James Bardin 8ca7cc0237 update CHANGELOG.md 2018-12-19 16:17:50 -05:00
cgriggs01 79f93ed695 links for ucloud provider 2018-12-19 13:11:31 -08:00
James Bardin 3e5ce033b0
Merge pull request #19707 from hashicorp/jbardin/connection
Validate provisioner connection blocks
2018-12-19 16:03:10 -05:00
James Bardin 0b59f9cad2 fix provisioner tests
Add host where required in the test configs, and fix the mock to check
for a null connection.
2018-12-19 16:02:56 -05:00
James Bardin c552284157 don't evaluate an empty connection body
There's a required field now, so evaluating an empty block will always
fail.
2018-12-19 16:02:56 -05:00
James Bardin 8d17fcea4e make connection host Required
And provide the connection config for validation
2018-12-19 15:22:01 -05:00
Kristin Laemmert 28306b2a1b
Update CHANGELOG.md 2018-12-19 11:39:42 -08:00
Sander van Harmelen 687ba2907d
Merge pull request #19704 from hashicorp/svh/f-versions
backend/remote: compare versions without the prerelease
2018-12-19 20:09:47 +01:00
Kristin Laemmert 126e5f337f
json output of terraform plan (#19687)
* command/show: adding functions to aid refactoring

The planfile -> statefile -> state logic path was getting hard to follow
with blurry human eyes. The getPlan... and getState... functions were
added to help streamline the logic flow. Continued refactoring may follow.

* command/show: use ctx.Config() instead of a config snapshot

As originally written, the jsonconfig marshaller was getting an error
when loading configs that included one or more modules. It's not clear
if that was an error in the function call or in the configloader itself,
  but as a simpler solution existed I did not dig too far.

* command/jsonplan: implement jsonplan.Marshal

Split the `config` portion into a discrete package to aid in naming
sanity (so we could have for example jsonconfig.Resource instead of
jsonplan.ConfigResource) and to enable marshaling the config on it's
own.
2018-12-19 11:08:25 -08:00
Sander van Harmelen 7b51af72b2 backend/remote: compare versions without the prerelease 2018-12-19 19:06:22 +01:00
Martin Atkins 65c0826293 vendor: upgrade github.com/zclconf/go-cty
This includes:
- An additional check in the format stdlib function to fail if there are
  too many arguments given, rather than silently ignoring.
- Refinements for the type unification behavior to allow unification of
  object/tuple types into weaker map/list types when no other unification
  is possible.
- Improvements to the error messages for failed type conversions on
  collection and structural types to talk about mismatching element types
  where possible, rather than the outer value.
2018-12-18 17:29:09 -08:00
James Bardin 149ccd929e missing commits from 19688 2018-12-18 16:54:09 -08:00
James Bardin bbaa8af4f7
Merge pull request #19688 from hashicorp/jbardin/backend-hash
decode backend hash as uint64
2018-12-18 18:38:45 -05:00
James Bardin 9667e06a03 decode backend hash as uint64
Older versions of terraform could save the backend hash number in a
value larger than an int.

While we could conditionally decode the state into an intermediary data
structure for upgrade, or detect the specific decode error and modify
the json, it seems simpler to just decode into the most flexible value
for now, which is a uint64.
2018-12-18 17:57:44 -05:00
James Bardin 9a34f14c60 update CHANGELOG.md 2018-12-18 16:18:10 -05:00
Sander van Harmelen b45fef91ea
Merge pull request #19667 from hashicorp/svh/b-const-check
backend/remote: fix an error that prevents checking constraints
2018-12-18 19:59:03 +01:00
James Bardin 7ce03b5a7e
Merge pull request #19676 from hashicorp/jbardin/ResourceInstanceObject
Ensure we have providers when scaling in counted data sources
2018-12-18 13:23:59 -05:00
James Bardin 87a375d49c rename NodeDestroyableDataResourceInstance
Make this node consistent with the naming if the other instances.
2018-12-18 13:22:21 -05:00
James Bardin e73a8bb627 don't allow EvalWriteState without a provider 2018-12-18 13:09:45 -05:00
James Bardin 06a75b8038 ensure NodeDestroyableDataResource has provider
Make sure that NodeDestroyableDataResource has a ResolvedProvider to
call EvalWriteState. This entails setting the ResolvedProvider in
concreteResourceDestroyable, as well as calling EvalGetProvider in
NodeDestroyableDataResource to load the provider schema.

Even though writing the state for a data destroy node should just be
removing the instance, every instance written sets the Provider for the
entire resource. This means that when scaling back a counted data
source, if the removed instances are written last, the data source will
be missing the provider in the state.
2018-12-18 12:43:58 -05:00
James Bardin a4ab055fbd attach a deep copy of ResourceState 2018-12-17 18:08:53 -05:00
James Bardin 292535820d ResourceInstanceObject needs to return a copy 2018-12-17 16:37:18 -05:00
Brian Flad 4596c44c05
Update CHANGELOG for #19651 2018-12-17 15:43:59 -05:00
Brian Flad 882b6e1daa
Merge pull request #19651 from hashicorp/d-terraform-provider-aws-v1.52.0
deps: github.com/aws/aws-sdk-go@v1.16.4 and github.com/terraform-providers/terraform-provider-aws@v1.52.0
2018-12-17 15:38:41 -05:00
Martin Atkins f964c83abe
Update CHANGELOG.md 2018-12-17 10:56:38 -08:00
Charles Kenney 2dfc3a399d command: allow -no-color option on "providers" command 2018-12-17 10:55:16 -08:00
James Bardin 82f5f50fe7
Merge pull request #19674 from hashicorp/jbardin/count-refs
failing count refs
2018-12-17 12:49:54 -05:00
James Bardin 21d06aac41 don't expand EachMode from state during validation
Validate should not require state or changes to be present. Break out
early when using evaluationStateData during walkValidate before checking
state or changes, to prevent errors when indexing resources that haven't
been expanded.
2018-12-17 12:34:57 -05:00
James Bardin c70be3c328 failing tests when using resources with count
Two different tests failing around resourced with count
2018-12-17 12:15:43 -05:00
Martin Atkins 2be524d6ac core: Validate depends_on and ignore_changes traversals
Both depends_on and ignore_changes contain references to objects that we
can validate.

Historically Terraform has not validated these, instead just ignoring
references to non-existent objects. Since there is no reason to refer to
something that doesn't exist, we'll now verify this and return errors so
that users get explicit feedback on any typos they may have made, rather
than just wondering why what they added seems to have no effect.

This is particularly important for ignore_changes because users have
historically used strange values here to try to exploit the fact that
Terraform was resolving ignore_changes against a flatmap. This will give
them explicit feedback for any odd constructs that the configuration
upgrade tool doesn't know how to detect and fix.
2018-12-17 09:02:25 -08:00