I have a scenario where i need to generate and update values of secret key at runtime and update my configuration files. The value of fernet key doesn't seem to render and it is getting replaced by string $fernet_key
itself. Have tried Within "" {} ()
. Nothing seems to be working. Please advise.
fernet_key="$(python3 -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())')"
sed -i -e 's|{FERNET_KEY}|$fernet_key|g' ~/config.yml
I am doing similar for secret key though with echo
which is working perfectly though.
secret_key="$(python3 -c 'from base64 import b64encode;import os; print(b64encode(os.urandom(64)).decode())')"
echo -e "SECRET_KEY=$secret_key" > ~/.env