1. Create private AWS ECR repository
Create private AWS ECR repository named “ecs-container-repo”
Push the locally stored image to the “ecs-container-repo” repository
Create an IAM role named “ecs-task-role” that will be “Elastic Container Service Task” based and have two policies attached to it: “AmazonECSTaskExecutionRolePolicy” and “CloudWatchLogsFullAccess”
Create an ECS Cluster named “ecs-demo-cluster” with the launch type as “AWS Fargate (serverless)”
Create a task definition under “ecs-demo-cluster”, named “ecs-demo-task-definition” with the following configurations:
- Launch type: AWS Fargate
- Operating System/Architecture: Linux/X86_64
- CPU: .5 vCPU
- Memory: 1 GB
- Task Role: None
- Task execution role: ecs-task-role
- Container name: ecs-demo-app
- Image URI: <ECR repository URI created in step 2>
- Container port: 80
Create a new security group “ecs-demo-app-sg” with description “ECS Demo App Security Group” and add a inbound rule to allow HTTP traffic on port 80 from anywhere.
Deploy task definition
Now run new task “ecs-demo-task-definition” keep “Launch type” as “FARGATE” and the “Platform version” as “LATEST.” Select us-east-1a as “Subnets”