Given a service that has a secret password in its config file called config.json
, create a software config file called config-development.json
:
password=[PASSWORD]
During Codedeploy, there are scripts or hooks, that run during the deployment cycle eg BeforeInstall, Install, AfterInstall. During the AfterInstall script execution, get the secret from the parameter store via cli, store it in a variable, and then replace the [PASSWORD]
value in the json file, using sed or any search and replace command line tool.
Rename the resulting file to the config.json
, and restart the service.
This approach will allow you to keep secrets out of your repo, and use only value from the parameter store.
See https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html#reference-appspec-file-structure-hooks-list
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…