ECS, ALB (ELBv2), RDS and Cloud Formation reference with a small bash script for workflow
- bash (Mac or Linux)
- aws-cli >=1.11.20
See https://raw.githubusercontent.com/marshyski/ecs-kit/master/userdata.sh
- RHEL 7
- awscli (Optional)
- awslogs agent (Optional)
- ecs agent
- ALB
- Auto Scaling Group
- CloudFormation
- CloudWatch
- EC2
- ECS
- IAM
- RDS
- Route53
- SNS Topic
This assumes you have VPC, Security Groups, IAM Certs, KeyPair, SNS Topic and Route53 Zones created
- Create ECS Cluster manually by adding just clicking create cluster and entering name
<app name>-<environment>
- Create CloudWatch Log Group manually
<app name>-<environment>
cft-ecs.json
- Change
ClusterName
helloworld-* to<app name>-<environment>
- Setup
InstanceProfile
for ecsInstanceRole https://docs.aws.amazon.com/AmazonECS/latest/developerguide/instance_IAM_role.html - Fill out params sections for each environment or just dev to get started
- Under
UserData
change location of where your user-data script is hosted. I recommend S3 by installing awscli first inUserData
.
userdata.sh
- Enter http proxies in locations if needed
- Change any logic for app config
- Add additional installations before systemctl commands
task-definition.json
- Change path to
conf
andlog
- Change
name
from helloworld to app name - Change
image
to location of Docker image - Tweak other values as needed
cft-db.json
- Change
ClusterName
helloworld-* to<app name>-<environment>
- Fill out params sections for each environment or just dev to get started
stack
- Change STACK variable to the app name
- Update ENVIRONMENT variable with additional environments
$ ./stack
Stack Name: helloworld
./stack create [dev qa prod] [db] - Create stack from cft-ecs.json
./stack delete [dev qa prod] [db] - Delete stack name helloworld
./stack update [dev qa prod] - Update stack from version or latest
you can override latest version for create and update
./stack update dev 0.0.1
Database command example, database will be altered by cft-db.json
./stack create dev db
./stack delete dev db
Example
./stack create dev db # Create DB
./stack create dev # Create Web / App Environment
- Update application version quickly
- Quicker refresh of EC2 instances with new AMIs
- Use minimal tools and AWS services for logging, metrics, alarms, etc.
- Bootstrap microservices to run on EC2 Container Service and Application Load Balancer