Code Monkey home page Code Monkey logo

aws-deploy's Introduction

Simple web app AWS deployment via Ansible

This project demonstrates one approach to deploying a web app to AWS. For the sake of simplicity, the web app is a single HTML page served by nginx.

Locally, a Vagrant vm definition provisions a development system. The production environment is an AWS VPC with an autoscaling group setup behind an Elastic Load Balancer. Deploys are accomplished by building an AMI with the current app state and associating the AMI with an autoscaling launch configuration. The autoscaling group handles creating and launching or replacing any existing instances one by one with new instances of the updated AMI.

The app's host system is Ubuntu Trusty based. System configuration and AWS provisioning and deployment are managed via Ansible.

Requirements

  • Ruby >= 2.0
  • Python 2.7.9
  • Vagrant and Virtualbox
  • PhantomJS (via HomeBrew: brew install phantomjs)
  • pip install -r requirements.txt
  • bundle install

Local Development

Local development is managed via Vagrant's Ansible provisioner.

  • vagrant up
    • provisions a fully working local vm on ip address 192.168.55.2.

Tests

Limited Cucumber feature tests are included runnable via:

  • cucumber

AWS Deployment

Deploying the current build is accomplished with two commands.

  • First, generate a new AMI from the current Ansible build:
    • AWS_ACCESS_KEY=... AWS_SECRET_KEY=... ansible-playbook bake_ami.yml -e "key_name=*valid key name*"
  • Next, deploy the current AMI to a new autoscaling launch configuration. This will either set up a new stack or replace any existing instances one by one with the new build.
    • AWS_ACCESS_KEY=... AWS_SECRET_KEY=... ansible-playbook deploy_aws.yml -e "key_name=*valid key name*"

Ansible resources

  • ./local_dev.yml playbook responsible for local dev environment.
  • ./bake_ami.yml playbook responsible for creating an AWS AMI from the current app build. Saves ami metadata to /vars/current_ami.yml for use by deploy playbook.
  • ./deploy_aws.yml playbook responsible creating a launch config for the AMI described in /vars/current_ami.yml
  • ./roles/nginx/ role responsible for configuring nginx on app host.
  • ./roles/web_app/ role responsible for deploying web app code.
  • ./roles/aws_core/ role responsible for basic AWS infrastructure setup.

Known Issues

  • Initial Ansible provisioning of the AWS autoscaling group is failing with an error around tags. However, the group is created as expected and subsequent provisions succeed. I'm still investigating this as a potential bug or my own misunderstanding.

Credit

Assembled with plenty of sample code and guidance from the following:

aws-deploy's People

Contributors

davekonopka avatar

Watchers

James Cloos avatar

Forkers

bvgowtham

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.