Skip to main content

Creating secrets

  1. Go to Google Secret Manager UI.
  2. Click the button at the top labeled + CREATE SECRET.
  3. Fill in the name of your secret; e.g. bigquery_credentials.
  4. Under Secret value, upload your service account credentials JSON file or paste the JSON into the text area labeled Secret value.
  5. Scroll all the way down and click the button CREATE SECRET.
You can mount secrets from Google Secret Manager through Terraform configurations or through the Google Console UI.

Using secrets locally

Download credentials from GCP UI

  1. Download the credentials JSON file from GCP.
  2. Run Mage and mount the secrets as a volume in Docker. Follow these instructions to learn how to do this.
  3. Here are example code snippets to read from that credentials JSON file:
    Note This code example assumes your credentials JSON file downloaded from GCP is named gcp_credentials.json and that the mount path (e.g. -v) you used when running Docker is /home/secrets.

Download credentials using gcloud CLI

  1. Authenticate locally by running this command in your local terminal:
  2. Create a new .env file in your Mage project folder with the following values:
  3. Run Mage using Docker and set the environment variable GOOGLE_APPLICATION_CREDENTIALS. Follow these instructions to learn how to do this. For example, set the environment variable to:
  4. Run Mage and mount the secrets as a volume in Docker. Follow these instructions to learn how to do this. For example:
  5. Here is an example code snippet: