diff --git a/internal/grpcwrap/provider.go b/internal/grpcwrap/provider.go index 00e323b503..8c2f3b1eee 100644 --- a/internal/grpcwrap/provider.go +++ b/internal/grpcwrap/provider.go @@ -154,6 +154,7 @@ func (p *provider) ValidateResourceTypeConfig(_ context.Context, req *tfplugin5. ClientCapabilities: providers.ClientCapabilities{ DeferralAllowed: true, WriteOnlyAttributesAllowed: true, + ComputedBlocksAllowed: true, }, }) @@ -867,6 +868,7 @@ func (p *provider) PlanAction(_ context.Context, req *tfplugin5.PlanAction_Reque ClientCapabilities: providers.ClientCapabilities{ DeferralAllowed: true, WriteOnlyAttributesAllowed: true, + ComputedBlocksAllowed: true, }, }) @@ -899,6 +901,7 @@ func (p *provider) InvokeAction(req *tfplugin5.InvokeAction_Request, server tfpl ClientCapabilities: providers.ClientCapabilities{ DeferralAllowed: true, WriteOnlyAttributesAllowed: true, + ComputedBlocksAllowed: true, }, }) diff --git a/internal/grpcwrap/provider6.go b/internal/grpcwrap/provider6.go index c7ceab017b..4e97b3af7f 100644 --- a/internal/grpcwrap/provider6.go +++ b/internal/grpcwrap/provider6.go @@ -1196,6 +1196,7 @@ func (p *provider6) PlanAction(_ context.Context, req *tfplugin6.PlanAction_Requ ClientCapabilities: providers.ClientCapabilities{ DeferralAllowed: true, WriteOnlyAttributesAllowed: true, + ComputedBlocksAllowed: true, }, }) @@ -1228,6 +1229,7 @@ func (p *provider6) InvokeAction(req *tfplugin6.InvokeAction_Request, server tfp ClientCapabilities: providers.ClientCapabilities{ DeferralAllowed: true, WriteOnlyAttributesAllowed: true, + ComputedBlocksAllowed: true, }, }) diff --git a/internal/moduletest/graph/node_provider.go b/internal/moduletest/graph/node_provider.go index 96a7945989..0bb56da6e5 100644 --- a/internal/moduletest/graph/node_provider.go +++ b/internal/moduletest/graph/node_provider.go @@ -108,6 +108,7 @@ func (n *NodeProviderConfigure) Execute(ctx *EvalContext) { ClientCapabilities: providers.ClientCapabilities{ DeferralAllowed: ctx.deferralAllowed, WriteOnlyAttributesAllowed: true, + ComputedBlocksAllowed: true, }, }) diff --git a/internal/plugin6/grpc_provider.go b/internal/plugin6/grpc_provider.go index 2b2c2f394c..bba74e2461 100644 --- a/internal/plugin6/grpc_provider.go +++ b/internal/plugin6/grpc_provider.go @@ -2073,6 +2073,7 @@ func clientCapabilitiesToProto(c providers.ClientCapabilities) *proto6.ClientCap DeferralAllowed: c.DeferralAllowed, WriteOnlyAttributesAllowed: c.WriteOnlyAttributesAllowed, StorePlannedPrivate: c.StorePlannedPrivate, + ComputedBlocksAllowed: c.ComputedBlocksAllowed, } } diff --git a/internal/providers/provider.go b/internal/providers/provider.go index 011294ebfc..f127ab4a3e 100644 --- a/internal/providers/provider.go +++ b/internal/providers/provider.go @@ -312,6 +312,13 @@ type ClientCapabilities struct { // returned from PlanResourceChange, and return it with the final // PlanResourceChange call. StorePlannedPrivate bool + + // computed_blocks_allowed indicates that the client can handle optionally + // computed nested block values in resources. Because older versions of + // Terraform without this capability will ignore the computed flag in the + // schema, it is up to the provider to return an appropriate diagnostic when + // a resource requiring the computed behavior is used. + ComputedBlocksAllowed bool } type ValidateProviderConfigRequest struct { diff --git a/internal/stacks/stackruntime/internal/stackeval/client_capabilities.go b/internal/stacks/stackruntime/internal/stackeval/client_capabilities.go index eb39d3dfe9..781cde3907 100644 --- a/internal/stacks/stackruntime/internal/stackeval/client_capabilities.go +++ b/internal/stacks/stackruntime/internal/stackeval/client_capabilities.go @@ -11,5 +11,6 @@ func ClientCapabilities() providers.ClientCapabilities { return providers.ClientCapabilities{ DeferralAllowed: true, WriteOnlyAttributesAllowed: true, + ComputedBlocksAllowed: true, } } diff --git a/internal/terraform/context_plan_test.go b/internal/terraform/context_plan_test.go index 22f715e5ce..6bd03d96a4 100644 --- a/internal/terraform/context_plan_test.go +++ b/internal/terraform/context_plan_test.go @@ -1749,6 +1749,7 @@ func TestContext2Plan_blockNestingGroup(t *testing.T) { DeferralAllowed: false, WriteOnlyAttributesAllowed: true, StorePlannedPrivate: true, + ComputedBlocksAllowed: true, }, } if !cmp.Equal(got, want, valueTrans) { diff --git a/internal/terraform/eval_context_builtin.go b/internal/terraform/eval_context_builtin.go index 09590c253b..7e50ee8d28 100644 --- a/internal/terraform/eval_context_builtin.go +++ b/internal/terraform/eval_context_builtin.go @@ -229,12 +229,9 @@ func (ctx *BuiltinEvalContext) ConfigureProvider(addr addrs.AbsProviderConfig, c } req := providers.ConfigureProviderRequest{ - TerraformVersion: version.String(), - Config: cfg, - ClientCapabilities: providers.ClientCapabilities{ - DeferralAllowed: ctx.Deferrals().DeferralAllowed(), - WriteOnlyAttributesAllowed: true, - }, + TerraformVersion: version.String(), + Config: cfg, + ClientCapabilities: ctx.ClientCapabilities(), } resp := p.ConfigureProvider(req) @@ -661,6 +658,7 @@ func (ctx *BuiltinEvalContext) ClientCapabilities() providers.ClientCapabilities DeferralAllowed: ctx.Deferrals().DeferralAllowed(), WriteOnlyAttributesAllowed: true, StorePlannedPrivate: true, + ComputedBlocksAllowed: true, } } diff --git a/internal/terraform/eval_context_mock.go b/internal/terraform/eval_context_mock.go index e1b54ce439..9e3e7e1f0d 100644 --- a/internal/terraform/eval_context_mock.go +++ b/internal/terraform/eval_context_mock.go @@ -448,6 +448,8 @@ func (ctx *MockEvalContext) ClientCapabilities() providers.ClientCapabilities { return providers.ClientCapabilities{ DeferralAllowed: ctx.Deferrals().DeferralAllowed(), WriteOnlyAttributesAllowed: true, + StorePlannedPrivate: true, + ComputedBlocksAllowed: true, } }