Search code examples
amazon-web-servicesaws-cloudformationamazon-ecsaws-fargate

AWS ECS service creation ( Ec2 Launch type) holding Create IN Progress status and showing Create Failled State after Rollback


I am learning and exploring AWS ECS service by creating cluster, service and task definition (ECS EC2 launch type). And pulling docker image from AWS ECR. Both cluster and task definitions are getting creating successfully. But while creating service, its holding "Create In Progress" state long time and showing Create Failled. And when scrolling down , it also lists Rollback also.

My Docker file looks like the following for helloworld angular application,

FROM node:latest as build
WORKDIR /app

RUN npm install -g @angular/cli
COPY ./package.json .
RUN npm install
COPY . .
RUN ng build --configuration production

FROM nginx as runtime
COPY --from=build /app/dist/helloworld/ /usr/share/nginx/html
EXPOSE 80

Steps Done For My Task

  1. Cluster Creation

    1.1 Created cluster with support of Ec2 Launch type 1.2 Choosing Amazon Linux 2 instance 1.3 Choosed t2.micro instance type

  2. Task Definition

    2.1 Choosed Ec2 launch type 2.2 Choosed Linux/x86_64 2.3 .5 vCpu and 1 Gb Memory 2.4 Choosed my ECR URL for image and mapped to port 80 2.5 Networ mode awsvpc

  3. Service creation

    3.1 Choosed Ec2 Launch type 3.2 Application type service. 3.3 Choosed family with created task defintion. 3.4 Service type replica 3.4 Choosed Desired no of task 1

NB -:It is working sucessfully in ECS Fargate method (By choosing Fargate option in Task definition and Fargate option in service)

Problem is When I am defining task defintion ec2 launch type and service also Ec2 launch type. If I am choosing Ec2 type in both places , it showing created failled error. When I am checking CloudWatch Logs its not giving any log.

Trouble shooted way,

  1. To cross check roles/permission/policy issues, I created from root user account, but still same response.
  2. I created cluster to support fargate/ec2 launch type and created service with fargate (by using application LB and without using application LB) , but still same response
  3. Cross checked with memory defined which is exceeding t2.micro instance type
  4. Cross checked by defining /path to health check
  5. Checked the port mapping and http protocol
  6. ECR repository path
  7. Security group to allow permissions
  8. I cross checked the cluster and task definition which created by defining launch type Ec2.

Can anyone suggest any troubleshooting method or kindly give any guidance to resolve please?

enter image description here

Updated Error

Error occurred during operation 'ECS Deployment Circuit Breaker was triggered error in aws ecs

enter image description here

enter image description here


Solution

  • You can't use t2.micro for an ECS task that requires "1 Gb Memory". t2.micro is too small for that as it has only 1 Gb of RAM. OS and other processes that run on the instance take large chunk of the 1 Gb available, leaving not enough for the task.