learn AWS ECS

Session Steps

following steps are based on

# configure ecs-cli
ecs-cli configure profile --profile-name ecs-cluster-01 --access-key <YOUR KEY> --secret-key <YOUR SECRET>
ecs-cli configure --cluster cluster01 --region us-east-1 --config-name cluster01

# create 1 node cluster
ecs-cli up --keypair brianpfeil --capability-iam --size 1 --instance-type t2.micro

# create node app
cd simple-node
docker build -t pfeilbr/simple-node .
docker push pfeilbr/simple-node

# NOTE: pfeilbr/simple-node docker image is referenced by docker-compose.yml

ecs-cli compose up
ecs-cli ps # shows ip and port.  see
open # see
ecs-cli compose down

# make changes to server.js

# rebuild image
docker build -t pfeilbr/simple-node .

# test locally
docker run -p 49160:8080 -d pfeilbr/simple-node

# open locally
open http://localhost:49160

# push
docker push pfeilbr/simple-node

# make changes to docker-compose.yml if neccessary
ecs-cli compose up

# scale cluster to 2 nodes
ecs-cli scale --capability-iam --size 2

# scale simple-node across 2 nodes
ecs-cli compose scale 2

# create a service.  defaults to 1 task.
# if task dies, service will automatically restart it
# e.g. try /kill path of web app, which calls process.exit(1).  
# it will start a new container instance within a few seconds
ecs-cli compose service up # be sure to run "ecs-cli compose down" first

# delete service
ecs-cli compose service down

# delete cluster
ecs-cli down --force