AWS ECS Cluster on EC2 with Terraform (2023)
<p>This short guide will describe how to create an AWS ECS Cluster on EC2 in 2023. Basically there are already articles and code samples on the Internet, but some products in AWS are becoming obsolete (like Launch Configuration) and Terraform is undergoing API changes. So the purpose of this article is to show how to run ECS Cluster on EC2 with Terraform today.</p>
<p>This article will look at how to create a Terraform configuration to provide such resources:</p>
<ul>
<li>VPC with public subnet</li>
<li>Internet Gateway to connect to the global Internet</li>
<li>Security groups for EC2 Node & ECS Service</li>
<li>Auto-scaling group for ECS cluster with Launch Templates</li>
<li>Publish image to ECR</li>
<li>ECS cluster with task and service definition</li>
<li>Load Balancer to public access & scale ECS Service</li>
</ul>
<h1>Preparation</h1>
<p>To get started, you need to create a new Terraform project. Let’s create new directory & <code>main.tf</code> file.</p>
<p><a href="https://medium.com/@vladkens/aws-ecs-cluster-on-ec2-with-terraform-2023-fdb9f6b7db07"><strong>Click Here</strong></a></p>