2.7.0 • Published 5 years ago

deploy_manager_aws v2.7.0

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

AWS Deployment Manager

A node package to Automate Environment building, termination, and management within AWS EC2 Instances with Codeship and AWS Route53 via AWS Elastic Beanstalk. AWS EC2 Free accounts get 750 hours per month of t2.micro instances free. This is usually enough for an entire month, but wont incur more than $1 in charges either way unless instances are left unterminated for very long periods of time (all instance runtime counts towards the 750 hour free amount)

This module works by Codeship automatically creating a build, from github master and develop merges, and deploying these using the deploy.sh script in the project root, or wherever you decide to put it. This deploy script creates an AWS EC2 Instance with that commit, and you can use npm run whats-live to see which environments are live or beta, with their respective urls, and commit hashes, messages, and GitHub information. Running npm run promote <hash> <environment> with a matching environment to the Domain Name Groups in the deployer.ts file, will point the DNS of those domain names to that instance of EC2. You can run whats-live again to see when the environment switch is complete. It's best to wait 15 or so minutes for the DNS to completely change over, at which point you can run npm run terminate against the old commit hash. This will terminate that EC2 instance so that there are no further costs with that specific instance.

Required Environment Variables

  • SERVICE_NAME - The Name of the project for information purposes
  • NODE_ENV - Environment that this is part of; Good names include 'prod' and 'beta' - likely will be deprecated in future

Runtime arguments

--unattended: Run unattended. All default settings will be accepted, and the output is formatted to be parsed

Usage

Download this repository, and use it as a node module by putting it into a utilities folder, or deployment folder or whatever.

Move the scripts/deploy.sh file to the root of your project, this is what will be called in CodeShip to actually deploy the built instance

Edit the scripts/deployer.ts file with any config information at the bottom, for required environment variables and default values that your project will use

Add the following scripts to your package.json for TypeScript projects

"clean": "rm -rf ./bin", // You could substitute this command for whatever clean command
"build": "npm run clean && tsc", // You could substitute this command for whatever build command
"deploy": "npm run build && node path/to/scripts/deploy.js",
"terminate": "npm run build && node path/to/scripts/terminate.js",
"whats-live": "npm run build && node path/to/scripts/whats-live.js",
"promote": "npm run build && node path/to/scripts/promote.js"

Command Usage

  • npm run deploy <commit hash>
  • npm run terminate <commit hash>
  • npm run whats-live
  • npm run promote <commit hash> <environment (example: 'beta')>