terraform
terraform copied to clipboard
Reject or warn about additional attributes during object type conversion
Terraform Version
1.5.1
Terraform Configuration Files
type Things struct {
A types.Bool `tfsdk:"A"`
B types.Bool `tfsdk:"B"`
}
type SomeResource struct {
Things things
}
<snip>
"things": schema.SingleNestedAttribute{
Attributes: map[string]schema.Attribute{
"B": schema.BoolAttribute{
Default: booldefault.StaticBool(false),
Optional: true,
Computed: true,
},
"B": schema.BoolAttribute{
Default: booldefault.StaticBool(false),
Optional: true,
Computed: true,
},
}
required: true,
}
resource "some_resource" "some_resource_name" {
things = {
A = true
should_fail_to_validate = "but doesn't"
}
}
Debug Output
n/a
Expected Behavior
terraform validate
should fail with a message that an unknown key is present.
Actual Behavior
terraform validate/plan/apply
all ran succesfully without errors or warning.
Steps to Reproduce
- Include the above model and schema in a provider.
-
terraform validate
.
Additional Context
It was suggested by @bflad to open an issue in this tracker instead, including some notes about what is being passed: https://github.com/hashicorp/terraform-plugin-framework/issues/805#issuecomment-1648521484
References
There appear to be a number of related issues already open:
- #28696
- #28727
- #29204
- #32015