You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating a new Cloud Run service that uses Secret Manager fails with this error:
╷
│ Error: Error creating Service: googleapi: Error 400: metadata.annotations: Annotation 'run.googleapis.com/secrets' is not supported on resources of kind 'Service'. Supported kinds are: Revision, Execution
│ Details:
│ [
│ {
│ "@type": "type.googleapis.com/google.rpc.BadRequest",
│ "fieldViolations": [
│ {
│ "description": "Annotation 'run.googleapis.com/secrets' is not supported on resources of kind 'Service'. Supported kinds are: Revision, Execution",
│ "field": "metadata.annotations"
│ }
│ ]
│ }
│ ]
│
│ with module.cloud_run.google_cloud_run_service.default,
│ on .terraform/modules/cloud_run/main.tf line 2, in resource "google_cloud_run_service" "default":
│ 2: resource google_cloud_run_service default {
│
╵
I believe this is happening because the run.googleapis.com/secrets annotation is being set in metadata.annotations where it's not supported.
Removing the run.googleapis.com/secrets annotation from here should fix the issue.
Example Code
Terraform to reproduce the error:
variable"project_id" {
type=stringdescription="The GCP project ID where the resources will be created."
}
# Create a service accountresource"google_service_account""this" {
project=var.project_idaccount_id="my-service-account"display_name="my-service-account"
}
# Create a secret in Secret Managerresource"google_secret_manager_secret""secret" {
project=var.project_idsecret_id="my-secret"replication {
automatic=true
}
}
# Store the secret valueresource"google_secret_manager_secret_version""secret" {
secret=google_secret_manager_secret.secret.idsecret_data="super-secret-value"
}
# Allow the service account to read the secret value from Secret Managerresource"google_secret_manager_secret_iam_member""secret" {
project=var.project_idsecret_id=google_secret_manager_secret.secret.secret_idrole="roles/secretmanager.secretAccessor"member="serviceAccount:${google_service_account.this.email}"
}
module"cloud_run" {
source="git::[email protected]:garbetjie/terraform-google-cloud-run.git//?ref=2.2.1"project=var.project_idlocation="us-central1"name="my-cloud-run"image="us-docker.pkg.dev/cloudrun/container/hello"service_account_email=google_service_account.this.emailenv=[
{
key ="MY_SECRET"
secret = google_secret_manager_secret.secret.id
version ="latest"
},
]
}
The text was updated successfully, but these errors were encountered:
Summary
Creating a new Cloud Run service that uses Secret Manager fails with this error:
I believe this is happening because the
run.googleapis.com/secrets
annotation is being set in metadata.annotations where it's not supported.Removing the
run.googleapis.com/secrets
annotation from here should fix the issue.Example Code
Terraform to reproduce the error:
The text was updated successfully, but these errors were encountered: