Professional Cloud DevOps Engineer
The security concept of least privilege ensures that human users and automated deployment tools have only the minimum access needed to complete their jobs. In Google Cloud, developers enforce this by applying fine-grained policies directly to resources like key rings and individual keys. Instead of downloading and managing risky long-lived service account keys for applications running outside of Google Cloud, organizations should implement Workload Identity Federation to securely link external identities. In Google Kubernetes Engine, workload identity allows containerized applications to securely impersonate Google Cloud service accounts without credential files. Security teams can continuously maintain this posture by using the Policy Analyzer and role recommender to audit permissions and remove excess access.
To protect cryptographic keys, administrators grant specific Identity and Access Management roles depending on the job function of each service. For example, a pipeline runner might only need the CryptoKey Encrypter/Decrypter role to secure build artifacts, while backup services may only need decryption access. To ensure a strict separation of duties, key management must be isolated in a dedicated project that is separate from the project hosting the active workloads. Developers should also use Secret Manager to store configuration secrets, applying regular rotation policies and scanning source code repositories to prevent credential leaks.
Securing deployment configurations and build resources at rest relies on a strategy called envelope encryption. In this model, the actual data payload is encrypted with a local data encryption key (DEK), which is then immediately encrypted by a key encryption key (KEK) managed in Cloud Key Management Service (Cloud KMS). By utilizing Customer-Managed Encryption Keys (CMEK), organizations retain ultimate authority over the KEK, allowing them to disable access instantly or track usage via audit logs. This design creates a secure trust boundary where the actual data never leaves the workload project unencrypted, and the master keys never leave Cloud KMS.
Applying CMEK across a continuous delivery pipeline involves securing multiple distinct endpoints to safeguard the software supply chain. Developers must integrate CMEK with storage buckets containing source code, Artifact Registry repositories storing container images, and persistent disks used by build runners. To simplify this setup, Cloud KMS Autokey can automate the provisioning of keys and assign the necessary permissions to pipeline service agents on-demand. When deploying resources, developers must align keys and workloads geographically, because regional resources depend on keys located in the exact same Google Cloud region.
A secure cryptographic key moves through a defined lifecycle that spans creation, rotation, and destruction states. Keys are initially generated in Cloud KMS, which can leverage hardware security modules via Cloud HSM or external systems via Cloud External Key Manager (Cloud EKM) to meet strict regulatory standards. Regular rotation replaces active key versions with new ones, which minimizes the impact of potential key exposure without breaking existing data integrations. If a key version is scheduled for destruction, a safety period begins before the key is permanently deleted. This lifecycle step is irreversible, meaning any data encrypted with that specific version becomes permanently undecryptable.
Integrating key management directly with delivery pipelines prevents unexpected service downtime when keys are rotated or modified. If an administrator disables a CMEK, pipeline services like Cloud Run or GKE will immediately lose access to their storage and boot disks, causing deployments to fail. Security teams can also enforce these guardrails at scale by applying organization policies like gcp.restrictNonCmekServices to prevent teams from launching unencrypted resources. To maintain reliable operations, organizations use Cloud Monitoring to track cryptographic quotas and alert administrators before key destruction occurs. Finally, Cloud Audit Logs record every key usage and configuration change, providing a verifiable compliance trail that tracks how, when, and by whom cryptographic keys were accessed.
Prepare and test your skills
Prepare and test your skills
Workload Identity Federation securely links external identities to Google Cloud, allowing applications running outside of Google Cloud to avoid using risky long-lived service account keys.
Envelope encryption encrypts data with a local data encryption key (DEK), which is then encrypted by a key encryption key (KEK) managed in Cloud KMS. This ensures the data never leaves the workload project unencrypted and the master keys never leave Cloud KMS.
Isolating key management in a dedicated project, separate from the project hosting active workloads, ensures a strict separation of duties for security.
If a CMEK is disabled, pipeline services like Cloud Run or Google Kubernetes Engine (GKE) will immediately lose access to their storage and boot disks, causing deployments to fail.
Configure a Workload Identity Pool mapping external usernames, grant the federated principal roles/cloudkms.cryptoKeyEncrypterDecrypter on the parent KeyRing, and enable default Cloud Logging for Cloud KMS.
Create a service account with roles/cloudkms.admin on the target CryptoKey, assign the pipeline runner roles/iam.workloadIdentityPoolAdmin on the project, and export audit logs to BigQuery.
Configure a Workload Identity Pool mapping stable external claims, grant the federated identity roles/iam.workloadIdentityUser on a dedicated service account, grant that service account roles/cloudkms.cryptoKeyDecrypter specifically on the target CryptoKey, and enable Data Access audit logs for the Security Token Service and IAM APIs.
Generate a downloadable JSON service account key for a deployment service account, assign it roles/cloudkms.cryptoKeyDecrypter at the project level, and enable Security Command Center audit alerting.
Your organization uses an external CI/CD pipeline running in an external cloud provider to deploy application infrastructure. The pipeline needs to decrypt sensitive deployment configuration files using a Cloud KMS key before initiating rollout.
To meet strict security compliance, your implementation must satisfy the following requirements:
Which configuration should you implement?