Skip to content

Commit

Permalink
azurerm_cosmosdb_postgresql_cluster - Mark administrator_login_passwo…
Browse files Browse the repository at this point in the history
…rd as optional (#23750)

* azurerm_cosmosdb_postgresql_cluster - Mark administrator_login_password as optional

* update code

* update code

* update code

* update code
  • Loading branch information
neil-yechenwei authored Nov 2, 2023
1 parent b8ee9b0 commit db4ac14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
20 changes: 13 additions & 7 deletions internal/services/cosmos/cosmosdb_postgresql_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ func (r CosmosDbPostgreSQLClusterResource) Arguments() map[string]*pluginsdk.Sch

"location": commonschema.Location(),

"administrator_login_password": {
Type: pluginsdk.TypeString,
Required: true,
Sensitive: true,
ValidateFunc: validation.StringLenBetween(8, 256),
},

"coordinator_storage_quota_in_mb": {
Type: pluginsdk.TypeInt,
Required: true,
Expand Down Expand Up @@ -123,6 +116,13 @@ func (r CosmosDbPostgreSQLClusterResource) Arguments() map[string]*pluginsdk.Sch
),
},

"administrator_login_password": {
Type: pluginsdk.TypeString,
Optional: true,
Sensitive: true,
ValidateFunc: validation.StringLenBetween(8, 256),
},

"citus_version": {
Type: pluginsdk.TypeString,
Optional: true,
Expand Down Expand Up @@ -378,6 +378,8 @@ func (r CosmosDbPostgreSQLClusterResource) Create() sdk.ResourceFunc {

if v := model.SourceResourceId; v != "" {
parameters.Properties.SourceResourceId = &model.SourceResourceId
} else if model.AdministratorLoginPassword == "" {
return fmt.Errorf("`administrator_login_password` is required when `source_resource_id` isn't set")
}

// If `shards_on_coordinator_enabled` isn't set, API would set it to `true` when `node_count` is `0`.
Expand Down Expand Up @@ -423,6 +425,10 @@ func (r CosmosDbPostgreSQLClusterResource) Update() sdk.ResourceFunc {
}

if metadata.ResourceData.HasChange("administrator_login_password") {
if model.SourceResourceId == "" && model.AdministratorLoginPassword == "" {
return fmt.Errorf("`administrator_login_password` is required when `source_resource_id` isn't set")
}

parameters.Properties.AdministratorLoginPassword = &model.AdministratorLoginPassword
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ resource "azurerm_cosmosdb_postgresql_cluster" "test2" {
source_resource_id = azurerm_cosmosdb_postgresql_cluster.test.id
point_in_time_in_utc = azurerm_cosmosdb_postgresql_cluster.test.earliest_restore_time
administrator_login_password = "H@Sh1CoR3!"
coordinator_storage_quota_in_mb = 131072
coordinator_vcore_count = 2
node_count = 0
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/cosmosdb_postgresql_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ The following arguments are supported:

* `location` - (Required) The Azure Region where the Azure Cosmos DB for PostgreSQL Cluster should exist. Changing this forces a new resource to be created.

* `administrator_login_password` - (Required) The password of the administrator login.

* `coordinator_storage_quota_in_mb` - (Required) The coordinator storage allowed for the Azure Cosmos DB for PostgreSQL Cluster. Possible values are `32768`, `65536`, `131072`, `262144`, `524288`, `1048576`, `2097152`, `4194304`, `8388608`, `16777216`, and `33554432`.

-> **NOTE:** More information on [the types of compute resources available for CosmosDB can be found in the product documentation](https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute)
Expand All @@ -49,6 +47,8 @@ The following arguments are supported:

* `node_count` - (Required) The worker node count of the Azure Cosmos DB for PostgreSQL Cluster. Possible value is between `0` and `20` except `1`.

* `administrator_login_password` - (Optional) The password of the administrator login. This is required when `source_resource_id` is not set.

* `citus_version` - (Optional) The citus extension version on the Azure Cosmos DB for PostgreSQL Cluster. Possible values are `8.3`, `9.0`, `9.1`, `9.2`, `9.3`, `9.4`, `9.5`, `10.0`, `10.1`, `10.2`, `11.0`, `11.1`, `11.2`, `11.3` and `12.1`.

* `coordinator_public_ip_access_enabled` - (Optional) Is public access enabled on coordinator? Defaults to `true`.
Expand Down

0 comments on commit db4ac14

Please sign in to comment.