Just getting into terraform provider development, and my provider needs a boolean attribute, but I’d like it to default to false. Maybe I’m missing an import, but when I try to do something like:
func (p *myProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "A provider",
Attributes: map[string]schema.Attribute{
...
"modular": schema.BoolAttribute{
Description: "Description for a boolean option",
Optional: true,
Default: booldefault.StaticBool(false),
},
...
I’m getting an error:
unknown field Default in struct literal of type "github.com/hashicorp/terraform-plugin-framework/provider/schema".BoolAttribute (compiler MissingLitField)
Looking into the provider schema: terraform-plugin-framework/provider/schema/bool_attribute.go at main · hashicorp/terraform-plugin-framework · GitHub
There is not a way to set a default this way. I’m looking for a suggestion to set a default for a schema attribute for a provider. Thank you in advance!