Skip to content

Commit

Permalink
Simplification by removing downscaling replicas from primary
Browse files Browse the repository at this point in the history
  • Loading branch information
Aris van Ommeren committed Mar 1, 2021
1 parent d5bd64c commit 388b4a4
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions azurerm/internal/services/postgres/postgresql_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,33 +664,6 @@ func resourcePostgreSQLServerUpdate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("waiting for update of PostgreSQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}

if d.HasChange("sku_name") && mode != postgresql.CreateModeReplica {
oldRaw, newRaw := d.GetChange("sku_name")
old := oldRaw.(string)
new := newRaw.(string)

if indexOfSku(old) > indexOfSku(new) {
propertiesReplica := postgresql.ServerUpdateParameters{
Sku: sku,
}

listReplicas, err := replicasClient.ListByServer(ctx, id.ResourceGroup, id.Name)
if err != nil {
return fmt.Errorf("request error for list of replicas for PostgreSQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}
for _, replica := range *listReplicas.Value {
future, err := client.Update(ctx, id.ResourceGroup, *replica.Name, propertiesReplica)
if err != nil {
return fmt.Errorf("updating PostgreSQL Server Replica %q (Resource Group %q): %+v", *replica.Name, id.ResourceGroup, err)
}

if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
return fmt.Errorf("waiting for update of PostgreSQL Server Replica %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}
}
}
}

if v, ok := d.GetOk("threat_detection_policy"); ok {
alert := expandSecurityAlertPolicy(v)
if alert != nil {
Expand Down

0 comments on commit 388b4a4

Please sign in to comment.