Deploying Cloud Run Service fails because of VPC Connector annotation

Viewed 1946

Deploying a new cloud run image failed today with the following error:

ERROR: (gcloud.run.deploy) Annotation 'run.googleapis.com/vpc-access-connector' is not supported on resources of kind 'Service'. Supported kinds are: Revision, Job

This is strange since there has been no change to the annotation for a while.

1 Answers

Apparently, gcp stopped supporting that tag in the root service metadata. As described by the documentation, the tag should be moved to the template's metadata (see the yaml part from the cloud run doc).

The terraform code:

resource "google_cloud_run_service" "gateway" {
  ... 
  template {
    metadata {
      annotations = {
        "run.googleapis.com/vpc-access-egress" : "all"
        "run.googleapis.com/vpc-access-connector": google_vpc_access_connector.connector.id
      }
    }
    spec {
      ...
    }
  }
  metadata {
    annotations = {
      "run.googleapis.com/launch-stage": "BETA"

      // I had the annotation here before
    }
  }
  ...
}

Related