mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
default optional+computed to prior value
This commit is contained in:
parent
673d6ca2bc
commit
3e281e1eda
@ -4543,6 +4543,11 @@ func TestContext2Plan_ignoreChangesWildcard(t *testing.T) {
|
||||
t.Error("computed id set in plan config")
|
||||
}
|
||||
|
||||
foo := req.Config.GetAttr("foo")
|
||||
if foo.IsNull() {
|
||||
t.Error(`missing "foo" during plan, was set to "bar" in state and config`)
|
||||
}
|
||||
|
||||
return testDiffFn(req)
|
||||
}
|
||||
|
||||
@ -4552,7 +4557,7 @@ func TestContext2Plan_ignoreChangesWildcard(t *testing.T) {
|
||||
mustResourceInstanceAddr("aws_instance.foo").Resource,
|
||||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"bar","ami":"ami-abcd1234","instance":"t2.micro","type":"aws_instance"}`),
|
||||
AttrsJSON: []byte(`{"id":"bar","ami":"ami-abcd1234","instance":"t2.micro","type":"aws_instance","foo":"bar"}`),
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`),
|
||||
)
|
||||
|
@ -1165,7 +1165,7 @@ func (n *NodeAbstractResource) processIgnoreChanges(prior, config cty.Value, sch
|
||||
// to the provider as if they were included in the configuration.
|
||||
ret, _ := cty.Transform(prior, func(path cty.Path, v cty.Value) (cty.Value, error) {
|
||||
attr := schema.AttributeByPath(path)
|
||||
if attr != nil && attr.Computed {
|
||||
if attr != nil && attr.Computed && !attr.Optional {
|
||||
return cty.NullVal(v.Type()), nil
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ variable "bar" {}
|
||||
resource "aws_instance" "foo" {
|
||||
ami = "${var.foo}"
|
||||
instance = "${var.bar}"
|
||||
foo = "bar"
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = all
|
||||
|
Loading…
Reference in New Issue
Block a user