GCP 2nd generation Cloud Functions: How can I use Secrets?

Viewed 129

How can I use a secret when creating a 2nd gen Cloud Function?

When I create a 1st generation Cloud Function, I can add secrets like so:

Cloud Function 1st gen has option adding secret

However this option is not available when creating a 2nd generation Cloud Function:

Cloud Function 2nd gen no option adding secret

1 Answers

When you create a 2nd generation Cloud Function, you actually create a Cloud Run.

So after the creation of your function go to Cloud Run, find the function you created, click on Edit & Deploy new revision and then add the references to the secret you need:

Edit and Deploy Cloud Run Secrets

Related