Secret Management
API credentials and sensitive configuration are stored in GCP Secret Manager and pulled onto the VM at startup. See Authentication for details on each source's credentials.
How It Works
- Secrets are stored as individual entries in Secret Manager under the
american-beauty-instituteproject. - On first boot, the VM startup script calls
gcloud secrets versions access latestfor each secret and writes the values into/home/dagster/data-platform/.env. - The
.envfile is owned bydagster:dagsterwithchmod 600(readable only by the dagster user). - Dagster services load the
.envfile via their systemdEnvironmentFiledirective.
Secrets in Secret Manager
| Secret Name | Used By |
|---|---|
stripe-secret-key |
Stripe extractor |
paypal-client-id |
PayPal extractor |
paypal-client-secret |
PayPal extractor |
facebook-ads-access-token |
Facebook Ads extractor |
facebook-ads-account-id |
Facebook Ads extractor |
google-ads-customer-id |
Google Ads extractor |
google-analytics-property-id |
Google Analytics extractor |
google-sheets-spreadsheet-id |
Google Sheets extractor |
Adding a New Secret
-
Create the secret in Secret Manager:
bash gcloud secrets create my-new-secret \ --project=american-beauty-institute \ --replication-policy=automatic -
Add a version with the secret value:
bash echo -n "the-secret-value" | gcloud secrets versions add my-new-secret \ --project=american-beauty-institute \ --data-file=- -
Add a line to the startup script (
infra/files/startup.sh) to pull the secret into the.envfile:bash MY_NEW_SECRET=$(gcloud secrets versions access latest --secret=my-new-secret --project=$${PROJECT_ID}) -
Add the variable to
.env.examplefor local development documentation. -
On the VM, either re-run the startup script or manually add the value to
/home/dagster/data-platform/.envand restart services.
Rotating a Secret
-
Add a new version in Secret Manager:
bash echo -n "new-value" | gcloud secrets versions add my-secret \ --project=american-beauty-institute \ --data-file=- -
SSH into the VM and update the
.envfile, or restart the VM to trigger the startup script. Then restart the Dagster services:bash sudo systemctl restart dagster-code sudo systemctl restart dagster
The startup script always pulls the latest version, so previous versions remain available in Secret Manager for rollback.
Local Development
For local development, copy .env.example to .env and fill in the values manually. The .env file is gitignored and should never be committed.
cp .env.example .env
Service Account Key
The GCP service account JSON key is not stored in Secret Manager. It must be copied to the VM manually after first boot:
gcloud compute scp key.json dagster-daemon:/etc/gcp/service-account.json \
--zone=us-east1-b --tunnel-through-iap --project=american-beauty-institute
This key is used by Google Sheets, Google Analytics, Google Ads, BigQuery, and GCS.