Created
May 18, 2025 19:41
-
-
Save mikesparr/e82c2c826400e9fdf51b360d913ce773 to your computer and use it in GitHub Desktop.
Google Cloud Secret Manager example secret as file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create secret as file | |
export SECRET_ID="example-secret" | |
export SECRET_FILE=".env" | |
# create env file | |
cat > $SECRET_FILE << EOF | |
# Node environment | |
NODE_ENV=production | |
# Logging configuration | |
LOG_LEVEL=debug | |
# Server configuration | |
PORT=8080 | |
HOST=0.0.0.0 | |
# Database configuration | |
DATABASE_URL=postgres://$DB_USER:$DB_PASS@$POSTGRES_HOST:$POSTGRES_PORT/$DB_NAME | |
# ... | |
EOF | |
# create secret from env file | |
gcloud secrets create $SECRET_ID --replication-policy="automatic" | |
gcloud secrets versions add $SECRET_ID --data-file=${PWD}/$SECRET_FILE | |
# remove temp file | |
rm $SECRET_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment