PROFESSIONAL-CLOUD-DEVOPS-ENGINEER practice question 18 of 25

[Building and implementing CI/CD pipelines for a service] You use Cloud Build to build and deploy your application. You want to securely incorporate database credentials and other application secrets into the build pipeline. You also want to minimize the development effort. What should you do?

Full set: 205 questions
Answer options
A: Create a Cloud Storage bucket and use the built-in encryption at rest. Store the secrets in the bucket and grant Cloud Build access to the bucket.
B: Encrypt the secrets and store them in the application repository. Store a decryption key in a separate repository and grant Cloud Build access to the repository.
C: Use client-side encryption to encrypt the secrets and store them in a Cloud Storage bucket. Store a decryption key in the bucket and grant Cloud Build access to the bucket.
D: Use Cloud Key Management Service (Cloud KMS) to encrypt the secrets and include them in your Cloud Build deployment configuration. Grant Cloud Build access to the KeyRing. Correct answer
Correct Answer:
D. Use Cloud Key Management Service (Cloud KMS) to encrypt the secrets and include them in your Cloud Build deployment configuration. Grant Cloud Build access to the KeyRing.
Explanation

The most secure and integrated method for handling secrets in Cloud Build is to use Cloud Key Management Service (Cloud KMS). You encrypt the secret value with a Cloud KMS key, store the encrypted value (ciphertext) in your build configuration or source repository, and grant the Cloud Build service account the cloudkms.cryptoKeyDecrypter IAM role. Cloud Build has native support to automatically decrypt these values at build time, requiring minimal development effort and following security best practices.

Why Incorrect

A. Storing secrets in Cloud Storage, even with encryption at rest, is less secure as any principal with read access to the object can retrieve the plaintext secret.
B. Storing decryption keys in a repository is an anti-pattern. It complicates key management and rotation and exposes the key in source control.
C. Storing a decryption key in the same bucket as the encrypted data completely undermines the security of the encryption.

References

1. Google Cloud Documentation, "Using encrypted secrets". "Cloud Build can integrate with Cloud Key Management Service (Cloud KMS) to encrypt and decrypt sensitive data... To use this feature, you must grant the Cloud Build service account the Cloud KMS CryptoKey Decrypter IAM role."

2. Google Cloud Documentation, "Secrets". In the context of Cloud Build, it explicitly details the process: "Encrypt the sensitive data using Cloud KMS... Add the encrypted data to your build config... Configure your build to decrypt the data when the build runs."

Scroll to Top