terraform/helper
Chris Marchesi 3fa11e456b
helper/schema: Clear existing map/set/list contents before overwriting
There are situations where one may need to write to a set, list, or map
more than once per single TF operation (apply/refresh/etc). In these
cases, further writes using Set (example: d.Set("some_set", newSet))
currently create unstable results in the set writer (the name of the
writer layer that holds the data set by these calls) because old keys
are not being cleared out first.

This bug is most visible when using sets. Example: First write to set
writes elements that have been hashed at 10 and 20, and the second write
writes elements that have been hashed at 30 and 40. While the set length
has been correctly set at 2, since a set is basically a map (as is the
entire map writer) and map results are non-deterministic, reads to this
set will now deliver unstable results in a random but predictable
fashion as the map results are delivered to the caller non-deterministic
- sometimes you may correctly get 30 and 40, but sometimes you may get
10 and 20, or even 10 and 30, etc.

This problem propagates to state which is even more damaging as unstable
results are set to state where they become part of the permanent data
set going forward.

The problem also applies to lists and maps. This is probably more of an
issue with maps as a map can contain any key/value combination and hence
there is no predictable pattern where keys would be overwritten with
default or zero values. This is contrary to complex lists, which has
this problem as well, but since lists are deterministic and the length
of a list properly gets updated during the overwrite, the problem is
masked by the fact that a read will only read to the boundary of the
list, skipping any bad data that may still be available due past the
list boundary.

This update clears the child contents of any set, list, or map before
beginning a new write to address this issue. Tests are included for all
three data types.
2017-11-05 12:04:23 -08:00
..
acctest Fix swallowed err in acctest package 2017-07-19 16:24:41 -07:00
config Fix failing tests 2014-10-09 21:29:21 -07:00
copy config/module: use the raw source as part of the key 2016-09-30 10:44:46 -07:00
didyoumean helper/didyoumean: helper library for "Did you mean ...? suggestions 2017-10-16 17:50:57 -07:00
diff helper/diff: handle unknownvariablevalue 2016-11-09 14:28:16 -08:00
encryption provider/aws: Extract helper/encryption library 2016-12-06 14:24:21 -06:00
experiment terraform: default shadow to false 2017-02-06 18:02:32 -08:00
hashcode hashcode: "Strings" function for hashing slices of strings 2017-10-20 14:54:23 -07:00
hilmapstructure core: Defeat backward compatibilty in mapstructure 2016-06-08 18:38:41 +01:00
logging helper: Allow logs isolation per acceptance test 2017-10-14 16:39:11 +03:00
mutexkv provider/aws: serialize SG rule access to fix race condition 2015-11-18 12:39:59 -06:00
pathorcontents ssh: accept private key contents instead of path 2015-11-12 14:59:14 -06:00
resource helper: Escape test name in TF_LOG_PATH_MASK 2017-10-31 06:48:57 +00:00
schema helper/schema: Clear existing map/set/list contents before overwriting 2017-11-05 12:04:23 -08:00
shadow Make sure shadow.closeWalker doesn't copy Mutexes 2017-07-07 11:20:54 -04:00
signalwrapper providers/azurerm: cancellable storage account creation 2016-08-15 21:12:32 -07:00
slowmessage helper/slowmessage 2017-02-14 09:27:23 -08:00
structure Adding tests for each helper method 2017-03-28 12:59:46 +01:00
validation helper/validation: Add NoZeroValues 2017-09-25 17:19:23 -07:00
variables command/init: backend-config accepts key=value pairs 2017-03-16 23:27:05 -07:00
wrappedreadline command: split out and tag code so compilation works on Solaris 2016-11-14 00:32:01 -08:00
wrappedstreams helper/wrappedstreams: get original console input/output on Windows 2016-11-21 10:44:01 -08:00
README.md dos2unix 2014-07-28 10:43:00 -07:00

README.md

Helper Libraries

This folder contains helper libraries for Terraform plugins. A running joke is that this is "Terraform standard library" for plugins. The goal of the packages in this directory are to provide high-level helpers to make it easier to implement the various aspects of writing a plugin for Terraform.