Description
You’re working for the company FlyEasy; They’ve been having hard time with their monilitic application and all the costs related to maitaining this type of architecture. They’re willing to try the microservices approach and assess the pros/cons. They assigned you the task to deploy a sample nodejs application on AWS Elastic Container Service.
Learning Objectives
- Create ECS IAM Roles
- Create a new ECS Cluster
- Create a task definition
- Create a service
- Access the application
Step 1 : Create ECS IAM Roles
First things first, let’s create 2 IAM roles, these roles will be used later.
EcsInstanceRole
EcsTaskExecutionRole
1. Open the IAM console, and select Create role

2. Select AWS service > EC2 > Next Permissions
3. Select AmazonEC2ContainerServiceforEC2Role and click on “Next“
4. Name your role “EcsInstanceRole” , then click on “Create role”
Repeat the same steps to create the second role EcsTaskExecutionRole
At step 3, select AmazonECSTaskExecutionRolePolicy
Step 2 : Create a new ECS Cluster
1. Open the Elastic Container Service, then select “Create Cluster”
2. Select EC2 Linux + Networking
3.
Cluster name: “Preproduction”
Number of instances : 1
Key pair : “Select your key pair”
4. Select an existing VPC or create a new one
5. Select the role we’ve created earlier “EcsInstanceRole” , then click on “Next”
Step 3 : Create a task definition
1. Select Create new Task Definition
2. Select EC2
3.
Task Definition Name : nodejs-demo-app
4. Select the 2nd role we’ve created earlier “EcsTaskExecutionRole” , then click on “Add container”
5. In the container section:
Container name: nodejs-demo-app-ecs
Image: ikubelabs/nodejs-demo-app-ecs:1.0
Memory Limits: 200
Port mappings
Host port : 80
Container port : 8080
6. Scroll down and add this environment variable
Key: ENVAPP
Value: STAGING
Then click on “Add”
7. Set the task size to 500
8. Scroll down and select “Create” ,
Step 3 : Create a service
1. Select “Actions > Create Service“
2.
Launch Type : EC2
Cluster: Preproduction
Service name: node-demo-app-service
Number of tasks: 1
Minimum healthy percent : 0
3. Leave the options by defaulit, then “Next step”
4. Select “None” then “Next step”
5. Leave the default option, then “Next step”
6. Select “Create Service“
7. Back to the console, select “Tasks” tab, see the task in execution, it should be in “PENDING” state, wait until it shows “RUNNING”
Then click on the Task id to see more details
8. Scroll down and expand the container for more details
9. Open the URL to access the application
10. This webpage is displayed.