destroy provisioner test
Ensure that we have destroy provisioner test that reference self
This commit is contained in:
parent
3223e352ea
commit
5b8e5ec276
|
@ -4891,7 +4891,7 @@ func TestContext2Apply_provisionerDestroy(t *testing.T) {
|
||||||
p.DiffFn = testDiffFn
|
p.DiffFn = testDiffFn
|
||||||
pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error {
|
pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error {
|
||||||
val, ok := c.Config["command"]
|
val, ok := c.Config["command"]
|
||||||
if !ok || val != "destroy a" {
|
if !ok || val != "destroy a bar" {
|
||||||
t.Fatalf("bad value for foo: %v %#v", val, c)
|
t.Fatalf("bad value for foo: %v %#v", val, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4904,7 +4904,7 @@ func TestContext2Apply_provisionerDestroy(t *testing.T) {
|
||||||
mustResourceInstanceAddr(`aws_instance.foo["a"]`).Resource,
|
mustResourceInstanceAddr(`aws_instance.foo["a"]`).Resource,
|
||||||
&states.ResourceInstanceObjectSrc{
|
&states.ResourceInstanceObjectSrc{
|
||||||
Status: states.ObjectReady,
|
Status: states.ObjectReady,
|
||||||
AttrsJSON: []byte(`{"id":"bar"}`),
|
AttrsJSON: []byte(`{"id":"bar","foo":"bar"}`),
|
||||||
},
|
},
|
||||||
mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`),
|
mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`),
|
||||||
)
|
)
|
||||||
|
@ -4955,7 +4955,7 @@ func TestContext2Apply_provisionerDestroyFail(t *testing.T) {
|
||||||
mustResourceInstanceAddr(`aws_instance.foo["a"]`).Resource,
|
mustResourceInstanceAddr(`aws_instance.foo["a"]`).Resource,
|
||||||
&states.ResourceInstanceObjectSrc{
|
&states.ResourceInstanceObjectSrc{
|
||||||
Status: states.ObjectReady,
|
Status: states.ObjectReady,
|
||||||
AttrsJSON: []byte(`{"id":"bar"}`),
|
AttrsJSON: []byte(`{"id":"bar","foo":"bar"}`),
|
||||||
},
|
},
|
||||||
mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`),
|
mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`),
|
||||||
)
|
)
|
||||||
|
@ -4985,6 +4985,7 @@ func TestContext2Apply_provisionerDestroyFail(t *testing.T) {
|
||||||
aws_instance.foo["a"]:
|
aws_instance.foo["a"]:
|
||||||
ID = bar
|
ID = bar
|
||||||
provider = provider["registry.terraform.io/hashicorp/aws"]
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
||||||
|
foo = bar
|
||||||
`)
|
`)
|
||||||
|
|
||||||
// Verify apply was invoked
|
// Verify apply was invoked
|
||||||
|
|
|
@ -664,9 +664,11 @@ func (d *evaluationStateData) GetResource(addr addrs.Resource, rng tfdiags.Sourc
|
||||||
if change.Action == plans.Delete {
|
if change.Action == plans.Delete {
|
||||||
// FIXME: we should not be evaluating resources that are going
|
// FIXME: we should not be evaluating resources that are going
|
||||||
// to be destroyed, but this needs to happen always since
|
// to be destroyed, but this needs to happen always since
|
||||||
// providers need to evaluate their configuration during a full
|
// destroy-time provisioners need to reference their self
|
||||||
// destroy, even of they depend on resources being destroyed.
|
// value, and providers need to evaluate their configuration
|
||||||
|
// during a full destroy, even of they depend on resources
|
||||||
|
// being destroyed.
|
||||||
|
//
|
||||||
// Since this requires a special transformer to try and fixup
|
// Since this requires a special transformer to try and fixup
|
||||||
// the order of evaluation when possible, reference it here to
|
// the order of evaluation when possible, reference it here to
|
||||||
// ensure that we remove the transformer when this is fixed.
|
// ensure that we remove the transformer when this is fixed.
|
||||||
|
|
|
@ -8,7 +8,7 @@ resource "aws_instance" "foo" {
|
||||||
|
|
||||||
provisioner "shell" {
|
provisioner "shell" {
|
||||||
when = "destroy"
|
when = "destroy"
|
||||||
command = "destroy ${each.key}"
|
command = "destroy ${each.key} ${self.foo}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue