Skip to content

Instantly share code, notes, and snippets.

@ara-ta3
Created January 20, 2018 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ara-ta3/93918ba06365db6f0d2204afe07b5452 to your computer and use it in GitHub Desktop.
Save ara-ta3/93918ba06365db6f0d2204afe07b5452 to your computer and use it in GitHub Desktop.
version: '2'
services:
hello:
image: nginx:latest
ports:
- "80:80"
mem_limit: 134217728
AWS=$(shell which aws)
ECS=$(shell which ecs-cli)
.DEFAULT_GOAL:=help
KEYNAME=ecs_cli_sample
CLUSTER=ecs-cli-sample
help:
cat Makefile
keypair/create:
$(AWS) ec2 create-key-pair --key-name $(KEYNAME) --query 'KeyMaterial' --output text > $(KEYNAME).pem
keypair/describe:
$(AWS) ec2 describe-key-pairs --key-name $(KEYNAME)
cluster/up:
$(ECS) up --keypair $(KEYNAME) --capability-iam --size 2 --instance-type t2.nano --cluster $(CLUSTER)
cluster/down:
$(ECS) down --cluster $(CLUSTER)
compose/up:
$(ECS) compose --file docker-compose.yml up --cluster $(CLUSTER)
compose/down:
$(ECS) compose --file docker-compose.yml down --cluster $(CLUSTER)
compose/ps:
$(ECS) ps --cluster $(CLUSTER)
targetgroup=
compose/service/up:
$(ECS) compose \
--cluster $(CLUSTER) \
--file docker-compose.yml \
service up \
--target-group-arn $(targetgroup) \
--container-name hello \
--container-port 80
compose/service/down:
$(ECS) compose \
--cluster $(CLUSTER) \
--file docker-compose.yml \
service down
alb=ecs-sample
subnets=
alb/create:
$(AWS) elbv2 create-load-balancer --name $(alb) --subnets $(subnets)
vpc=
alb/targetgroup/create:
$(AWS) elbv2 create-target-group --name ecs-sample --protocol HTTP --port 80 --vpc-id $(vpc)
alb/listener/create:
$(AWS) elbv2 create-listener \
--load-balancer-arn $(albarn) \
--protocol HTTP \
--port 80 \
--default-actions Type=forward,TargetGroupArn=$(targetgroup)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment