I’m a newbie of custom providers, and now developing a custom provider resource having following schema.
Schema: map[string]*schema.Schema{
"input": {
Type: schema.TypeString,
Required: true,
},
"status": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
This resource creates an actual resource according to the input
variable, and then get status
of the created resource.
I want to detect the resource drift as status
value changed, so I set the status
variable in my ReadContext function.
func resourceReadContext(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
status := getResourceStatusBySomeApi()
d.Set("status", status)
return nil
}
After modifying the resource manually and run terraform apply
again, I expected UpdateContext function is called to fix the drift because status
variable is changed, but Terraform tells No changes. Your infrastructure matches the configuration.
Is it possible to detect drift and let terraform run UpdateContext when the specific computed value is changed?