Skip to content

Commit

Permalink
azurerm_iothub - fix a bug for local_auth_enabled (#24326)
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyeqf authored Jan 4, 2024
1 parent 978c3be commit 1f059ba
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/services/iothub/iothub_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/url"
"regexp"
"sort"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -971,6 +972,31 @@ func resourceIotHubUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
return fmt.Errorf("waiting for update of %q: %+v", id, err)
}

// When the `local_authentication_enabled` updated, GET on the resource is returned with 404 for a while.
// Tracked on https://github.com/Azure/azure-rest-api-specs/issues/27183
timeout, _ := ctx.Deadline()
stateConf := &pluginsdk.StateChangeConf{
Pending: []string{"404"},
Target: []string{"200"},
Refresh: func() (result interface{}, state string, err error) {
resp, err := client.Get(ctx, id.ResourceGroup, id.Name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return resp, strconv.Itoa(resp.StatusCode), nil
}
return resp, strconv.Itoa(resp.StatusCode), err
}
return resp, strconv.Itoa(resp.StatusCode), nil
},
Delay: 1 * time.Minute,
PollInterval: 1 * time.Minute,
Timeout: time.Until(timeout),
}

if _, err := stateConf.WaitForStateContext(ctx); err != nil {
return fmt.Errorf("waiting for creation/update of %q: %+v", id, err)
}

d.SetId(id.ID())

return resourceIotHubRead(d, meta)
Expand Down

0 comments on commit 1f059ba

Please sign in to comment.