Demonstrate how to use Mozilla SOPS.
Refer to terraform_examples/19_sops
brew install sops
# show version
sops -v
Instal gpg tooling
brew install gpg
gpg --version
# compare to latest
open https://www.gnupg.org/download/
Create the gpg locally here
# check if you have a key already
gpg --list-secret-keys --keyid-format=long
# generate a key - use noreply chrisguest75@users.noreply.github.com
# enter a passphrase
gpg --full-generate-key
# for older versions
gpg --default-new-key-algo rsa4096 --gen-key
# answers
> (1) RSA and RSA
> What keysize do you want? (3072) 4096
> Real name: SOPS Test
> Email address: sops@guestcode.dev
> Comment: Testing SOPS
> You selected this USER-ID:
> "SOPS Test (Testing SOPS) <sops@guestcode.dev>"
> password: testsops
# see generated keys
gpg --list-secret-keys --keyid-format=long
# export the key in armor format
gpg --armor --export XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# set key thumbprint
export SOPS_PGP_FP="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# encrypt
sops -e ./my_secrets.json
sops -e ./my_secrets.json > ./my_secrets.enc.json
# if you have a password on the pgp key
gpg-agent
GPG_TTY=$(tty)
export GPG_TTY
# now decrypt
sops -d ./my_secrets.enc.json
gpg --export-secret-keys "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" > XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pgp.key
gpg --import XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pgp.key
unset SOPS_PGP_FP
gpg --delete-secret-keys "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"