Skip to content

Commit 9904d72

Browse files
committed
AWS ECS Deployment example
1 parent 457daf5 commit 9904d72

File tree

7 files changed

+47
-4
lines changed

7 files changed

+47
-4
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Overview
22

3-
![ECS in two public subnets](ecs-in-two-public-subnets.svg)
3+
![ECS Zero Downtime Deployment](ecs-in-two-public-subnets.svg)
44

55
# Companion Blog Post
66

7-
[The AWS Journey Part 2: Deploying a Docker image from the Command Line with CloudFormation](https://reflectoring.io/aws-cloudformation-deploy-docker-image/)
7+
[The AWS Journey Part 4: Zero-Downtime Deployment with CloudFormation and ECS](https://reflectoring.io/aws-cloudformation-ecs-deployment/)
88

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Turning off the AWS pager so that the CLI doesn't open an editor for each command result
2+
export AWS_PAGER=""
3+
4+
aws cloudformation create-change-set \
5+
--change-set-name update-reflectoring-ecs-zero-downtime-deployment-service \
6+
--stack-name reflectoring-ecs-zero-downtime-deployment-service \
7+
--use-previous-template \
8+
--parameters \
9+
ParameterKey=StackName,ParameterValue=reflectoring-ecs-zero-downtime-deployment-network \
10+
ParameterKey=ServiceName,ParameterValue=reflectoring-hello-world \
11+
ParameterKey=ImageUrl,ParameterValue=docker.io/reflectoring/aws-hello-world:v4 \
12+
ParameterKey=ContainerPort,ParameterValue=8080 \
13+
ParameterKey=HealthCheckPath,ParameterValue=/hello \
14+
ParameterKey=HealthCheckIntervalSeconds,ParameterValue=90
15+
16+
aws cloudformation describe-change-set \
17+
--stack-name reflectoring-ecs-zero-downtime-deployment-service \
18+
--change-set-name update-reflectoring-ecs-zero-downtime-deployment-service

aws/cloudformation/ecs-zero-downtime-deployment/create.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ aws cloudformation create-stack \
1414
--parameters \
1515
ParameterKey=StackName,ParameterValue=reflectoring-ecs-zero-downtime-deployment-network \
1616
ParameterKey=ServiceName,ParameterValue=reflectoring-hello-world \
17-
ParameterKey=ImageUrl,ParameterValue=docker.io/reflectoring/aws-hello-world:latest \
17+
ParameterKey=ImageUrl,ParameterValue=docker.io/reflectoring/aws-hello-world:v3 \
1818
ParameterKey=ContainerPort,ParameterValue=8080 \
1919
ParameterKey=HealthCheckPath,ParameterValue=/hello \
2020
ParameterKey=HealthCheckIntervalSeconds,ParameterValue=90

aws/cloudformation/ecs-zero-downtime-deployment/delete.sh

100644100755
File mode changed.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Turning off the AWS pager so that the CLI doesn't open an editor for each command result
2+
export AWS_PAGER=""
3+
4+
aws cloudformation execute-change-set \
5+
--stack-name reflectoring-ecs-zero-downtime-deployment-service \
6+
--change-set-name update-reflectoring-ecs-zero-downtime-deployment-service
7+
8+
aws cloudformation wait stack-update-complete --stack-name reflectoring-ecs-zero-downtime-deployment-service

aws/cloudformation/ecs-zero-downtime-deployment/service.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Resources:
100100
Memory: !Ref 'ContainerMemory'
101101
Image: !Ref 'ImageUrl'
102102
PortMappings:
103-
- ContainerPort: !Ref 'ContainerPort' serve
103+
- ContainerPort: !Ref 'ContainerPort'
104104
LogConfiguration:
105105
LogDriver: 'awslogs'
106106
Options:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Turning off the AWS pager so that the CLI doesn't open an editor for each command result
2+
export AWS_PAGER=""
3+
4+
IMAGE_URL=$1
5+
6+
aws cloudformation update-stack \
7+
--stack-name reflectoring-ecs-zero-downtime-deployment-service \
8+
--use-previous-template \
9+
--parameters \
10+
ParameterKey=StackName,ParameterValue=reflectoring-ecs-zero-downtime-deployment-network \
11+
ParameterKey=ServiceName,ParameterValue=reflectoring-hello-world \
12+
ParameterKey=ImageUrl,ParameterValue=$IMAGE_URL \
13+
ParameterKey=ContainerPort,ParameterValue=8080 \
14+
ParameterKey=HealthCheckPath,ParameterValue=/hello \
15+
ParameterKey=HealthCheckIntervalSeconds,ParameterValue=90
16+
17+
aws cloudformation wait stack-update-complete --stack-name reflectoring-ecs-zero-downtime-deployment-service

0 commit comments

Comments
 (0)