In this 6-part series on configuring a CI/CD pipeline using Customized Docker image on an Apache Web Server, Application Load Balancer, ECS, ECR, CodeCommit, CodeBuild, CodeDeply services -
In the 2nd article, We will create Task Definition in ECS, that references the customized image my_apache_image
in the repository - and Application Load balancer (ALB) for the Task which is to be run on Fargate Cluster.
1st article
- As a reference, please read my 1st article - 6-part series - (1) Deploy a Custom Docker Image with Centos on an Apache web server and Save it to AWS ECR Repository
Let’s get started!
Please visit my GitHub Repository for CI-CD/Docker/ECS/ECR articles on various topics being updated on constant basis.
Objectives:
1. Create role
2. Create Task definition
3. Create an Application Load Balancer (ALB) and Target groups
Pre-requisites:
- AWS user account with admin access, not a root account.
- AWS CLI.
Resources Used:
Steps for implementation to this project:
1. Create role
On the EC2 dashboard, Roles, Create role, Use cases - EC2, Next, Search for AmazonECSTaskExecutionRolePolicy, AmazonECSTaskExecutionRole
Create role
-
click AmazonECSTaskExecutionRole, Trust relationships, Edit Trust policy, delete the default code and copy and paste this policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
- Update policy
2. Create Task definition
-
on Elastic Container Service in the Containers section, Task definitions, Create new Task Definition, my_task, Under Container details, my_container
From my 1st article, Step-7, Copy image URI -
<YOUR ACCOUNT NUMBER>.dkr.ecr.us-east-1.amazonaws.com/my-ecr:latest
Next, Fargate, Under Task size, choose Task memory as 0.5 GB and Task CPU as 0.25 vCPU, Task execution role - ecsTaskExecutionRole is selected automatically, Next
Create
- Task definition - my_task
- Container name - my_container
3. Create an Application Load Balancer (ALB) and Target groups
On EC2 Dashboard, Load Balancers, Create load balancer
Application load Balancer, Create, my-alb, internet-facing, default vpc, 2 public subnets - us-east-1a and us-east-1b,
my_sg (Security group of EC2 Instance)create target group, instances, my-tg, Next, Available instances, DO NOT SELECT EC2 INSTANCE, Create target group
On Load balancer page, refresh, select my-tg
Create Load Balancer
Target Groups
What we have done so far
- We have successfully created
- (1) Task Definition in ECS that references the customized image in the repository and
- (2) Application Load balancer (ALB) for the Task which is to be run on Fargate Cluster.
Top comments (1)
The most important part of this articlec is creating the Task Defintion and there are no details listed here. I would expand on this section.