Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of the key used to encrypt IBM Cloud Databases backups #1761

Closed
l2fprod opened this issue Jul 28, 2020 · 7 comments
Closed

Comments

@l2fprod
Copy link
Member

l2fprod commented Jul 28, 2020

Currently only the key used to encrypt the database can be specified:

"key_protect_instance": {

but ICD also supports providing the key to encrypt backups as described in https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect#byok-for-backups

Today it is not possible and I end up having only the data but not the backup being encrypted with my own key:

image

@movinglightspeed
Copy link

Also another issue on this
#1727

kavya498 added a commit to kavya498/terraform-provider-ibm that referenced this issue Aug 10, 2020
@hkantare
Copy link
Collaborator

@l2fprod
Copy link
Member Author

l2fprod commented Sep 1, 2020

@hkantare there is a naming inconsistency in the newly added key:

image

  • notice "key_protect_key" for the disk encryption pointing to a crn.
  • And then "backup_encryption_key_crn" for the backup encryption, this one has "crn" in its name. Not very consistent with the other one.
  • Also the doc for "key_protect_instance" does not say if this instance will be used to look for the backup encryption key. Is this instance needed at all given we have the crn for the key?

@kavya498
Copy link
Collaborator

kavya498 commented Sep 2, 2020

Hi,
key_protect_instance is not required.. crn for the key i.e backup_encryption_key_crn parameter is good enough for icd backup encryption..

backup_encryption_key_crn parameter name is chosen from docs.

key_protect_key support was introduced long back in terraform, we see some updates from icd api..
we'll work on the consistency of parameters and update soon.

@l2fprod
Copy link
Member Author

l2fprod commented Sep 2, 2020

@kavya498

I tried the new backup_encryption_key_crn and the Redis instance I wanted to create stayed in "Provisioning" for hours before failing. I use the same key for both db encryption and backup encryption.

After I removed the backup_encryption_key_crn I could create a Redis instance

@l2fprod
Copy link
Member Author

l2fprod commented Sep 3, 2020

here is a terraform template that fails to provision a Redis database:

variable ibmcloud_api_key {}
variable basename { default="redis-failed"}
variable resource_group_name {}
variable region { default = "us-south" }

provider "ibm" {
  ibmcloud_api_key = var.ibmcloud_api_key
  region           = var.region
  generation       = 2
  ibmcloud_timeout = 900
}

data ibm_resource_group group {
  name = var.resource_group_name
}

resource ibm_resource_instance kms {
  name              = "${var.basename}-kms"
  resource_group_id = data.ibm_resource_group.group.id
  service           = "kms"
  plan              = "tiered-pricing"
  location          = var.region
}

resource ibm_kp_key key {
  key_protect_id = ibm_resource_instance.kms.guid
  key_name       = "root_key"
  standard_key   = false
  force_delete   = true
}

resource ibm_database redis {
  name              = "${var.basename}-redis"
  resource_group_id = data.ibm_resource_group.group.id
  plan              = "standard"
  service           = "databases-for-redis"
  location          = var.region

  key_protect_key           = ibm_kp_key.key.crn
  key_protect_instance      = ibm_resource_instance.kms.crn
  backup_encryption_key_crn = ibm_kp_key.key.crn

  service_endpoints = "private"

  depends_on = [
    ibm_iam_authorization_policy.redis_policy
  ]
}

resource ibm_iam_authorization_policy redis_policy {
  source_service_name         = "databases-for-redis"
  target_service_name         = "kms"
  target_resource_instance_id = ibm_resource_instance.kms.guid
  roles                       = ["Reader"]
}

@l2fprod
Copy link
Member Author

l2fprod commented Sep 11, 2020

the reason for the provisioning failure is because the authorization policy is incomplete. It needs an additional role AuthorizationDelegator:

resource ibm_iam_authorization_policy redis_policy {
  source_service_name         = "databases-for-redis"
  target_service_name         = "kms"
  target_resource_instance_id = ibm_resource_instance.kms.guid
  roles                       = ["Reader", "AuthorizationDelegator"]
}

@l2fprod l2fprod closed this as completed Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants