Enforcing Testing Gates with Binary Authorization in Cloud Run

PCD By islever Editorial Last updated

Short answer

B Enable Binary Authorization on your Cloud Run service to enforce policies that require attestations confirming tests have passed before allowing deployment.

Question

You use Cloud Build to build and test container images prior to deploying them to Cloud Run. Your images are stored in Artifact Registry. You need to ensure that only container images that have passed testing are deployed. You want to minimize operational overhead. What should you do?
  1. Deploy a new revision to a Cloud Run service. Assign a tag that allows access to the revision at a specific URL without serving traffic. Test that revision again. Migrate the traffic to the Cloud Run service after you confirm that the new revision is performing as expected.
  2. Enable Binary Authorization on your Cloud Run service. Create an attestation if the container image has passed all tests. Configure Binary Authorization to allow only images with appropriate attestation to be deployed to the Cloud Run service. Correct Answer
  3. Create a GKE cluster. Verify that all tests have passed, and then deploy the image to the GKE cluster.
  4. Configure build provenance on your Cloud Build pipeline. Verify that all the tests have passed, and then deploy the image to a Cloud Run service.

Key Takeaways

Binary Authorization ensures only tested container images are deployed to Cloud Run by requiring attestations. This method minimizes operational overhead compared to manual checks or infrastructure changes like GKE.

Expert Analysis

Artifact Registry provides managed container image storage with IAM, vulnerability scanning, and regional repositories. Container Registry (A) is deprecated. Cloud Storage (C) doesn't have container-specific features. Docker Hub (D) is external.

The scenario presents a classic DevSecOps challenge: enforcing quality gates in a CI/CD pipeline without introducing manual bottlenecks or excessive operational overhead. The requirement is explicit—only images that pass testing should be deployed to Cloud Run—and the constraint is minimizing operational burden. While the reference explanation provided with this question contains text describing storage options (Artifact Registry vs. Container Registry), it appears misaligned with the specific question stem regarding deployment enforcement. However, based on the source answer key 'B' and the logical requirements of the scenario, we must evaluate the options through the lens of Google Cloud's policy enforcement mechanisms.

Option B proposes enabling Binary Authorization on the Cloud Run service. Binary Authorization is a feature that enforces policies about which container images can run in your projects. It works by requiring an attestation—a signed statement from a trusted party (in this case, the build/test system)—that verifies the image has passed required checks. By configuring Binary Authorization to allow only images with appropriate attestations, you create a hard policy gate at the deployment level. If an image hasn't been attested (i.e., testing failed or wasn't performed), the deployment will be rejected automatically. This approach minimizes operational overhead because it integrates directly into the deployment workflow via IAM and policy settings, rather than requiring complex custom scripts or external orchestration layers. It ensures security and compliance by design, adhering to the principle of least privilege and automated verification.

Let's analyze why the other options are incorrect or suboptimal:

Option A describes a traffic migration strategy using tags (canary releases). While this is a valid pattern for gradual rollouts and safety nets in Cloud Run, it does not inherently prevent the deployment of untested images. You could still deploy a revision of an untested image; you would just choose not to route traffic to it initially. The requirement is to ensure only tested images are deployed, implying a prevention mechanism, not just a traffic management strategy. Furthermore, this adds operational complexity by requiring manual or scripted validation before migration.

Option C suggests creating a GKE cluster. This is a significant deviation from the stated architecture (Cloud Run) and introduces substantial operational overhead. Managing Kubernetes clusters involves node maintenance, scaling policies, network configuration, and more. It violates the "minimize operational overhead" constraint entirely. Additionally, moving from Cloud Run to GKE is not a solution to the testing enforcement problem; it's a change in infrastructure platform.

Option D mentions configuring build provenance. Build provenance in Cloud Build records metadata about how an image was built (e.g., source commit, build triggers). While useful for auditing and traceability, provenance itself does not enforce deployment policies. It provides evidence of the build process but does not stop an untested image from being deployed unless explicitly integrated with a policy engine like Binary Authorization. Without Binary Authorization, provenance data is passive information, not an active gatekeeper.

Therefore, Binary Authorization (Option B) is the correct choice because it provides an automated, policy-based enforcement mechanism that aligns with Cloud Run's serverless nature and minimizes operational overhead by leveraging native IAM and attestation workflows.

Exam Strategy

When asked to enforce quality gates or security policies in a cloud-native deployment pipeline, prioritize managed policy engines like Binary Authorization over custom scripting or infrastructure shifts. Look for keywords like "minimize operational overhead" and "ensure only..." which point toward automated, declarative enforcement mechanisms rather than procedural workarounds.

Practice All PCD Questions

Access 84 questions with complete answers and detailed explanations.

View Full PCD Practice Test →

← Back to PCD Study Guide