Commit Graph

24152 Commits

Author SHA1 Message Date
Kristin Laemmert b9f114aa25
command/show (json): marshal the state snapshot included with the plan file (#21597)
* command/show: marshal the state snapshot from the planfile

The planfile contains a state snapshot with certain resources updated
(outputs and datasources). Previously `terraform show -json PLANFILE`
was using the current state instead of the state inside the plan as
intended.

This caused an issue when the state included a terraform_remote_state
datasource. The datasource's state gets refreshed - and therefore
upgraded to the current state version - during plan, but that won't
persist to state until apply.

* update comment to reflect new return
2019-06-05 07:29:02 -04:00
Martin Atkins 2f893f2b95
Update CHANGELOG.md 2019-06-04 16:25:38 -07:00
Martin Atkins 382e1ca821 lang: yamldecode and yamlencode functions
These follow the same principle as jsondecode and jsonencode, but use
YAML instead of JSON.

YAML has a much more complex information model than JSON, so we can only
support a subset of it during decoding, but hopefully the subset supported
here is a useful one.

Because there are many different ways to _generate_ YAML, the yamlencode
function is forced to make some decisions, and those decisions are likely
to affect compatibility with other real-world YAML parsers. Although the
format here is intended to be generic and compatible, we may find that
there are problems with it that'll we'll want to adjust for in a future
release, so yamlencode is therefore marked as experimental for now until
the underlying library is ready to commit to ongoing byte-for-byte
compatibility in serialization.

The main use-case here is met by yamldecode, which will allow reading in
files written in YAML format by humans for use in Terraform modules, in
situations where a higher-level input format than direct Terraform
language declarations is helpful.
2019-06-04 16:24:09 -07:00
Martin Atkins 3eb379f4d4 vendor: go get github.com/zclconf/go-cty-yaml@v0.1.0
This module contains a YAML parser and encoder tailored to cty, though we
are mostly interested in it for its YAMLEncode and YAMLDecode cty
functions, which we can make available in Terraform.
2019-06-04 16:24:09 -07:00
Martin Atkins 60850bc6c4
Update CHANGELOG.md 2019-06-04 16:21:18 -07:00
Martin Atkins f9a73d48db lang: "range" function
This is similar to the function of the same name in Python, generating a
sequence of numbers as a list that can then be used in other
sequence-oriented operations.

The primary use-case for it is to turn a count expressed as a number into
a list of that length, which can then be iterated over or passed to a
collection function to produce that number of something else, as shown
in the example at the end of its documentation page.
2019-06-04 16:20:17 -07:00
Pam Selle 05cb7617c4 release: clean up after v0.12.1 2019-06-04 17:35:45 +00:00
Pam Selle 12c3170748
v0.12.1 2019-06-04 17:21:35 +00:00
Martin Atkins bf661d54fc
Update CHANGELOG.md 2019-06-04 09:25:39 -07:00
Martin Atkins b1213f7f6c backend/local: don't panic when an instance has only a deposed object
This unusual situation isn't supposed to arise in normal use, but it can
come up in practice in some edge-case scenarios where Terraform fails in
a severe way during a create_before_destroy.

Some earlier versions of Terraform also had bugs in their handling of
deposed objects, so this may also arise if upgrading from one of those
older versions with some leftover deposed objects in the state.
2019-06-04 09:23:29 -07:00
Kristin Laemmert 2d194828a4
Merge pull request #21576 from hashicorp/mildwonkey/b-matchkeys
lang/funcs: fix error when `matchkeys` encountered a variable
2019-06-04 12:19:09 -04:00
Kristin Laemmert c163ba71db simplify 2019-06-04 11:54:26 -04:00
Kristin Laemmert 30a924e162 lang/funcs: `matchkeys` - unify type for keys and searchset
Added higher-level test for matchkeys to exercise mixing
types in searchset. This had to be in the functions tests so the HCL
auto conversion from tuple to list would occur.
2019-06-04 08:57:02 -04:00
Chris Griggs c281f70662
Merge pull request #21578 from hashicorp/cgriggs01-community-links
[Website] new community links + update signalFX
2019-06-03 19:47:06 -05:00
cgriggs01 55fe3c7a28 new community links + update signalFX 2019-06-03 17:19:52 -07:00
David Liao 97ad35f90c website: Update taint command docs to reflect new 0.12 usage 2019-06-03 15:36:38 -07:00
Kristin Laemmert f2a14d7c18 lang/funcs: fix error when `matchkeys` encountered a variable
`matchkeys` was returning a (false) error if the searchset was a
variable, since then the type of the keylist and searchset parameters
would not match.

This does slightly change the behavior: previously matchkeys would
produce an error if the parameters were not of the same type, for e.g.
if searchset was a list of strings and keylist was a list of integers.
  This no longer produces an error.
2019-06-03 18:00:53 -04:00
Kristin Laemmert e9e718b318
command/show (-json): fix panic if a moduleCall has a nil config (#21569)
In the unlikely event that a moduleCall has a nil config - for example,
if a nested module call includes a variable with a typo in an
attribute - continue gracefully.

This is an unusual edge case in the category of "probably should not happen", caused by
#21568
2019-06-03 13:04:21 -05:00
Kristin Laemmert 06a3333316 note: this is an unusual edgecase in the category of "probably should not happen"
If https://github.com/hashicorp/terraform/issues/21543 is
fixed, we can remove this check.
2019-06-03 14:00:46 -04:00
Martin Atkins 7dfdcb9c2d
Update CHANGELOG.md 2019-06-03 09:49:19 -07:00
Martin Atkins e85093ce08 configs/configload: Don't panic when version constraint is added
Previously, adding a version constraint to a module that was previously
recorded without a version in the module manifest would cause a panic.

Instead, we now use a slight variant of the "dependencies have changed"
error that doesn't try to print out a specific version number.
2019-06-03 09:45:30 -07:00
Martin Atkins c5285021fa internal/initwd: Test that version is rejected for local modules
This was already working, but since that codepath is separate from the
go-getter install codepath it's helpful to have a separate test for it,
in addition to the existing one for go-getter modules.
2019-06-03 09:45:30 -07:00
Kristin Laemmert 703f024cbd command/show (-json): fix panic if a moduleCall has a nil config
In the unlikely event that a moduleCall has a nil config - for example,
if a nested module call includes a variable with a typo in an
attribute - continue gracefully.
2019-06-03 11:19:03 -04:00
Kristin Laemmert ab9e98da3c
Update CHANGELOG.md 2019-06-03 08:15:29 -04:00
Kristin Laemmert 65fc037ecb
command/show (plan -json): fix panic (#21541)
* command/show -json: fix panic

afterUnknown should return only bools, not values.

* command/jsonplan: let's delete some redundant code!

the plan output was somewhat inconsistent with return values for
"after_unknown". This strives to fix that. If all "after" values are
known, return an empty object instead of iterating over values.

Also fixing some typos and general copypasta.
2019-06-03 07:14:23 -05:00
James Bardin ebc2e5fb56
Merge pull request #21549 from hashicorp/jbardin/empty-dynamic-attr
allow empty dynamic blocks with ConfigModeAttr
2019-06-01 12:01:49 -05:00
James Bardin 0133dda311 allow empty dynamic blocks with ConfigModeAttr
If a dynamic block is evaluated zero times, the body content will
contain 0 blocks. Allow the probe for ConfigModeAttr to accept that no
blocks with a matching attribute should still be converted to a block if
they are called with dynamicExpand.
2019-05-31 16:31:24 -05:00
Martin Atkins 6e5c6cbdea
Update CHANGELOG.md 2019-05-31 09:45:11 -07:00
Martin Atkins 55794eb658 lang/funcs: Don't panic when distinct called with empty list 2019-05-31 11:44:31 -05:00
enm10k 8118bf8d93 Fix a broken link in CHANGELOG.md (#21508) 2019-05-29 16:49:53 -05:00
James Bardin 7f5ffbfe90
Merge pull request #21439 from hashicorp/jbardin/init-backend
init always prompts for migration with most remote backend configurations
2019-05-29 16:01:40 -05:00
James Bardin ad883c6c50
Merge pull request #21443 from hashicorp/jbardin/unknowns-in-validation
filter unknowns from simple lists and maps in sdk
2019-05-29 15:59:49 -05:00
James Bardin 06dfc4abd8 allow setting -backend-config='' to unset override
There is currently no way to unset -backend-config during init, since
not setting that option assumes the user will use the saved config.
Allow setting `-backend-config=""` to specify no overrides.
2019-05-29 12:58:04 -05:00
Martin Atkins ff9235c464 build: remove Vagrantfile
This Vagrantfile hasn't been maintained for a long time and no longer
produces a correct and functioning development environment for Terraform.

Terraform's development environment is a pretty standard Go development
environment, so a custom VM setup for development is overkill. Maintaining
the Makefile and other similar dev environment helpers is already overhead
enough, and having this stale Vagrantfile here was occasionally causing
folks to try to use it and get frustrated that it didn't work.
2019-05-28 19:35:34 -07:00
Martin Atkins d512584497 command/jsonplan: Don't panic with mixtures of known/unknown/empty
The omitUnknowns and unknownAsBool functions were previously trying hard
to preserve the same collection types in the output as they had in the
input, by attempting to keep everything matched up so that the results
would be valid.

Unfortunately, this turns out to be a harder problem than we originally
thought: it was possible for a collection value going in to produce
inconsistent element types out (and thus a panic) in the following
situations:
- when a collection with mixed known and unknown values was passed in
  to omitUnknowns.
- when a collection of collections where the inner collections are a
  mixture of empty and not empty in unknownAsNull.

The results of these functions are only used to marshal to JSON anyway,
and JSON serialization can't distinguish between the three sequence types
or the two mapping types, so in practice we can just standardize on
converting all sequences to tuple and all mappings to object here and not
change the resulting output at all, and then we don't have to worry about
making sure all of the inner types get preserved exactly.

A nice consequence of that relaxation is that we can now do what we
originally wanted to do with unknownAsBool, and omit map keys and
object attributes altogether if their values would've been false,
producing a much more compact result. This is easiest to do now when
there's only one known user of this JSON plan output, and we know that
user will treat both false and omitted as the same here.
2019-05-28 19:33:21 -07:00
Brian Flad 3865b74780
Merge pull request #21122 from fbcbarbosa/patch-1
Document AWS_SDK_LOAD_CONFIG on s3 backend
2019-05-28 21:05:40 -05:00
Kristin Laemmert 9869fbc5c4
core: don't panic in NodeAbstractResourceInstance References() (#21445)
* core: don't panic in NodeAbstractResourceInstance References()

It is possible for s.Current to be nil. This was hard to reproduce, so
the root cause is still unknown, but we can guard against the symptom.

* add log statement
2019-05-28 17:27:38 -04:00
Radek Simko d3506b774f
Merge pull request #21476 from hashicorp/vendor-go-cmp
vendor: github.com/google/go-cmp@v0.3.0
2019-05-28 10:42:51 -05:00
James Bardin 6055cb632e filter unknowns from simple lists and maps in sdk
While there was already a check in the sdk to filter unknowns from
validation, it missed the case where those were in simple lists and maps.
2019-05-28 09:58:07 -04:00
Mateusz Gozdek b6de825723 backend/gcs: make Unlock error message more clear 2019-05-27 20:07:14 -07:00
Radek Simko 02437f067e
vendor: github.com/google/go-cmp@v0.3.0 2019-05-27 20:35:42 -05:00
Radek Simko f3fb3f8ccf
Merge pull request #21470 from hashicorp/vendor-go-mock
vendor: github.com/golang/mock@v1.3.1
2019-05-27 20:24:56 -05:00
Radek Simko 37f19cb9f5
vendor: github.com/golang/mock@v1.3.1 2019-05-27 12:22:03 +01:00
James Bardin c017149b31 don't store prepared backend config
The backend gets to "prepare" the configuration before Configure is
called, in order to validate the values and insert defaults. We don't
want to store this value in the "config state", because it will often
not match the raw config after it is prepared, forcing unecessary
backend migrations during init.

Since PrepareConfig is always called before Configure, we can store the
config value directly, and assume that it will be prepared in the same
manner each time.
2019-05-24 14:51:18 -04:00
James Bardin ee9a618369 don't migrate backend during init without override
If the backend config hashes match during init, and there are no new
backend override options, then we assume the existing config is OK.
Since init should be idempotent, we should be able to run init with no
options or config changes, and not effect the backends at all.
2019-05-24 11:31:04 -04:00
Joe Tavin 2c176fdf4b website/0.12 upgrade: Fix typo (#21426) 2019-05-24 10:06:01 -04:00
James Bardin cefc927e48 failing test for backend re-init 2019-05-23 18:21:52 -04:00
Sander van Harmelen f68673fbe4
Update CHANGELOG.md 2019-05-23 14:38:20 +02:00
Sander van Harmelen 486b8167f3
Update CHANGELOG.md 2019-05-23 14:36:53 +02:00
Sander van Harmelen 8fd3aa91a0
Merge pull request #21234 from hashicorp/svh/f-init-v0.12
Always try to select a workspace after initialization (v0.12)
2019-05-23 14:34:31 +02:00