AWS CodeDeploy scripts for deploying Node apps
npm install @aptoma/node-codedeployBash scripts for deploying node apps with AWS CodeDeploy the aptoma way.
The following is required for the app that should be deployed
1. pm2 config must exist in
2. pm2.json must contain "cwd": "/var/services/app"
Install this module in your application
npm install @aptoma/node-codedeploy
Copy appspec.yml to your application root dir
cp nodemodules/@aptoma/node-codedeploy/appspec.yml .
Create a pm2 config in config/pm2.json
[{
"name": "my-app",
"script": "./src/server.js",
"exec_mode": "cluster",
"cwd": "/var/services/app",
"out_file": "/var/log/aptoma/my-app.out.log",
"error_file": "/var/log/aptoma/my-app.err.log",
"kill_timeout": 2300
}]
Setup custom environment variables in scripts/deploy/env.sh
#!/bin/bash
export MONGO_URI=getCredential "my-app" "mongo_uri"
export CRYPTO_KEY=getCredential "my-app" "crypto_key"
There is a helper function available for getting credstash credentials.
Using this requires that credential keys are using the following form service.
Example of scripts/deploy/env.sh
#!/bin/bash
export MONGO_URI=getCredential "my-app" "mongo_uri"