hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.33k stars 1.73k forks source link

Add 'primary' version of cryptokey to google_kms_crypto_key #5688

Closed rvdh closed 10 months ago

rvdh commented 4 years ago

Community Note

Description

To update the crypto key version to be used in MongoDB's Atlas encryption at rest resource (https://www.terraform.io/docs/providers/mongodbatlas/r/encryption_at_rest.html) we need to specify the crypto key version resource ID.

The GCP API returns, as part of the 'Primary' field of the crypto key, the current key version (https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#get). This should be returned by the google_kms_crypto_key resource or data source so we can return it as an output and pass it to the MongoDB Atlas provider.

New or Affected Resource(s)

Potential Terraform Configuration

data "google_kms_key_ring" "key_ring" {
  name     = "my_keyring"
  location = "europe-west1"
}

data "google_kms_crypto_key" "crypto_key" {
  name     = "my_crypto_key"
  key_ring = data.google_kms_key_ring.key_ring.self_link
}

resource "mongodbatlas_encryption_at_rest" "encryption" {
  project_id = var.mongodbatlas_project_id

  google_cloud_kms = {
    enabled                 = true
    service_account_key     = var.gcp_service_account_key
    key_version_resource_id = data.google_kms_crypto_key.crypto_key.primary.self_link 
  }
}
bdelage commented 2 years ago

Hi I'm encountering the same situation, I know It's been 2 years but I was wondering if you solved it or circumvented it somehow ?

rvdh commented 2 years ago

Hi I'm encountering the same situation, I know It's been 2 years but I was wondering if you solved it or circumvented it somehow ?

Nope, unfortunately we're still updating the key version ID manually every 90 days..

bdelage commented 2 years ago

Thanks Rick, I opened a suggestion for them to improve this https://feedback.mongodb.com/forums/924145-atlas/suggestions/44834422-atlas-does-not-automatically-rotate-the-key-versio

saad-uddin commented 1 year ago

Hi, am facing the same issue. We need to manually change the cryptokeyversion in the datasource of our tfcode. Its been 2 years since this was reported, is there any solution to this yet ? or any workaround ??

@rvdh @danawillow @bdelage @topfunky @fd

Thanks in advance.

github-actions[bot] commented 9 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.