Meer
Meer

Reputation: 1

I'm having a hard time passing secrets in gcp secret manager to cloud build docker build stage. Am i passing these correctly?

steps:

Upvotes: 0

Views: 37

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75940

You can do much simpler. Keep in mind that you can use SECRET_ENV in Cloud Build only in "script" context (entrypoint bash)

See my working exemple

steps:
- name: 'gcr.io/cloud-builders/docker'
  secretEnv: ['SECRET']
  entrypoint: 'bash'
  args:
    - -c
    - |
      echo $$SECRET
      docker build --build-arg SECRET="$$SECRET" -f Dockerfile -t gcr.io/<your project id>/test-secret . 

availableSecrets:
  secretManager:
    - versionName: projects/<YOUR PROJECT ID or NUMBER>/secrets/<YOUR SECRET NAME>/versions/latest
      env: 'SECRET'

And the dockerfile

FROM debian:buster-slim

ARG SECRET

RUN echo "The secret is $SECRET"

Side question: Must URLs be stored in secret manager?

Upvotes: 0

Related Questions