Skip to content

Commit

Permalink
postgresql_server: public_network_access_enabled fixed on createR…
Browse files Browse the repository at this point in the history
…eplica (#11465)

Co-authored-by: kt <[email protected]>
  • Loading branch information
aristosvo and katbyte authored Apr 25, 2021
1 parent 32caebe commit f205229
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions azurerm/internal/services/postgres/postgresql_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,25 @@ func resourcePostgreSQLServerCreate(d *schema.ResourceData, meta interface{}) er
}
}

// Issue tracking the REST API update failure: https://github.com/Azure/azure-rest-api-specs/issues/14117
if mode == postgresql.CreateModeReplica {
log.Printf("[INFO] changing `public_network_access_enabled` for AzureRM PostgreSQL Server %q (Resource Group %q)", name, resourceGroup)
properties := postgresql.ServerUpdateParameters{
ServerUpdateParametersProperties: &postgresql.ServerUpdateParametersProperties{
PublicNetworkAccess: publicAccess,
},
}

future, err := client.Update(ctx, resourceGroup, name, properties)
if err != nil {
return fmt.Errorf("updating PostgreSQL Server %q (Resource Group %q): %+v", name, resourceGroup, err)
}

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

return resourcePostgreSQLServerRead(d, meta)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ resource "azurerm_postgresql_server" "replica" {
create_mode = "Replica"
creation_source_server_id = azurerm_postgresql_server.test.id
ssl_enforcement_enabled = true
public_network_access_enabled = false
ssl_enforcement_enabled = true
}
`, r.template(data, sku, "11"), data.RandomInteger, data.Locations.Secondary, sku)
}
Expand Down

0 comments on commit f205229

Please sign in to comment.