Skip to content

Commit

Permalink
Deprecate key_protect_key_id (IBM-Cloud#3939)
Browse files Browse the repository at this point in the history
* Modified platform options and deprecated key_protect_key_id

* deprecated key_protect_key_id

* added deprecation to docs

* removed comment

* removed another comment
  • Loading branch information
omaraibrahim authored and SunithaGudisagarIBM1 committed Sep 14, 2022
1 parent 6e14dad commit a295c08
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
10 changes: 10 additions & 0 deletions ibm/flex/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,16 @@ func FlattenWhitelist(whitelist icdv4.Whitelist) []map[string]interface{} {
return entries
}

func ExpandPlatformOptions(platformOptions icdv4.PlatformOptions) []map[string]interface{} {
pltOptions := make([]map[string]interface{}, 0, 1)
pltOption := make(map[string]interface{})
pltOption["key_protect_key_id"] = platformOptions.KeyProtectKey
pltOption["disk_encryption_key_crn"] = platformOptions.DiskENcryptionKeyCrn
pltOption["backup_encryption_key_crn"] = platformOptions.BackUpEncryptionKeyCrn
pltOptions = append(pltOptions, pltOption)
return pltOptions
}

func expandStringMap(inVal interface{}) map[string]string {
outVal := make(map[string]string)
if inVal == nil {
Expand Down
29 changes: 22 additions & 7 deletions ibm/service/database/data_source_ibm_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,28 @@ func DataSourceIBMDatabaseInstance() *schema.Resource {
},
"platform_options": {
Description: "Platform-specific options for this deployment.r",
Type: schema.TypeMap,
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key_protect_key_id": {
Description: "Key protect key id",
Type: schema.TypeString,
Computed: true,
Deprecated: "This field is deprecated and has been replaced by disk_encryption_key_crn",
},
"disk_encryption_key_crn": {
Description: "Disk encryption key crn",
Type: schema.TypeString,
Computed: true,
},
"backup_encryption_key_crn": {
Description: "Backup encryption key crn",
Type: schema.TypeString,
Computed: true,
},
},
},
},
"tags": {
Type: schema.TypeSet,
Expand Down Expand Up @@ -678,12 +698,7 @@ func dataSourceIBMDatabaseInstanceRead(d *schema.ResourceData, meta interface{})
d.Set("adminuser", cdb.AdminUser)
d.Set("version", cdb.Version)
if &cdb.PlatformOptions != nil {
platformOptions := map[string]interface{}{
"key_protect_key_id": cdb.PlatformOptions.KeyProtectKey,
"disk_encryption_key_crn": cdb.PlatformOptions.DiskENcryptionKeyCrn,
"backup_encryption_key_crn": cdb.PlatformOptions.BackUpEncryptionKeyCrn,
}
d.Set("platform_options", platformOptions)
d.Set("platform_options", flex.ExpandPlatformOptions(cdb.PlatformOptions))
}

groupList, err := icdClient.Groups().GetGroups(icdId)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/database.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ In addition to all argument references list, you can access the following attrib
- `platform_options`- (String) The CRN of key protect key.

Nested scheme for `platform_options`:
- `key_protect_key_id`- (String) The CRN of key protect key.
- `key_protect_key_id`- **Deprecated** - (String) The CRN of key protect key. - replaced by `backup_encryption_key_crn`
- `disk_encryption_key_crn`- (String) The CRN of disk encryption key.
- `backup_encryption_key_crn`- (String) The CRN of backup encryption key.

Expand Down

0 comments on commit a295c08

Please sign in to comment.