Change a Cloud Run Service to add a tag to a newly deployed revision

A sample that shows how to change a defined Cloud Run Service to add a newly deployed revision to show how to deploy a new revision and test it prior to having traffic deployed.

Code sample


To learn how to apply or remove a Terraform configuration, see Basic Terraform commands. For more information, see the Terraform provider reference documentation.

resource "google_cloud_run_v2_service" "default" {
  name     = "cloudrun-srv"
  location = "us-central1"

  template {}

  # Define the traffic split for each revision
  traffic {
    percent = 100
    # This revision needs to already exist
    revision = "cloudrun-srv-green"

  traffic {
    # Deploy new revision with 0% traffic
    percent  = 0
    revision = "cloudrun-srv-blue"
    tag      = "tag-name"

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.