I have an application exposing a REST API which needs some secrets to launch, like database password, p12 keystore password or HS512 secret for issuing tokens. Those values are extracted from application environment. I will be deploying the app to AWS EC2. I've come up with 4 options to pass those values:
- As environment variables passed with the switch to
java
command - this would be very inconvenient - Create a bash script with hard coded passwords stored in plain text which executes the
java
command - that would make them available for anyone who connects to the EC2 instance. - Same as above but instead of storing secrets in plain text, encrypt them with a symmetric key and make the script prompt for it and run the application with decrypted values.
- AWS secret manager - that seems to be an overkill for a simple web app and also introduces costs.
What is the right way to do this? Does option 3 even make sense?