This is really part 2 of a 2-part question. Part 1 was about a more graceful way to load secrets in Google Secret Manager during the middleware processing of ASP.Net Web API applications ...
Part 2: Now that my Web API is deployed to Google Run, it doesn't have the credentials it needs to access secrets stored in Google Secret Manager.
Currently a new image is built whenever there is a commit on the test
branch of my repo. That triggers a build process at Google Build, which uses this cloudbuild.yaml
to do the build...
steps:
# Docker Build
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t',
'gcr.io/${PROJECT_ID}/tic-tac-toe-api',
'./api']
# Docker Push
- name: 'gcr.io/cloud-builders/docker'
args: ['push',
'gcr.io/${PROJECT_ID}/tic-tac-toe-api']
# Entrypoint, timeout and environment variables
- name: 'gcr.io/cloud-builders/gcloud'
args: ['run', 'deploy', 'tic-tac-toe-api',
'--image', 'gcr.io/${PROJECT_ID}/tic-tac-toe-api', '--region', 'us-central1']
images:
- gcr.io/$PROJECT_ID/tic-tac-toe-api
Once the image is built and deployed to Google Run it needs the GC CLI credentials to be loaded so that it can access the Secret Manager API (or so I assume).
But how to get them in there?
Storing my Google Cloud credentials in a file that gets committed to the repo, so that the cloudbuild.yaml can find it and incorporate in the build seems counter-productive.
I can't find a viable solution to this and at this point I can't tell if that is because there isn't one, or because deploying .Net Web API applications to GCP inside a Docker container is just complete madness. :p