diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index dc6af4acb..9c92b2f43 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -2010,6 +2010,25 @@ func TestContext2Plan_orphan(t *testing.T) { } } +// This tests that configurations with UUIDs don't produce errors. +// For shadows, this would produce errors since a UUID changes every time. +func TestContext2Plan_shadowUuid(t *testing.T) { + m := testModule(t, "plan-shadow-uuid") + p := testProvider("aws") + p.DiffFn = testDiffFn + ctx := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + }) + + _, err := ctx.Plan() + if err != nil { + t.Fatalf("err: %s", err) + } +} + func TestContext2Plan_state(t *testing.T) { m := testModule(t, "plan-good") p := testProvider("aws") diff --git a/terraform/shadow_context.go b/terraform/shadow_context.go index 226fd396b..5e0e31609 100644 --- a/terraform/shadow_context.go +++ b/terraform/shadow_context.go @@ -2,6 +2,7 @@ package terraform import ( "fmt" + "strings" "github.com/hashicorp/go-multierror" "github.com/mitchellh/copystructure" @@ -138,5 +139,17 @@ func (c *shadowContextCloser) CloseShadow() error { } func (c *shadowContextCloser) ShadowError() error { - return c.Components.ShadowError() + err := c.Components.ShadowError() + if err == nil { + return nil + } + + // This is a sad edge case: if the configuration contains uuid() at + // any point, we cannot reason aboyt the shadow execution. Tested + // with Context2Plan_shadowUuid. + if strings.Contains(err.Error(), "uuid()") { + err = nil + } + + return err } diff --git a/terraform/test-fixtures/plan-shadow-uuid/main.tf b/terraform/test-fixtures/plan-shadow-uuid/main.tf new file mode 100644 index 000000000..2b6ec72a0 --- /dev/null +++ b/terraform/test-fixtures/plan-shadow-uuid/main.tf @@ -0,0 +1,3 @@ +resource "aws_instance" "test" { + value = "${uuid()}" +}