Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-yechenwei committed Jan 24, 2024
1 parent 1c5c69c commit d809123
Show file tree
Hide file tree
Showing 3 changed files with 233 additions and 11 deletions.
12 changes: 8 additions & 4 deletions internal/services/cosmos/cosmosdb_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ func resourceCosmosDbAccount() *pluginsdk.Resource {
"minimal_tls_version": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(cosmosdb.MinimalTlsVersionTlsOneTwo),
ValidateFunc: validation.StringInSlice(cosmosdb.PossibleValuesForMinimalTlsVersion(), false),
},

Expand Down Expand Up @@ -766,7 +765,6 @@ func resourceCosmosDbAccountCreate(d *pluginsdk.ResourceData, meta interface{})
partitionMergeEnabled := d.Get("partition_merge_enabled").(bool)
enableAnalyticalStorage := d.Get("analytical_storage_enabled").(bool)
disableLocalAuthentication := d.Get("local_authentication_disabled").(bool)
minimalTlsVersion := d.Get("minimal_tls_version").(string)

r, err := databaseClient.CheckNameExists(ctx, id.DatabaseAccountName)
if err != nil {
Expand Down Expand Up @@ -824,11 +822,14 @@ func resourceCosmosDbAccountCreate(d *pluginsdk.ResourceData, meta interface{})
NetworkAclBypass: pointer.To(networkByPass),
NetworkAclBypassResourceIds: utils.ExpandStringSlice(d.Get("network_acl_bypass_ids").([]interface{})),
DisableLocalAuth: utils.Bool(disableLocalAuthentication),
MinimalTlsVersion: pointer.To(cosmosdb.MinimalTlsVersion(minimalTlsVersion)),
},
Tags: tags.Expand(t),
}

if v, ok := d.GetOk("minimal_tls_version"); ok {
account.Properties.MinimalTlsVersion = pointer.To(cosmosdb.MinimalTlsVersion(v.(string)))
}

// These values may not have changed but they need to be in the update params...
if v, ok := d.GetOk("default_identity_type"); ok {
account.Properties.DefaultIdentity = pointer.To(v.(string))
Expand Down Expand Up @@ -1062,11 +1063,14 @@ func resourceCosmosDbAccountUpdate(d *pluginsdk.ResourceData, meta interface{})
DisableLocalAuth: disableLocalAuthentication,
BackupPolicy: backup,
EnablePartitionMerge: pointer.To(d.Get("partition_merge_enabled").(bool)),
MinimalTlsVersion: pointer.To(cosmosdb.MinimalTlsVersion(d.Get("minimal_tls_version").(string))),
},
Tags: t,
}

if v, ok := d.GetOk("minimal_tls_version"); ok {
account.Properties.MinimalTlsVersion = pointer.To(cosmosdb.MinimalTlsVersion(v.(string)))
}

if keyVaultKeyIDRaw, ok := d.GetOk("key_vault_key_id"); ok {
keyVaultKey, err := keyVaultParse.ParseOptionallyVersionedNestedItemID(keyVaultKeyIDRaw.(string))
if err != nil {
Expand Down
Loading

0 comments on commit d809123

Please sign in to comment.