Skip to content

Commit

Permalink
azurerm_app_configuration_{key|feature} - prelong wait time for the…
Browse files Browse the repository at this point in the history
… role permission to be done propagated (#21337)

* fix role permission to be done propagated

* fix comment

* fix
  • Loading branch information
teowa authored Apr 12, 2023
1 parent c603554 commit 973e7a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,25 @@ func (k FeatureResource) Create() sdk.ResourceFunc {
}
featureKey := fmt.Sprintf("%s/%s", FeatureKeyPrefix, rawKey)

nestedItemId, err := parse.NewNestedItemID(client.Endpoint, featureKey, model.Label)
if err != nil {
return err
}

deadline, ok := ctx.Deadline()
if !ok {
return fmt.Errorf("internal-error: context had no deadline")
}

// from https://learn.microsoft.com/en-us/azure/azure-app-configuration/concept-enable-rbac#azure-built-in-roles-for-azure-app-configuration
// allow up to 15 min for role permission to be done propagated
// allow some time for role permission to be done propagated
metadata.Logger.Infof("[DEBUG] Waiting for App Configuration Key %q read permission to be done propagated", featureKey)
stateConf := &pluginsdk.StateChangeConf{
Pending: []string{"Forbidden"},
Target: []string{"Error", "Exists"},
Refresh: appConfigurationGetKeyRefreshFunc(ctx, client, featureKey, model.Label),
PollInterval: 20 * time.Second,
Timeout: 15 * time.Minute,
}

nestedItemId, err := parse.NewNestedItemID(client.Endpoint, featureKey, model.Label)
if err != nil {
return err
Timeout: time.Until(deadline),
}

if _, err = stateConf.WaitForStateContext(ctx); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,20 @@ func (k KeyResource) Create() sdk.ResourceFunc {
return err
}

deadline, ok := ctx.Deadline()
if !ok {
return fmt.Errorf("internal-error: context had no deadline")
}

// from https://learn.microsoft.com/en-us/azure/azure-app-configuration/concept-enable-rbac#azure-built-in-roles-for-azure-app-configuration
// allow up to 15 min for role permission to be done propagated
// allow some time for role permission to be done propagated
metadata.Logger.Infof("[DEBUG] Waiting for App Configuration Key %q read permission to be done propagated", model.Key)
stateConf := &pluginsdk.StateChangeConf{
Pending: []string{"Forbidden"},
Target: []string{"Error", "Exists"},
Refresh: appConfigurationGetKeyRefreshFunc(ctx, client, model.Key, model.Label),
PollInterval: 20 * time.Second,
Timeout: 15 * time.Minute,
Timeout: time.Until(deadline),
}

if _, err = stateConf.WaitForStateContext(ctx); err != nil {
Expand Down

0 comments on commit 973e7a5

Please sign in to comment.