Encrypt user passwords
Last updated
Last updated
SnowDDL provides functionality to encrypt user passwords, secrets and other sensitive information stored in YAML config. SnowDDL uses symmetric encryption.
Run command in terminal:
You'll get output similar to this:
This is your encryption key with added "export" command for convenience. Make sure to store this encryption key securely.
Run this command in order to set environment variable SNOWFLAKE_CONFIG_FERNET_KEYS
, which is uses by other snowddl-fernet
and snowddl
commands.
Also, make sure to add this environment variable to CI/CD pipelines running snowddl
.
Run command in terminal:
You'll get output similar to this:
This is a value encrypted by key generated earlier.
You may use !decrypt
tag with any string config parameters.
As long as valid Fernet key is present in SNOWFLAKE_CONFIG_FERNET_KEYS
environment variable, SnowDDL will automatically decrypt values with !decrypt
tag.
Normally only account administrators should know the encryption key(s). If one of administrators leaves the company, keys should be rotated and values should be encrypted again in order to prevent this administrator from being able to decrypt future passwords.
In order to perform key rotation, please do the following steps:
Generate new key using command: snowddl-fernet generate-key --export --prepend
.
Option --prepend
means that newly generated key will be added at the beginning of key sequence stored inSNOWFLAKE_CONFIG_FERNET_KEYS
.
Output of previous command will look like this:
export SNOWFLAKE_CONFIG_FERNET_KEYS=<new_key>,<old_key>
Run it in terminal to update environment variable.
Run command to rotate keys: snowddl-fernet config-rotate -c <path_to_config>
.
Encrypted values in YAML files will be decrypted by old key and encrypted once again with newly generated key.
All values with !decrypt
tag should be changed. Review & commit these changes to Git repository.
Update config of CI/CD pipelines with SNOWFLAKE_CONFIG_FERNET_KEYS=<new_key>
snowddl-fernet generate-key
- generate new encryption key
snowddl-fernet encrypt <value>
- encrypt string value with first key
snowddl-fernet decrypt <value>
- decrypt string value with any key
snowddl-fernet rotate <value>
- decrypt string value with any key and encrypt it again with first key
snowddl-fernet config-encrypt -c <path_to_config>
- encrypt and replace all values starting with YAML custom tag !encrypt
in config
snowddl-fernet config-decrypt -c <path_to_config>
- decrypt and replace all values starting with YAML custom tag !decrypt
in config
snowddl-fernet config-rotate -c <path_to_config>
- rotate and replace all values starting with YAML custom tag !decrypt
in config
Encryption keys for snowddl
command can ONLY be specified with environment variable SNOWFLAKE_CONFIG_FERNET_KEYS
.
Replacing values in YAML document is difficult if we want to preserve original formatting. The current approach relies on regular expressions looking for !encrypt
and !decrypt
tags. Only normal single-line scalar values are supported. No literal block scalars, no folded scalars.
Add encrypted value to SnowDDL config using !decrypt
: