Soru

Zorluk: Çok zorProvisioning Storage and Database Systems

An enterprise architecture team is implementing an automated Infrastructure as Code workflow to provision a multi-region Cloud Spanner database encrypted with Customer-Managed Encryption Keys (CMEK). Place the operational steps in the mandatory execution sequence required to successfully deploy the database and grant application access without permission or lifecycle failures.

  1. 1Create the Cloud KMS KeyRing and CryptoKey, and assign the `roles/cloudkms.cryptoKeyEncrypterDecrypter` IAM role to the Cloud Spanner Service Agent (`[email protected]`).
  2. 2Provision the multi-region Cloud Spanner instance resource (`google_spanner_instance`) defining the compute capacity and regional configuration.
  3. 3Create the Cloud Spanner database resource (`google_spanner_database`) within the instance, passing the Cloud KMS CryptoKey resource name into the `encryption_config` block.
  4. 4Apply database-level IAM policy bindings (`google_spanner_database_iam_binding`) to grant application service accounts the `roles/spanner.databaseUser` role.

Cevap

The mandatory operational sequence is: 1) Create the Cloud KMS KeyRing/CryptoKey and grant the Cloud Spanner Service Agent the Encrypter/Decrypter role; 2) Provision the Cloud Spanner instance; 3) Provision the Cloud Spanner database specifying the KMS key in the encryption configuration; 4) Apply database IAM bindings for application service accounts.
Provisioning a CMEK-encrypted Cloud Spanner database requires strict prerequisite ordering: first, the Cloud Spanner service agent must be granted Cloud KMS encrypter/decrypter permissions on the key; second, the parent Spanner instance must be provisioned; third, the database is created using the KMS key configuration; finally, fine-grained IAM database user permissions are assigned to application service accounts.

Adım Adım Çözüm

1
Configure Cloud KMS and IAM Delegation
The Cloud Spanner Service Agent is granted permissions to encrypt and decrypt data using the dedicated Cloud KMS key.
If CMEK encryption is specified during database creation without prior IAM delegation to the service agent, the API call will fail with a permission denied error.
2
Provision Spanner Instance
The parent Cloud Spanner instance is allocated with the specified node count and multi-region configuration.
Databases in Spanner must belong to an existing parent instance resource.
3
Provision Spanner Database with CMEK
The database is created inside the instance and encrypted using the authorized Cloud KMS key.
The Spanner service validates key existence and service account access during database initialization.
4
Bind Database IAM Roles
Application service accounts receive fine-grained read/write access to the newly created database.
Resource-level IAM policies for databases require the target database resource ID to exist.

Anahtar Kavram

Cloud Spanner CMEK Provisioning Dependencies and Lifecycle Ordering
Bu soruyu puanla