diff --git a/internal/services/cosmos/cosmosdb_postgresql_cluster_resource.go b/internal/services/cosmos/cosmosdb_postgresql_cluster_resource.go index e7522723b3ea..0ae63b0c5e6e 100644 --- a/internal/services/cosmos/cosmosdb_postgresql_cluster_resource.go +++ b/internal/services/cosmos/cosmosdb_postgresql_cluster_resource.go @@ -36,6 +36,7 @@ type CosmosDbPostgreSQLClusterModel struct { SourceLocation string `tfschema:"source_location"` SourceResourceId string `tfschema:"source_resource_id"` MaintenanceWindow []MaintenanceWindow `tfschema:"maintenance_window"` + ServerNames []ServerNameItem `tfschema:"servers"` NodeCount int64 `tfschema:"node_count"` NodePublicIPAccessEnabled bool `tfschema:"node_public_ip_access_enabled"` NodeServerEdition string `tfschema:"node_server_edition"` @@ -48,6 +49,11 @@ type CosmosDbPostgreSQLClusterModel struct { EarliestRestoreTime string `tfschema:"earliest_restore_time"` } +type ServerNameItem struct { + Name string `tfschema:"name"` + FullyQualifiedDomainName string `tfschema:"fqdn"` +} + type MaintenanceWindow struct { DayOfWeek int64 `tfschema:"day_of_week"` StartHour int64 `tfschema:"start_hour"` @@ -304,6 +310,22 @@ func (r CosmosDbPostgreSQLClusterResource) Attributes() map[string]*pluginsdk.Sc Type: pluginsdk.TypeString, Computed: true, }, + "servers": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "fqdn": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, } } @@ -558,6 +580,7 @@ func (r CosmosDbPostgreSQLClusterResource) Read() sdk.ResourceFunc { state.CoordinatorServerEdition = pointer.From(props.CoordinatorServerEdition) state.CoordinatorStorageQuotaInMb = pointer.From(props.CoordinatorStorageQuotaInMb) state.CoordinatorVCoreCount = pointer.From(props.CoordinatorVCores) + state.ServerNames = flattenServerNames(props.ServerNames) state.HaEnabled = pointer.From(props.EnableHa) state.NodeCount = pointer.From(props.NodeCount) state.NodePublicIPAccessEnabled = pointer.From(props.NodeEnablePublicIPAccess) @@ -636,3 +659,20 @@ func flattenMaintenanceWindow(input *clusters.MaintenanceWindow) []MaintenanceWi }, } } + +func flattenServerNames(input *[]clusters.ServerNameItem) []ServerNameItem { + var output []ServerNameItem + + if input == nil { + return output + } + + for _, v := range *input { + output = append(output, ServerNameItem{ + FullyQualifiedDomainName: *v.FullyQualifiedDomainName, + Name: *v.Name, + }) + } + + return output +} diff --git a/internal/services/cosmos/cosmosdb_postgresql_cluster_resource_test.go b/internal/services/cosmos/cosmosdb_postgresql_cluster_resource_test.go index 19365fb94a8b..c7fb53617027 100644 --- a/internal/services/cosmos/cosmosdb_postgresql_cluster_resource_test.go +++ b/internal/services/cosmos/cosmosdb_postgresql_cluster_resource_test.go @@ -29,6 +29,8 @@ func TestAccCosmosDbPostgreSQLCluster_basic(t *testing.T) { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("servers.0.fqdn").IsNotEmpty(), + check.That(data.ResourceName).Key("servers.0.name").IsNotEmpty(), ), }, data.ImportStep("administrator_login_password"), diff --git a/website/docs/r/cosmosdb_postgresql_cluster.html.markdown b/website/docs/r/cosmosdb_postgresql_cluster.html.markdown index 991266b896f9..711ce6e464cc 100644 --- a/website/docs/r/cosmosdb_postgresql_cluster.html.markdown +++ b/website/docs/r/cosmosdb_postgresql_cluster.html.markdown @@ -99,6 +99,16 @@ In addition to the Arguments listed above - the following Attributes are exporte * `earliest_restore_time` - The earliest restore point time (ISO8601 format) for the Azure Cosmos DB for PostgreSQL Cluster. +* `servers` - A `servers` block as defined below. + +--- + +A `servers` block exports the following: + +* `fqdn` - The Fully Qualified Domain Name of the server. + +* `name` - The name of the server. + ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: