Aiden Pearce
Aiden Pearce

Reputation: 300

Google Cloud Run Service Reference Secret within Terraform

I am trying to deploy an application in Google Cloud Run with Terraform and there are some secrets I want to reference in the Cloud Run Service. However I am getting this error:

Error: Unsupported block type
│ 
│   on main.tf line 122, in resource "google_cloud_run_service" "default":
│   122:           value_from {
│ 
│ Blocks of type "value_from" are not expected here.

But in the documentation it shows that I can use value_from to reference a secret. Is there anyone who knows what is the problem?

Note: My hashicorp/google provider version is 3.90.1

Upvotes: 0

Views: 2520

Answers (1)

Marko E
Marko E

Reputation: 18223

It was in beta for that provider version:

value_from - (Optional, Beta) Source for the environment variable's value. Only supports secret_key_ref. Structure is documented below.

So you would either have to use google-beta provider [1] or switch to a newer provider version where it is no longer in beta. For example, in the latest provider version [2]:

value_from - (Optional) Source for the environment variable's value. Only supports secret_key_ref. Structure is documented below.


[1] https://registry.terraform.io/providers/hashicorp/google/3.90.1/docs/guides/provider_versions#using-the-google-beta-provider

[2] https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_service

Upvotes: 2

Related Questions