Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
Your team is configuring a Cloud Build pipeline (cloudbuild.yaml) to execute automated integration tests and container security scans before deploying a microservice to production. Your pipeline must meet the following requirements:
.env files.Which configuration should you implement in your Cloud Build pipeline?
roles/cloudkms.cryptoKeyDecrypter, reference kmsKeyName in availableSecrets, and configure the bash test step to capture $?, log any failures to Cloud Logging, and finish with exit 0 so the build history records all steps.Cloud Key Management Service (Cloud KMS) lets teams encrypt sensitive values into ciphertext files or base64 strings that Cloud Build decrypts during execution using the kmsKeyName field inside availableSecrets. Ending a script with exit 0 signals to Cloud Build that the step succeeded regardless of any errors logged during execution.
exit 0 after logging a test or scan failure tells Cloud Build that the step passed. As a result, the pipeline continues to subsequent build and deployment steps, allowing failing code or vulnerable images to reach production.roles/cloudkms.cryptoKeyDecrypter allows the service account to decrypt any payload encrypted with that key rather than scoping access to a single named secret.exit 0 suppresses pipeline failure signals and defeats automated CI/CD checks.The scenario involved maintaining an existing legacy Cloud Build pipeline that already relies on Cloud KMS ciphertext, and the step was explicitly required to return exit 1 on failures rather than exit 0.
Logging diagnostic details to Cloud Logging is valuable for troubleshooting, but quality gates rely on non-zero exit codes (such as exit 1) to instruct Cloud Build to abort downstream deployment steps.
roles/secretmanager.secretAccessor role on that secret, declare it in availableSecrets.secretManager, and reference $$API_KEY via secretEnv in a bash step that captures the test exit code, logs the outcome, and runs exit 1 on failures.Integrating Secret Manager with Cloud Build provides centralized, audited credential injection at build time without persisting sensitive strings in repositories or configuration files. Pairing this with explicit exit code evaluation inside a bash build step creates an automated quality gate that logs execution outcomes and halts the pipeline whenever tests or security checks fail.
availableSecrets.secretManager and mapping it to secretEnv injects the decrypted API key into memory during step execution. Using entrypoint: 'bash' with -c and referencing $$API_KEY prevents Cloud Build from treating it as a static substitution variable.roles/secretmanager.secretAccessor directly on the individual secret (rather than at the project level) restricts the build service account to reading only the exact credential required.|| exit_code=$?) lets the script differentiate between conformant runs (0), test or policy failures (1), and unexpected internal errors, write clear status messages to Cloud Logging, and terminate the build with exit 1 so deployment steps never execute.AccessSecretVersion call made by the CI/CD service account.This approach combines Google Cloud's recommended secret management service for new projects with deterministic CI/CD quality gates, ensuring sensitive test credentials stay protected and defective or non-conformant builds are automatically blocked before reaching production.
roles/secretmanager.viewer role on the secret, pass the secret resource path in the build step's standard env field, and invoke the test runner directly without entrypoint: 'bash' so Cloud Build treats any warning output as a build failure.env configuration doesThe roles/secretmanager.viewer IAM role grants permissions to view secret metadata and list secrets (secretmanager.secrets.list), while the standard env field in a Cloud Build step sets plain-text environment variables directly in the container environment.
roles/secretmanager.viewer does not grant secretmanager.versions.access, so the build service account cannot decrypt or retrieve the API key payload. It needs roles/secretmanager.secretAccessor.env array passes the literal resource string (for example, projects/.../secrets/...) rather than the decrypted secret value. Secret Manager integration in Cloud Build requires availableSecrets.secretManager, secretEnv, and referencing $$VAR_NAME inside args (typically with entrypoint: 'bash' for shell expansion).stdout or stderr. If a test runner or scanner exits with 0 despite logging warnings, the pipeline will still proceed.env: Standard env entries are never automatically fetched from Secret Manager.secretEnv variables inline within command arguments requires a shell entrypoint like bash and the $$ escape prefix.You only needed a service account to list secret names for auditing rather than read credentials, and you were using availableSecrets with secretEnv and roles/secretmanager.secretAccessor for actual test execution.
.env file to Secure Source Manager using the git push -o dlpskip=true option to bypass secret scanning, and configure a Binary Authorization continuous validation policy to log deployment violations instead of evaluating exit codes in cloudbuild.yaml.Secure Source Manager includes secret scanning to inspect commits and pull requests for exposed credentials and block pushes containing sensitive keys, though users with permissions can force-push using dlpskip=true. Binary Authorization continuous validation periodically inspects running Pods in GKE after deployment and records policy conformance events in Cloud Logging.
.env file exposes sensitive credentials in Git commit history and bypasses a critical shift-left security control. Best practices explicitly require removing secrets from source code and .env files and storing them in Secret Manager..env file is later removed, secrets pushed into Git remain recoverable in repository history unless rewritten.cloudbuild.yaml leaves integration test failures undetected by the pipeline.You had an approved exception for non-sensitive test fixtures triggering false positives in Secure Source Manager and separately wanted post-deploy runtime compliance monitoring on GKE.
Secure Source Manager secret scanning and Binary Authorization attestations complement Cloud Build security, but they do not replace Secret Manager for runtime test credentials or exit code evaluation for CI quality gates.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated