-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Hi @ms-henglu
In the AzureRM provider, certain resources have a custom poller for the GET after PUT read. This allows the certain resources to wait until they are in a particular state before proceeding.
We need this because the API will sometimes return complete, but the resource has not finished provisioning.
Example resource: Microsoft.AAD/domainServices@2025-06-01
We should wait for the following:
"properties": {
"replicaSets": [
{
// ...
"serviceStatus": "Running"
// ...
}
]
}Proposal
Implement a user-configurable custom wait_for_desired_state attribute that uses JMESPath expressions which must evaluate to true. Else the GET is retried.
E.g.
resource "azapi_resource" "example" {
# other stuff ...
wait_for_desired_state = [
"properties.replicaSets[?serviceStatus != 'Running'] | length(@) == `0`" # must evaluate to true
"properties.something == `ok`" # simpler example
]
}We then implement a custom ShouldRetry func here:
terraform-provider-azapi/internal/services/azapi_resource.go
Lines 906 to 909 in 6438c33
| RetryOptions: clients.CombineRetryOptions( | |
| clients.NewRetryOptionsForReadAfterCreate(), | |
| clients.NewRetryOptions(plan.Retry), | |
| ), |
We could add:
clients.NewRetryFromWaitForDesiredState(plan.WaitForDesiredState)We already have the JMESpath functions we need in the utils package.