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

Terraform

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_service" "default" {
  name     = "cloudrun-srv"
  location = "us-central1"

  template {}

  traffic {
    percent = 100
    # This revision needs to already exist
    revision_name = "cloudrun-srv-green"
  }

  traffic {
    # Deploy new revision with 0% traffic
    percent       = 0
    revision_name = "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.