Hello everyone,
I am trying to use a default values for a custom provided using the the terraform plugin framework[ 1]. However, when I remove the field from the template it does not detect the change in the plan and it says “No changes. Your infrastructure matches the configuration.”
These are the schema of my objects
"description": schema.StringAttribute{
Description: "Report description",
Optional: true,
Default: stringdefault.StaticString(""),
Computed: true,
},
"include_promotional_credits": schema.BoolAttribute{
Description: "",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
"advanced_analysis": schema.SingleNestedAttribute{
Attributes: map[string]schema.Attribute{
"forecast": schema.BoolAttribute{
Description: "",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
"not_trending": schema.BoolAttribute{
Description: "",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
"trending_down": schema.BoolAttribute{
Description: "",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
"trending_up": schema.BoolAttribute{
Description: "",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
},
Description: "",
Optional: true,
Computed: true,
Default: objectdefault.StaticValue(types.ObjectValueMust(AdvancedAnalysisModel{}.attrTypes(), AdvancedAnalysisModel{}.defaultObject())),
},
When I create my template as the following
resource "doit-console_report" "my-report" {
name = "test10"
description = "a"
include_promotional_credits = true
}
But if I remove the fields
resource "doit-console_report" "my-report" {
name = "test10"
}
It says:
No changes. Your infrastructure matches the configuration.
I believe it is related with the default value being the same value as the empty value
[1] Plugin Development - Framework: Default | Terraform | HashiCorp Developer