Skip to content

Commit

Permalink
INTMDB-181: Detects unnecessary changes changes for azure/gcp encrypt…
Browse files Browse the repository at this point in the history
…ion at rest (#412)

* fix: deleted some parameters what will be empty in response

* fix: set project id in read

Co-authored-by: Edgar López <[email protected]>
  • Loading branch information
coderGo93 and Edgar López authored Mar 12, 2021
1 parent 98097d2 commit 8a31066
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions mongodbatlas/resource_mongodbatlas_encryption_at_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,40 @@ func resourceMongoDBAtlasEncryptionAtRestRead(d *schema.ResourceData, meta inter

values = flattenAzureVault(&resp.AzureKeyVault)
if !counterEmptyValues(values) {
azure, azureOk := d.GetOk("azure_key_vault")
if azureOk {
azure2 := azure.(map[string]interface{})
values["secret"] = cast.ToString(azure2["secret"])
if v, sa := values["secret"]; sa {
if v.(string) == "" {
delete(values, "secret")
}
}
}
if err = d.Set("azure_key_vault", values); err != nil {
return fmt.Errorf(errorAlertEncryptionAtRestSetting, "azure_key_vault", d.Id(), err)
}
}

values = flattenGCPKms(&resp.GoogleCloudKms)
if !counterEmptyValues(values) {
gcp, gcpOk := d.GetOk("google_cloud_kms")
if gcpOk {
gcp2 := gcp.(map[string]interface{})
values["service_account_key"] = cast.ToString(gcp2["service_account_key"])
if v, sa := values["service_account_key"]; sa {
if v.(string) == "" {
delete(values, "service_account_key")
}
}
}
if err = d.Set("google_cloud_kms", values); err != nil {
return fmt.Errorf(errorAlertEncryptionAtRestSetting, "google_cloud_kms", d.Id(), err)
}
}
if err = d.Set("project_id", d.Id()); err != nil {
return fmt.Errorf(errorAlertEncryptionAtRestSetting, "project_id", d.Id(), err)
}

return nil
}
Expand Down

0 comments on commit 8a31066

Please sign in to comment.