[devserum] AWS setup guide for ECR event-based deploy
Create VPC & Subnet
this part will handle another page
Create ECR
make new ECR with some separator such as ${organization}/${stage}/${project-name} e.g > aws-fulfilment/dev/node-api
Tips
if you push same tag to ECR old one will change to <untagged>
if you active immutable tag override will not able which means you can't push latest tag twice to ECR
Create Cluster
Step -1: select cluster template
select Network only (Fargate) Fargate is serverless tech
select EC2 Linux + Networking type
Step - 2: Configure cluster
check *Enable Container Insights
Configure cluster
cluster name
Instance configuration
Provisioning Model -> select Spot for saving
EC2 Instance Types -> t2.micro for start
Networking
VPC -> your VPC
Subnets -> your Subnets
Security group -> your Security group
Container instance IAM role
use default
Spot Fleet IAM role
use default
CloudWatch Container Insights
click *Enable Container Insights
*click Create
Spot instance type support both of task type 'fargate', 'ec2'
Let me explain ..... An ECS Cluster when using EC2 Launch Type will create EC2 instances in the background... When its using Fargate Launch type, its serverless, meaning that there are No EC2 Instances created in the background ....
Now, in case of EC2 launch type, you can choose What Instances Types should the ECS Cluster launch in the background ... whether On demand or Spot Instances ...
Create Task
Step 1: Select launch type compatibility
select Fargate
Step 2: Configure task and container definitions
Task Definition Name
Task role -> ecsTaskExcutionRole
Task execution IAM role
default
Task size
Task memory -> 0.5GB || your order
Task CPU -> 0.25 vCPU || your order
Container Definitions
click *Add Container
Container name
Image -> input your ECR url with tag
Memory Limits -> 95% of what you just setup. if 0.5GB = 475MB (approximately)
Port mappings -> your container port > it's only can mapping same port such as 80:80 || 4000:4000 not support 4000:80 like that. if you want to do, you should choose classic load balancer
CPU Units -> 95% of what you just setup 1 CPU has 1024 unit. so if you choose 0.25 vCPU that means you have 256 unit so 256 * 0.95 = 243.2 input the 243
*create task
Create Load Balancer
Go to EC2 Dashboard
Go to *Load Balancers of *LOAD BALNACING section
click *Create Load Balancer
select *Application Load Balancer for REST
Step 1: Configure Load Balancer
Basic Configuration
name
Scheme -> internet-facing
IP Address type -> IPv4
Listeners
open HTTP & HTTPS(if you have Certificate)
Availability Zones
select your VPC
select our AZ
*click Next
Step 2: Configure Security Settings
default
*click Next
Step 3: Configure Security Groups
select existing security group ( if you have)
*click Next
Step 4: Configure Routing
Create Target Group for ECS service
ECS Cluster type
Target group type
ECS - Fargate
IP
ECS - EC2
instance
EC2
instance
Step
Last updated
Was this helpful?