Migrating your ec2 instances on ECS to Fargate will let you focus on building applications instead of managing servers. Maybe you will ask yourself, which size do you need to pick up for your ec2 instances? The thing is that Fargate doesn’t have an instance size, you will have to define the right CPU and memory values for the tasks hosted on Fargate.
- AWS account
- AWS CLI
Issues that might occur
Using Terraform as an infrastructure as code while moving your ec2 instances to Fargate, you will have to define the CPU and memory values for the ECS tasks. If you specify an invalid value you will get the following error:
Error: ClientException: No Fargate configuration exists for given values
Define the right CPU and memory values for the tasks hosted on Fargate
To resolve the above issue, I’m going to provide you with a table that contains all supported values for the CPU and memory, where you can apply the right value in your task definition.
| CPU Value | Memory Value | | ----------- | ------------------------------------- | | 256 (25 vCPU) | 0.5GB, 1GB and 2GB | | 512 (5 vCPU) | Min 1GB and Max 4GB, in 1GB increments | | 1024 (1 vCPU) | Min 2GB and Max 8GB, in 1GB increments | | 2048 (2 vCPU) | Min 4GB and Max 16GB, in 1GB increments | | 4096 (4 vCPU) | Min 8GB and Max 30GB, in 1GB increments |
This tutorial will help you to define the right CPU and memory values for tasks hosted on Fargate. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.