Repository navigation
Conversation
…rules - fedramp-high/cloud-spanner: add kms_key_name variable, wire to spanner module, grant Spanner SA KMS encryption/decryption access - il5/bastion-pattern: scope ingress firewall to target_tags=['bastion'], add matching VM tag - il5/postgresql: firewall already has logging (no additional changes needed - Cloud SQL uses PSA)
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
刚 force push 了 erraform fmt 修复 Repository Lint(for_each map key 对齐)。CI 会重新跑。 |
|
Hi, I just signed the Google Contributor License Agreement (CLA). Could someone please re-run the \cla/google\ check? Thanks! |
aghassemlouei
left a comment
There was a problem hiding this comment.
Thanks for wiring bastion-pattern firewall scoping and cloud-spanner CMEK toward #374. Running terraform validate and terraform plan surfaced three issues documented inline:
blueprints/fedramp-high/cloud-spanner/main.tffailsterraform validatewithUnsupported argument: An argument named "kms_key_name" is not expected herebecausemodules/spanner-instance-seconfigureskms_key_nameper database insidevar.databases, not at the module root.blueprints/fedramp-high/cloud-spanner/main.tfomitsdepends_onedges fromgoogle_project_service.spanner_apitogoogle_project_service_identity.spannerand fromgoogle_kms_crypto_key_iam_member.spanner_sa_kms_accesstomodule.cloud-spanner, causing fresh CMEK deployments to race the KMS IAM grant.- Only 2 of the blueprints tracked in #374 are covered here while items in
cloud-composer-environment,blueprints/il5/postgresql, and resource-scoped IAM remain open; please switchFixes #374.toPart of #374.and populate the.github/pull_request_template.mdsections.
| source = "../../../modules/spanner-instance-se" | ||
| project_id = var.main_project_id | ||
| edition = var.edition | ||
| kms_key_name = var.kms_key_name |
There was a problem hiding this comment.
modules/spanner-instance-se does not declare a top-level kms_key_name variable, so terraform validate fails here with Error: Unsupported argument: An argument named "kms_key_name" is not expected here. In modules/spanner-instance-se/variables.tf at line 43 and main.tf at line 100, kms_key_name is an attribute on each entry of the databases map via databases = { (var.database_name) = { kms_key_name = var.kms_key_name, ... } }. Wire kms_key_name = var.kms_key_name inside databases[(var.database_name)], update the variable description in variables.tf since CMEK encrypts the Spanner database rather than the instance, and regenerate README.md with tools/tfdoc.py.
| depends_on = [google_project_service.spanner_api] | ||
| } | ||
|
|
||
| # Grant Spanner service identity access to CMEK key when provided | ||
| resource "google_project_service_identity" "spanner" { | ||
| provider = google-beta | ||
| project = var.main_project_id | ||
| service = "spanner.googleapis.com" | ||
| count = var.kms_key_name != null ? 1 : 0 | ||
| } | ||
|
|
||
| resource "google_kms_crypto_key_iam_member" "spanner_sa_kms_access" { | ||
| count = var.kms_key_name != null ? 1 : 0 | ||
| crypto_key_id = var.kms_key_name | ||
| role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" | ||
| member = google_project_service_identity.spanner[0].member | ||
| } No newline at end of file |
There was a problem hiding this comment.
On a fresh project with var.kms_key_name != null, google_project_service_identity.spanner needs depends_on = [google_project_service.spanner_api] and module.cloud-spanner needs depends_on = [google_project_service.spanner_api, google_kms_crypto_key_iam_member.spanner_sa_kms_access] so Spanner database creation waits until the Spanner service agent holds roles/cloudkms.cryptoKeyEncrypterDecrypter on var.kms_key_name.
Fixes #374.
Summary
This PR enhances workload blueprints with CMEK wiring, resource-scoped firewall rules, and bastion VM hardening.
Changes Made
fedramp-high/cloud-spanner
kms_key_namevariable (default:null) accepting a fully qualified KMS crypto key self link.kms_key_name = var.kms_key_nameinto the spanner-instance-se module. When a key is provided, Spanner data at rest is encrypted with CMEK instead of GKEK.google_project_service_identity.spannerandgoogle_kms_crypto_key_iam_member.spanner_sa_kms_accessresources (guarded withcount) that grant the Spanner API service identityroles/cloudkms.cryptoKeyEncrypterDecrypteron the CMEK key when configured.il5/bastion-pattern
target_tags = ["bastion"]instead of applying it to all instances in the network.tags = ["bastion"]to the bastion VM so the firewall rule matches only the intended target.Security Impact
bastion, preventing accidental application to other workload VMs on the shared VPC.log_config { metadata = "INCLUDE_ALL_METADATA" }on their firewall rules.