Hello Community!
I have a question that is bugging me for some time. I will be thankful for explaining how it works under the hood and tips for solving it or using alternative approach.
Is it possible to use both, Optional and Computed, on attribute that is embedded resource ? Lets assume schema:
return map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"embedded": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"color": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
},
},
}
embedded is a Set with elements that have Resource schema.
This schema requires to configure name but leaves color as optional - if not provided, it might be computed by remote.
Such configuration ends in plan that is not clean every time when remote calculates color attribute. Plan indicates that embedded needs to be replaced. Having color as Computed only works well.
I’ve experimented with many functions like ConfigMode
, Set
orDiffSuppressFunc
but did not find suitable solution yet.
Thanks in advance.