Create AWS CloudFormation Stack for EC2 & RDS and Deploy Docker App
Chandra Shettigar
Learn how to create application stack using AWS CloudFormation and then deploy dockerized API application.
Stack is defined using YAML template that contains 4 resources to be created on AWS,
- EC2 Instance to run the application on
- EC2 Security Group that defines the possible inbound ports on the EC2 instance
- RDS Instance for MySQL database
- RDS Security Group that defines the possible sources the database can be reached from
Following are the steps to walk through,
- Create a KeyPair on AWS account to be used for SSH access to EC2
- Generate API keys and configure the AWS CLI on the local machine
- Create a simple stack using CloudFormation and this stack will consist of an EC2 instance and necessary security group for the EC2 instance
- Update the stack to install and configure docker on the EC2 instance
- Update the stack to add RDS instance and necessary security group to the stack
- Create Docker compose file to define the application to be deployed on EC2 instance with its database on RDS instance
- Deploy the application on the EC2 instance (docker host) remotely from local
Links:
- Source Code: https://github.com/devteds/e7-cloudformation-docker
- AWS CloudFormation: https://aws.amazon.com/cloudformation
- AWS EC2: https://aws.amazon.com/ec2
- AWS RDS: https://aws.amazon.com/rds
- Configure Docker Engine: https://docs.docker.com/engine/admin/
- Docker & TLS: https://docs.docker.com/engine/security/https/
- Docker Image: https://hub.docker.com/r/devteds/rails-api-example
If you found this post informative, please help us spread the word by sharing it with your friends and followers