terraform/terraform
Martin Atkins 15cd6d8300 core: Retain prior state if update fails with no new state
In an ideal world, providers are supposed to respond to errors during
apply by returning a partial new state alongside the error diagnostics.
In practice though, our SDK leaves the new value set to nil for certain
errors, which was causing Terraform to "forget" the object altogether by
assuming that the provider intended to say "null".

We now adjust that assumption to apply only in the delete case. In all
other cases (including updates) we retain the prior state if the new
state is given as nil. Although we could potentially fix this in the SDK
itself, I expect this is a likely bug in other future SDKs for other
languages too, so this new assumption is a safer one to make to be
resilient to data loss when providers don't behave perfectly.

Providers that return both nil new value and no errors are considered
buggy, but unfortunately that applies to the mocks in many of our tests,
so for pragmatic reasons we can't generate an error for that case as we do
for other "should never happen" situations. Instead, we'll just retain the
prior value in the state so the user can retry.
2019-01-18 16:54:52 -08:00
..
test-fixtures core: Retain prior state if update fails with no new state 2019-01-18 16:54:52 -08:00
context.go export ShimLegacyState to use it in resource tests 2018-12-04 15:38:34 -05:00
context_apply_test.go core: Retain prior state if update fails with no new state 2019-01-18 16:54:52 -08:00
context_components.go update to start a new process for each plugin 2018-10-16 19:14:11 -07:00
context_components_test.go replace provider and provisioner types in tests 2018-10-16 19:11:09 -07:00
context_fixtures_test.go core: A "go fmt" catchup 2018-10-16 19:14:11 -07:00
context_graph_type.go core: Remove machinery for the "input" walk 2018-10-16 18:49:20 -07:00
context_import.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
context_import_test.go add implied providers during import 2018-12-04 16:04:19 -05:00
context_input.go core: Context.Input as config walk, rather than graph walk 2018-10-16 18:49:20 -07:00
context_input_test.go core: Fix two TestContext2Input_... tests 2018-10-16 19:14:11 -07:00
context_plan_test.go add missing key-value from test 2018-11-19 18:58:29 -05:00
context_refresh_test.go core: Automatically upgrade resource instance states on read 2018-11-30 11:22:39 -08:00
context_test.go export MustShimLegacyState for resource tests 2018-10-16 19:14:11 -07:00
context_validate_test.go core: Validate depends_on and ignore_changes traversals 2018-12-17 09:02:25 -08:00
diff.go fixes for the remaining tests 2018-11-19 18:56:50 -05:00
diff_test.go re-count the flatmapped containers 2018-11-16 15:26:16 -05:00
edge_destroy.go
eval.go core: EvalSequence must continue when only warnings are returned 2018-10-16 18:49:20 -07:00
eval_apply.go core: Retain prior state if update fails with no new state 2019-01-18 16:54:52 -08:00
eval_check_prevent_destroy.go core: Handle forced-create_before_destroy during the plan walk 2018-10-16 19:14:11 -07:00
eval_context.go ResourceProvisioner to provisioners.Interface 2018-10-16 19:11:09 -07:00
eval_context_builtin.go don't expand EachMode from state during validation 2018-12-17 12:34:57 -05:00
eval_context_builtin_test.go terraform: More wiring in of new provider types 2018-10-16 19:12:54 -07:00
eval_context_mock.go ResourceProvisioner to provisioners.Interface 2018-10-16 19:11:09 -07:00
eval_count.go core: Update EvalCountFixZeroOneBoundaryGlobal for new state types 2018-10-16 19:14:11 -07:00
eval_count_boundary.go core: Update EvalCountFixZeroOneBoundaryGlobal for new state types 2018-10-16 19:14:11 -07:00
eval_count_computed.go
eval_diff.go core: Make resource type schema versions visible to callers 2018-11-27 15:53:54 -08:00
eval_diff_test.go core: A "go fmt" catchup 2018-10-16 19:14:11 -07:00
eval_error.go
eval_filter.go
eval_filter_operation.go
eval_if.go
eval_import_state.go terraform: More wiring in of new provider types 2018-10-16 19:12:54 -07:00
eval_lang.go move "configschema" from "config" to "configs" 2018-10-16 18:50:29 -07:00
eval_local.go core: Detect and reject self-referencing local values 2018-12-19 13:46:01 -08:00
eval_local_test.go core: Detect and reject self-referencing local values 2018-12-19 13:46:01 -08:00
eval_noop.go
eval_output.go core: Allow planned output changes to be updated during apply 2018-11-05 16:02:45 -08:00
eval_output_test.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
eval_provider.go first step in core provider type replacement 2018-10-16 19:11:09 -07:00
eval_provider_test.go replace provider and provisioner types in tests 2018-10-16 19:11:09 -07:00
eval_provisioner.go ResourceProvisioner to provisioners.Interface 2018-10-16 19:11:09 -07:00
eval_provisioner_test.go replace provider and provisioner types in tests 2018-10-16 19:11:09 -07:00
eval_read_data.go core: Make resource type schema versions visible to callers 2018-11-27 15:53:54 -08:00
eval_refresh.go core: Make resource type schema versions visible to callers 2018-11-27 15:53:54 -08:00
eval_sequence.go core: EvalSequence to handle EvalEarlyExitError 2018-10-16 18:49:20 -07:00
eval_sequence_test.go
eval_state.go don't allow EvalWriteState without a provider 2018-12-18 13:09:45 -05:00
eval_state_test.go export MustShimLegacyState for resource tests 2018-10-16 19:14:11 -07:00
eval_state_upgrade.go core: Automatically upgrade resource instance states on read 2018-11-30 11:22:39 -08:00
eval_test.go
eval_validate.go make connection host Required 2018-12-19 15:22:01 -05:00
eval_validate_selfref.go core: Make resource type schema versions visible to callers 2018-11-27 15:53:54 -08:00
eval_validate_selfref_test.go move "configschema" from "config" to "configs" 2018-10-16 18:50:29 -07:00
eval_validate_test.go fix provisioner tests 2018-12-19 16:02:56 -05:00
eval_variable.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
evaltree_provider.go first step in core provider type replacement 2018-10-16 19:11:09 -07:00
evaluate.go core: path.module, path.root, path.cwd use fwd slashes on all platforms 2018-12-19 13:47:42 -08:00
evaluate_test.go core: path.module, path.root, path.cwd use fwd slashes on all platforms 2018-12-19 13:47:42 -08:00
evaluate_valid.go core: Specialized errors for incorrect indexes in resource reference 2018-12-20 13:55:42 -08:00
evaluate_valid_test.go core: Specialized errors for incorrect indexes in resource reference 2018-12-20 13:55:42 -08:00
features.go output warning flag 2017-11-28 14:18:54 -05:00
graph.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
graph_builder.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
graph_builder_apply.go core: Clean up resource states when they are orphaned 2018-10-16 19:14:11 -07:00
graph_builder_apply_test.go export MustShimLegacyState for resource tests 2018-10-16 19:14:11 -07:00
graph_builder_destroy_plan.go core: A "go fmt" catchup 2018-10-16 19:14:11 -07:00
graph_builder_eval.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
graph_builder_import.go core: Don't create indirect provider dependencies for references 2018-10-16 18:49:20 -07:00
graph_builder_plan.go core: A "go fmt" catchup 2018-10-16 19:14:11 -07:00
graph_builder_plan_test.go terraform.Schemas: export struct fields 2018-10-16 19:14:11 -07:00
graph_builder_refresh.go core: A "go fmt" catchup 2018-10-16 19:14:11 -07:00
graph_builder_refresh_test.go export MustShimLegacyState for resource tests 2018-10-16 19:14:11 -07:00
graph_builder_test.go core: Get tests compiling again 2018-10-16 18:46:46 -07:00
graph_builder_validate.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
graph_dot.go
graph_dot_test.go terraform: remove ConnectDependents and related interfaces 2017-02-03 14:25:54 +01:00
graph_interface_subgraph.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
graph_test.go update some graph builder tests 2018-10-16 19:14:11 -07:00
graph_walk.go core: Remove GraphWalkerPanicwrap, etc 2018-10-16 18:48:28 -07:00
graph_walk_context.go core: Evaluate resource references from plan where possible 2018-10-16 19:14:11 -07:00
graph_walk_operation.go core: Remove machinery for the "input" walk 2018-10-16 18:49:20 -07:00
graph_walk_test.go
graphtype_string.go core: update Stringer implementations for GraphType and walkOperation 2018-10-16 18:49:20 -07:00
hook.go terraform: More wiring in of new provider types 2018-10-16 19:12:54 -07:00
hook_mock.go terraform: More wiring in of new provider types 2018-10-16 19:12:54 -07:00
hook_stop.go command: Fix TestPlan_shutdown 2018-11-08 08:57:11 -08:00
hook_stop_test.go
hook_test.go core: Fix various compile-time errors in tests 2018-10-16 19:14:11 -07:00
instancetype.go
instancetype_string.go Update various files for new version of "stringer" 2017-12-11 13:26:29 -08:00
interpolate.go core: Remove machinery for the "input" walk 2018-10-16 18:49:20 -07:00
module_dependencies.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
module_dependencies_test.go export MustShimLegacyState for resource tests 2018-10-16 19:14:11 -07:00
node_count_boundary.go core: Update EvalCountFixZeroOneBoundaryGlobal for new state types 2018-10-16 19:14:11 -07:00
node_data_destroy.go rename NodeDestroyableDataResourceInstance 2018-12-18 13:22:21 -05:00
node_data_refresh.go rename NodeDestroyableDataResourceInstance 2018-12-18 13:22:21 -05:00
node_data_refresh_test.go rename NodeDestroyableDataResourceInstance 2018-12-18 13:22:21 -05:00
node_local.go core: Local and output values must reference destroy nodes too 2018-10-16 18:49:20 -07:00
node_module_removed.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
node_module_variable.go core: Remove machinery for the "input" walk 2018-10-16 18:49:20 -07:00
node_module_variable_test.go core: Update TestNodeApplyableModuleVariablePath for new address type 2018-10-16 18:48:28 -07:00
node_output.go core: Remove machinery for the "input" walk 2018-10-16 18:49:20 -07:00
node_output_orphan.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
node_provider.go WIP reference providers by full name 2017-11-02 15:00:06 -04:00
node_provider_abstract.go core: A "go fmt" catchup 2018-10-16 19:14:11 -07:00
node_provider_disabled.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
node_provider_eval.go core: Context.Eval method 2018-10-16 18:46:46 -07:00
node_provisioner.go core: NodeProvisioner.Name update for new address types 2018-10-16 18:48:28 -07:00
node_resource_abstract.go core: Attach schemas to nodes created by ResourceCountTransformer 2018-12-07 17:05:36 -08:00
node_resource_apply.go core: NodeApplyableResource only depends on count and for_each 2018-10-16 19:14:11 -07:00
node_resource_apply_instance.go core: Reinstate state-based tracking of data resource dependencies 2018-10-16 19:14:11 -07:00
node_resource_destroy.go core: Clean up resource states when they are orphaned 2018-10-16 19:14:11 -07:00
node_resource_destroy_deposed.go core: NodePlanDeposedResourceInstanceObject populate EvalReadStateDeposed 2018-11-30 11:22:39 -08:00
node_resource_plan.go core: Handle forced-create_before_destroy during the plan walk 2018-10-16 19:14:11 -07:00
node_resource_plan_destroy.go core: Always set ProviderAddr on EvalDiffDestroy 2018-10-16 19:14:11 -07:00
node_resource_plan_instance.go core: Reinstate state-based tracking of data resource dependencies 2018-10-16 19:14:11 -07:00
node_resource_plan_orphan.go core: Record correct provider address in orphan destroy plan 2018-10-16 19:14:11 -07:00
node_resource_refresh.go rename NodeDestroyableDataResourceInstance 2018-12-18 13:22:21 -05:00
node_resource_refresh_test.go export MustShimLegacyState for resource tests 2018-10-16 19:14:11 -07:00
node_resource_validate.go make connection host Required 2018-12-19 15:22:01 -05:00
node_root_variable.go core: render variables, locals and outputs nicely in "terraform graph" 2018-10-16 18:46:46 -07:00
path.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
plan.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
provider_mock.go core: Automatically upgrade resource instance states on read 2018-11-30 11:22:39 -08:00
provisioner_mock.go fix provisioner tests 2018-12-19 16:02:56 -05:00
resource.go insert resource timeouts into the config schema 2018-10-30 13:14:08 -04:00
resource_address.go core: NewLegacyResourceInstanceAddress correct handling of addrs.NoKey 2018-10-16 18:46:46 -07:00
resource_address_test.go configs: Re-unify the ManagedResource and DataResource types 2018-10-16 18:44:26 -07:00
resource_provider.go first step in core provider type replacement 2018-10-16 19:11:09 -07:00
resource_provider_mock.go minor race issue in mockResourceProvider 2017-12-20 09:18:38 -05:00
resource_provider_mock_test.go terraform: More wiring in of new provider types 2018-10-16 19:12:54 -07:00
resource_provisioner.go provisioners: Add Factory type and FactoryFixed helper 2018-10-16 19:14:11 -07:00
resource_provisioner_mock.go move "configschema" from "config" to "configs" 2018-10-16 18:50:29 -07:00
resource_provisioner_mock_test.go replace provider and provisioner types in tests 2018-10-16 19:11:09 -07:00
resource_test.go some basic tests for NewResourceConfigShimmed 2018-10-26 15:01:30 -04:00
schemas.go core: Automatically upgrade resource instance states on read 2018-11-30 11:22:39 -08:00
schemas_test.go terraform.Schemas: export struct fields 2018-10-16 19:14:11 -07:00
state.go restore (via copypaste) terraform.State.Remove 2019-01-03 22:06:30 -05:00
state_filter.go restore (via copypaste) terraform.State.Remove 2019-01-03 22:06:30 -05:00
state_test.go restore (via copypaste) terraform.State.Remove 2019-01-03 22:06:30 -05:00
state_upgrade_v1_to_v2.go terraform: convert empty path to root path in V1 state 2017-03-21 11:37:12 -07:00
state_upgrade_v2_to_v3.go terraform: V1 to V2 upgrade should treat nil path as root path 2017-03-21 11:12:44 -07:00
state_v1.go
terraform_test.go command: "terraform init" can partially initialize for 0.12upgrade 2019-01-14 11:33:21 -08:00
testing.go terraform: support backends in the state 2017-01-26 14:33:49 -08:00
transform.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_attach_config_provider.go core: Attach resource and provider config schemas during graph build 2018-10-16 18:46:46 -07:00
transform_attach_config_resource.go core: Additional trace logging in attach resource config transformer 2018-10-16 18:48:28 -07:00
transform_attach_schema.go core: Make resource type schema versions visible to callers 2018-11-27 15:53:54 -08:00
transform_attach_state.go attach a deep copy of ResourceState 2018-12-17 18:08:53 -05:00
transform_config.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_config_flat.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_config_flat_test.go core: Get tests compiling again 2018-10-16 18:46:46 -07:00
transform_config_old.go terraform: remove config transformer old 2017-01-26 19:57:46 -08:00
transform_config_test.go core: Get tests compiling again 2018-10-16 18:46:46 -07:00
transform_count_boundary.go core: Update EvalCountFixZeroOneBoundaryGlobal for new state types 2018-10-16 19:14:11 -07:00
transform_destroy_cbd.go CBD transformer test update 2018-10-16 19:14:11 -07:00
transform_destroy_cbd_test.go CBD transformer test update 2018-10-16 19:14:11 -07:00
transform_destroy_edge.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
transform_destroy_edge_test.go core: Fetch schemas during context construction 2018-10-16 18:49:20 -07:00
transform_diff.go core: Handle forced-create_before_destroy during the plan walk 2018-10-16 19:14:11 -07:00
transform_diff_test.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
transform_expand.go terraform: more dead code removal 2017-01-26 19:47:02 -08:00
transform_expand_test.go
transform_import_provider.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_import_state.go add implied providers during import 2018-12-04 16:04:19 -05:00
transform_local.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_module_variable.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_module_variable_test.go core: Get tests compiling again 2018-10-16 18:46:46 -07:00
transform_orphan_count.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
transform_orphan_count_test.go export MustShimLegacyState for resource tests 2018-10-16 19:14:11 -07:00
transform_orphan_output.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
transform_orphan_resource.go core: Clean up resource states when they are orphaned 2018-10-16 19:14:11 -07:00
transform_orphan_resource_test.go core: OrphanResourceTransformer -> OrphanResourceInstanceTransformer 2018-10-16 19:14:11 -07:00
transform_output.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_provider.go core: Better error message for prematurely-removed provider config 2018-10-16 19:14:11 -07:00
transform_provider_test.go core: Update ProviderTransformer tests for new ImportTarget interface 2018-10-16 18:48:28 -07:00
transform_provisioner.go core: Make provisioner schemas available to plan resource instance nodes 2018-10-16 18:49:20 -07:00
transform_provisioner_test.go core: Be more explicit in how we handle create_before_destroy 2018-10-16 19:14:11 -07:00
transform_reference.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
transform_reference_test.go core: Fix ReferenceTransformer tests 2018-10-16 18:48:28 -07:00
transform_removed_modules.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
transform_resource_count.go core: Attach schemas to nodes created by ResourceCountTransformer 2018-12-07 17:05:36 -08:00
transform_root.go terraform: provider transform is converted to new graph world view 2017-01-26 20:58:22 -08:00
transform_root_test.go core: NodeAbstractResource correct default result from ProvidedBy 2018-10-16 18:48:28 -07:00
transform_state.go core: Be more explicit in how we handle create_before_destroy 2018-10-16 19:14:11 -07:00
transform_targets.go don't check for targeted downstream from providers 2018-10-16 18:49:20 -07:00
transform_targets_test.go core: Get tests compiling again 2018-10-16 18:46:46 -07:00
transform_transitive_reduction.go
transform_transitive_reduction_test.go terraform.Schemas: export struct fields 2018-10-16 19:14:11 -07:00
transform_variable.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_vertex.go
transform_vertex_test.go
ui_input.go
ui_input_mock.go
ui_input_prefix.go
ui_input_prefix_test.go
ui_output.go
ui_output_callback.go
ui_output_callback_test.go
ui_output_mock.go minor race fix in tests 2017-10-02 16:19:01 -04:00
ui_output_mock_test.go
ui_output_provisioner.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
ui_output_provisioner_test.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
upgrade_state_v1_test.go Fix swallowed tests in terraform package tests 2017-07-20 02:23:43 -07:00
upgrade_state_v2_test.go
user_agent.go Standardize http.Client creation with User-Agent 2018-02-28 12:09:50 -05:00
util.go Resolve resource provider types in config package 2017-06-09 14:03:59 -07:00
util_test.go Resolve resource provider types in config package 2017-06-09 14:03:59 -07:00
valuesourcetype_string.go Fix wildcard dependencies when upgrading states 2018-11-15 13:17:15 +01:00
variables.go core: Remove GraphSemanticChecker, etc 2018-11-26 08:25:03 -08:00
variables_test.go core: Remove GraphSemanticChecker, etc 2018-11-26 08:25:03 -08:00
version.go use the new version package 2017-10-19 21:48:08 -04:00
version_required.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
walkoperation_string.go core: update Stringer implementations for GraphType and walkOperation 2018-10-16 18:49:20 -07:00