diff --git a/command/show_test.go b/command/show_test.go index 746ea1706..5febe8578 100644 --- a/command/show_test.go +++ b/command/show_test.go @@ -244,13 +244,29 @@ func showFixtureProvider() *terraform.MockProvider { p := testProvider() p.GetSchemaReturn = showFixtureSchema() p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse { + idVal := req.ProposedNewState.GetAttr("id") + amiVal := req.ProposedNewState.GetAttr("ami") + if idVal.IsNull() { + idVal = cty.UnknownVal(cty.String) + } return providers.PlanResourceChangeResponse{ - PlannedState: req.ProposedNewState, + PlannedState: cty.ObjectVal(map[string]cty.Value{ + "id": idVal, + "ami": amiVal, + }), } } p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + idVal := req.PlannedState.GetAttr("id") + amiVal := req.PlannedState.GetAttr("ami") + if !idVal.IsKnown() { + idVal = cty.StringVal("placeholder") + } return providers.ApplyResourceChangeResponse{ - NewState: cty.UnknownAsNull(req.PlannedState), + NewState: cty.ObjectVal(map[string]cty.Value{ + "id": idVal, + "ami": amiVal, + }), } } return p diff --git a/command/test-fixtures/show-json/basic-delete/output.json b/command/test-fixtures/show-json/basic-delete/output.json index 297ded0e7..837ed5d01 100644 --- a/command/test-fixtures/show-json/basic-delete/output.json +++ b/command/test-fixtures/show-json/basic-delete/output.json @@ -18,7 +18,7 @@ "schema_version": 0, "values": { "ami": "bar", - "id": null + "id": "placeholder" } } ] @@ -37,11 +37,11 @@ ], "before": { "ami": "foo", - "id": null + "id": "placeholder" }, "after": { "ami": "bar", - "id": null + "id": "placeholder" }, "after_unknown": { "ami": false, @@ -61,7 +61,7 @@ ], "before": { "ami": "foo", - "id": null + "id": "placeholder" }, "after": null, "after_unknown": false diff --git a/command/test-fixtures/show-json/basic-delete/terraform.tfstate b/command/test-fixtures/show-json/basic-delete/terraform.tfstate index 4cf6ed7fb..db49d3e68 100644 --- a/command/test-fixtures/show-json/basic-delete/terraform.tfstate +++ b/command/test-fixtures/show-json/basic-delete/terraform.tfstate @@ -14,7 +14,8 @@ { "schema_version": 0, "attributes": { - "ami": "foo" + "ami": "foo", + "id": "placeholder" } } ] @@ -28,7 +29,8 @@ { "schema_version": 0, "attributes": { - "ami": "foo" + "ami": "foo", + "id": "placeholder" } } ] diff --git a/command/test-fixtures/show-json/basic-update/output.json b/command/test-fixtures/show-json/basic-update/output.json index d065edaf0..4f5f115fb 100644 --- a/command/test-fixtures/show-json/basic-update/output.json +++ b/command/test-fixtures/show-json/basic-update/output.json @@ -18,7 +18,7 @@ "schema_version": 0, "values": { "ami": "bar", - "id": null + "id": "placeholder" } } ] @@ -37,11 +37,11 @@ ], "before": { "ami": "bar", - "id": null + "id": "placeholder" }, "after": { "ami": "bar", - "id": null + "id": "placeholder" }, "after_unknown": { "ami": false, diff --git a/command/test-fixtures/show-json/basic-update/terraform.tfstate b/command/test-fixtures/show-json/basic-update/terraform.tfstate index f980cdfd5..dfc796a88 100644 --- a/command/test-fixtures/show-json/basic-update/terraform.tfstate +++ b/command/test-fixtures/show-json/basic-update/terraform.tfstate @@ -14,7 +14,8 @@ { "schema_version": 0, "attributes": { - "ami": "bar" + "ami": "bar", + "id": "placeholder" } } ]