Protect the data encryption key with a key stored in Google Cloud Key Management Service (KMS).
Configuration example
Create a key with Google Cloud KMS:
gcloud kms keys create pg-tde-master-1 --location=global --keyring=pg-tde --purpose=encryption
Use the gcloud kms command with the pg-tde-master-1 key to wrap and unwrap the data encryption key. You can provide these commands as environment variables or as initdb command-line arguments.
Via environment variable
PGDATAKEYWRAPCMD='gcloud kms encrypt --plaintext-file=- --ciphertext-file=%p --location=global --keyring=pg-tde --key=pg-tde-master-1' PGDATAKEYUNWRAPCMD='gcloud kms decrypt --plaintext-file=- --ciphertext-file=%p --location=global --keyring=pg-tde --key=pg-tde-master-1'
Via command argument
initdb --data-encryption -D /var/lib/edb/as16/data \ --key-wrap-command='gcloud kms encrypt --plaintext-file=- --ciphertext-file=%p --location=global --keyring=pg-tde --key=pg-tde-master-1' \ --key-unwrap-command='gcloud kms decrypt --plaintext-file=- --ciphertext-file=%p --location=global --keyring=pg-tde --key=pg-tde-master-1'