1. Introduction
This section provides an introduction to the topic of AWS ECS Fargate launch types, setting the context for the rest of the article. It may briefly explain what ECS Fargate is and its significance in containerized applications.
2. Purpose
The purpose section clearly outlines the objectives of the article, which likely include explaining AWS ECS Fargate launch types and providing practical guidance on how to create them using different methods.
3. What is AWS ECS?
Amazon ECS (Elastic Container Service) is a fully managed container orchestration service provided by Amazon Web Services (AWS). It allows you to easily deploy, manage, and scale containerized applications using Docker containers. ECS enables you to run and manage containers in a highly available and scalable manner without having to worry about the underlying infrastructure.
Key features of Amazon ECS include:
- Container Management: ECS allows you to run Docker containers in a scalable and efficient manner. It simplifies the process of deploying and managing containers, making it easier for developers to focus on their applications rather than infrastructure.
- Flexibility: ECS supports both "EC2 launch type" and "Fargate launch type." In the EC2 launch type, you run containers on a cluster of Amazon EC2 instances that you manage. In the Fargate launch type, you run containers without managing the underlying infrastructure, making it a serverless option for running containers.
- Task Definitions: A task definition is a blueprint that defines how a container should run, including container images, CPU and memory requirements, networking information, environment variables, and more.
- Services: ECS allows you to define and manage services, which are long-running tasks that ensure that a specified number of instances of a task definition are running at any given time. Services manage the scaling, failover, and distribution of tasks.
- Task Scheduling: ECS schedules tasks on your cluster based on your defined criteria, ensuring that tasks are distributed across instances while taking into account task placement strategies and constraints.
- Networking: ECS integrates with Amazon VPC (Virtual Private Cloud) for network isolation. Containers in a task can communicate with each other using the task's private IP address.
- Load Balancing: ECS can integrate with Amazon Elastic Load Balancing to distribute incoming traffic across multiple containers or tasks.
- Auto Scaling: ECS supports auto-scaling of services to automatically adjust the number of tasks based on resource utilization or custom metrics.
- Integration: ECS integrates with other AWS services, including AWS Identity and Access Management (IAM), Amazon CloudWatch for monitoring and logging, and Amazon CloudFormation for infrastructure management.
- Deployment Strategies: ECS supports various deployment strategies, including rolling updates, blue-green deployments, and canary deployments. This makes it easier to release new versions of your application with minimal downtime.
- CLI and SDKs: ECS provides command-line tools and SDKs that allow you to interact with the service programmatically.
- You need to provision and manage the EC2 instances yourself, including capacity planning, scaling, and maintenance.
- You define an Amazon ECS cluster that represents a group of EC2 instances.
- ECS tasks are placed on the cluster's instances based on task placement strategies and constraints.
- You can take advantage of instance types, Amazon EBS (Elastic Block Store) volumes, and other EC2-related features.
- You are responsible for managing the underlying infrastructure, including security updates, scaling, and high availability.
- You do not need to manage EC2 instances; AWS handles the infrastructure provisioning and management.
- You define task definitions specifying the container images, resources, and networking requirements.
- ECS schedules tasks on the Fargate platform, which automatically provisions the necessary compute resources.
- You pay only for the resources allocated to your tasks, with no need to worry about instance types or capacity planning.
- Fargate provides a high level of isolation between tasks, enhancing security and resource management.
- It's an ideal choice for scenarios where you want to focus on your application and not on infrastructure management.
4. Creating AWS ECS (Fargate launch type) with AWS console
In this section, the article will walk readers through a step-by-step guide on how to create an AWS ECS (Fargate launch type) using the AWS Management Console. It will include details on setting up task definitions, configuring containers, and deploying them on Fargate.
Step1. Create ECS cluster
Go to ECS service → go to Clusters → click to Create cluster.
Then, enter the cluster name, choose the VPC and subnets where your cluster is placed.
In Infrastructure, do not need to choose more option, because the default option is AWS Fargate. Then, you can click to Create button to finish ECS cluster creation.
Step 2. Create Task definition
Go to Task definitions → click to Create new task definition.
Enter task name.
Choose launch type is AWS Fargate. Then, select OS and task size and task role.
Configure container:
- For Name, enter a name for the container.
- For Image URI, enter the image to use to start a container. Images in the Amazon ECR Public Gallery registry may be specified using the Amazon ECR Public registry name only. For example, if public.ecr.aws/ecs/amazon-ecs-agent:latest is specified, the Amazon Linux container hosted on Amazon ECR Public Gallery is used. For all other repositories, specify the repository using either the repository-url/image:tag or repository-url/image@digest formats.
- A port mapping allows the container to access ports on the host to send or receive traffic. Under Port mappings, do one of the following:
- When you use the awsvpc network mode, for Container port and Protocol, choose the port mapping to use for the container.
- When you use the bridge network mode, for Container port and Protocol, choose the port mapping to use for the container.
5. Creating AWS ECS (Fargate launch type) with PrismScaler
Prism Scaler provides you with an intuitive model and a concise form, you just need to fill in the necessary information and press create, now PrismScaler will automatically build a simple web application/system that moves on a container on AWS:
Automatically build a simple serverless application on AWS:
- When simple and limited use is expected, such as company website and blog
- It is necessary to save data such as user information, and when the user is changed, the screening and processing of the screen are changed.
- One FARGATE container in public
- One RDS for private
- Role, SecurityGroup, cluster associated with the above
6. How to create security group for RDS can be accessed from Fargate container
To create a security group that allows an Amazon RDS instance to be accessed from an Amazon ECS (Fargate) container, you need to configure the RDS security group. In security group for RDS instance, you have to open port for database and source is security group of Fargate:
Please make sure your RDS instance is in the same VPC with Fargate.
7. Reference
The reference section lists the sources or external materials used in the article, allowing readers to explore further or verify the information provided.
Creating a cluster for the Fargate launch type using the console - Amazon Elastic Container Service