Merge pull request #10106 from hashicorp/b-shadow-uuid
terraform: shadow errors with UUID() must be ignored
This commit is contained in:
commit
48295684ae
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
resource "aws_instance" "test" {
|
||||
value = "${uuid()}"
|
||||
}
|
Loading…
Reference in New Issue