Skip to content

feat: consider adding wait for desired state after azapi_resource create #1031

@matt-FFFFFF

Description

@matt-FFFFFF

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:

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.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions