I have a SetNestedAttribute in my schema that looks like this:
"attrs": schema.SetNestedAttribute{
Description: "...",
Required: true
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"stringattr": schema.StringAttribute{
Description: "...",
Required: true,
},
"boolattr": schema.BoolAttribute{
Description: "...",
Optional: true,
},
},
},
},
The service Iām writing this provider for can return additional defaults for attrs
, even when some other attrs are specified. For example, with HCL like this:
attrs = [
{
stringattr = "example"
boolattr = true
}
]
The service can return a list including both that attribute from the config, along with one or more additional attributes generated by the service.
This causes an error in the provider as expected:
ā·
ā Error: Provider produced inconsistent result after apply
ā
ā When applying changes to a.b, provider
ā "provider[\"asdf"]" produced an unexpected new value:
ā .example.attrs: length changed from 1 to 2.
ā
ā This is a bug in the provider, which should be reported in the provider's own issue tracker.
āµ
Is there any way to allow for some of the values in the state for a list to come from the config with some additional computed values? I tried changing the attribute to computed and using a planmodifier to add the expected elements to the list but that causes a different error:
Planning failed. Terraform encountered an error while generating this plan.
ā·
ā Error: Provider produced invalid plan
ā
ā Provider "asdf" planned an invalid value for
ā asdf_example.example.attrs: count in plan (2)
ā disagrees with count in config (1).
ā
ā This is a bug in the provider, which should be reported in the provider's own issue tracker.
āµ