Skip to content

Instantly share code, notes, and snippets.

@nshttpd
Created August 1, 2017 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nshttpd/ee78529256c3061d2e2fb0452b99479f to your computer and use it in GitHub Desktop.
Save nshttpd/ee78529256c3061d2e2fb0452b99479f to your computer and use it in GitHub Desktop.
gcloud encrypt
#!/bin/bash
set -e
GCP_PROJECT="${GCP_PROJECT:-default}"
KMS_KEYRING="${KMS_KEYRING:-default}"
KMS_LOCATION="${KMS_LOCATION:-default}"
KMS_KEY="${KMS_KEY:-default}"
hash gcloud 2>/dev/null || { echo >&2 "glcoud command required to encrypt secrets."; exit 1; }
echo "Encrypting : $1"
gcloud kms encrypt --ciphertext-file=$1.enc --plaintext-file=$1 --key=${KMS_KEY} --keyring=${KMS_KEYRING} --location=${KMS_LOCATION}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment