Coder Social home page Coder Social logo

ocrrss / e7-cloudformation-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from devteds/e7-cloudformation-docker

0.0 1.0 0.0 5 KB

Create AWS CloudFormation Stack and deploy Dockerized application. Devteds episode #7 https://devteds.com/episodes/7-create-aws-cloudformation-stack-for-ec2-rds-and-deploy-docker-app

e7-cloudformation-docker's Introduction

AWS CloudFormation + EC2 + RDS and Docker App

Devteds Episode #7

Create an application stack that consist of an EC2 instance and RDS Instance for MySQL, using AWS CloudFormation. And then deploy an dockerized / containerized API application to run on EC2 instance.

Episode video link

Episode Video Link

Visit https://devteds.com to watch all the episodes. If you're looking to learn Docker with ECS checkout episode #9

Setup AWS & CLI

  • Login to AWS Management Console and Generate a new KeyPair. Save the downloaded key
  • Configure AWS Command Line Interface (AWS CLI) with a new AWS Access Key and a secret generated on AWS
  • Update the stack.yml if you're using this template for your application
  • Use AWS CLI to run create-stack command that'll create all the resources defined in the stack.yml
  • Update the docker-compose app.yml if you're using this for your application
  • Using docker compose run database migration command, run service in background and run db-seed to populate test data

Commands

mkdir ~/projs
git clone https://github.com/devteds/e7-cloudformation-docker.git deploy-aws
cd deploy-aws

# Create new KeyPair on AWS CLI and name it aws-key1 and,
cp ~/Downloads/aws-key1.pem ./
chmod 400 aws-key1.pem

# On AWS CLI, Create a new user with programatic access which will generate a new Access Key & Secret. With that,
aws configure --profile demo
# Make sure to use the region name (us-west-2 or another) as the default for this profile 'demo'

aws cloudformation create-stack --profile demo --stack-name blog-stage --template-body file://$PWD/stack.yml

# After the stack creation is successful, Get the IP address or DNS of the AppNode EC2 instance
ssh -i aws-key1.pem ubuntu@<IP ADDRESS OR DNS OF THE EC2 INSTANCE>

# Point your local to EC2 instance,
export DOCKER_HOST=tcp://35.160.122.95:2375
docker ps -a

docker-compose -f app.yml run --rm app rails db:migrate
docker-compose -f app.yml up -d
docker-compose -f app.yml ps
docker-compose -f app.yml run --rm app rails db:seed

# Make sure to delete the stack and all resources when you're done
aws cloudformation delete-stack --stack-name blog-stage --profile demo

More useful commands

aws cloudformation describe-stack-resources --stack-name blog-stage --profile demo
aws cloudformation describe-stack-events --stack-name blog-stage --profile demo

# For more help
aws cloudformation help
aws cloudformation create-stack help
aws cloudformation delete-stack help
aws cloudformation delete-stack help
aws cloudformation describe-stack-resources help

e7-cloudformation-docker's People

Contributors

shettigarc avatar chandra-dtest avatar

Watchers

James Cloos avatar

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.