Skip to content

Commit 9197644

Browse files
data.azurerm_postgresql_flexible_server - add support for zone and high_availability (hashicorp#31034)
[ENHANCEMENT] * `data.azurerm_postgresql_flexible_server` - add support for `zone` and `high_availability`
1 parent 2d360f8 commit 9197644

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

internal/services/postgres/postgresql_flexible_server_data_source.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,26 @@ func dataSourcePostgresqlFlexibleServer() *pluginsdk.Resource {
8282
},
8383

8484
"tags": commonschema.TagsDataSource(),
85+
86+
"high_availability": {
87+
Type: pluginsdk.TypeList,
88+
Computed: true,
89+
Elem: &pluginsdk.Resource{
90+
Schema: map[string]*pluginsdk.Schema{
91+
"mode": {
92+
Type: pluginsdk.TypeString,
93+
Computed: true,
94+
},
95+
96+
"standby_availability_zone": {
97+
Type: pluginsdk.TypeString,
98+
Computed: true,
99+
},
100+
},
101+
},
102+
},
103+
104+
"zone": commonschema.ZoneSingleComputed(),
85105
},
86106
}
87107
}
@@ -116,6 +136,7 @@ func dataSourceArmPostgresqlFlexibleServerRead(d *pluginsdk.ResourceData, meta i
116136
d.Set("administrator_login", props.AdministratorLogin)
117137
d.Set("version", string(pointer.From(props.Version)))
118138
d.Set("fqdn", props.FullyQualifiedDomainName)
139+
d.Set("zone", props.AvailabilityZone)
119140

120141
if storage := props.Storage; storage != nil {
121142
if storage.AutoGrow != nil {
@@ -139,6 +160,10 @@ func dataSourceArmPostgresqlFlexibleServerRead(d *pluginsdk.ResourceData, meta i
139160
}
140161
d.Set("public_network_access_enabled", publicNetworkAccess)
141162
}
163+
164+
if err := d.Set("high_availability", flattenFlexibleServerHighAvailability(props.HighAvailability)); err != nil {
165+
return fmt.Errorf("flattening `high_availability`: %+v", err)
166+
}
142167
}
143168

144169
sku, err := flattenFlexibleServerSku(model.Sku)

internal/services/postgres/postgresql_flexible_server_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestAccDataSourcePostgresqlflexibleServer_basic(t *testing.T) {
2929
check.That(data.ResourceName).Key("backup_retention_days").Exists(),
3030
check.That(data.ResourceName).Key("fqdn").Exists(),
3131
check.That(data.ResourceName).Key("public_network_access_enabled").Exists(),
32+
check.That(data.ResourceName).Key("zone").Exists(),
3233
),
3334
},
3435
})

website/docs/d/postgresql_flexible_server.html.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ In addition to the Arguments listed above - the following Attributes are exporte
4949

5050
* `fqdn` - The FQDN of the PostgreSQL Flexible Server.
5151

52+
* `high_availability` - A `high_availability` block for this PostgreSQL Flexible Server as defined below.
53+
5254
* `public_network_access_enabled` - Is public network access enabled?
5355

5456
* `sku_name` - The SKU Name for the PostgreSQL Flexible Server. The name of the SKU, follows the `tier` + `name` pattern (e.g. `B_Standard_B1ms`, `GP_Standard_D2s_v3`, `MO_Standard_E4s_v3`).
@@ -57,8 +59,18 @@ In addition to the Arguments listed above - the following Attributes are exporte
5759

5860
* `version` - The version of PostgreSQL Flexible Server to use.
5961

62+
* `zone` - The Availability Zones where this PostgreSQL Flexible Server is located.
63+
6064
* `tags` - A mapping of tags assigned to the PostgreSQL Flexible Server.
6165

66+
---
67+
68+
A `high_availability` block exports the following:
69+
70+
* `mode` - The high availability mode of the PostgreSQL Flexible Server.
71+
72+
* `standby_availability_zone` - The availability zone of the standby Flexible Server.
73+
6274
## Timeouts
6375

6476
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions:

0 commit comments

Comments
 (0)