This post is part of a series about the stack Grafana deployed on AWS ECS. This project is a simple MVP.
In part 1, we will set up our cluster ECS and LoadBalance.
AWS ECS: is a container orchestration that helps us to deploy, manage, and scale applications.
Pre-Requirements
- Knowledge with Terraform
- AWS Account
- 2 subnets publics, with tag:
tier = public
- 2 subnets private, with tag:
tier = private
- 2 subnets publics, with tag:
AWS VPC
We need the following structure for AWS VPC. We'll get ID the subnets privates with the Terraform DataSource.
Remember the add tag tier = private
for private subnets.
Remember the add tag tier = public
for public subnets.
ECS Cluster Type
Currently, there are three types of the ECS cluster. Cluster EC2 instance, serverless Fargate, and on-primeses VM.
Consult the AWS documentations for more details. https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-configuration.html
We'll use the ECS EC2 cluster for this MVP.
Create ECS Cluster
You can use this Terraform module to create cluster ECS.
Below an example how to use this module. That will provide a cluster ECS type of EC2, and Application LoadBalance.
####################################################################################################
### ECS Cluster o11y ###
####################################################################################################
module "ecs_cluster" {
source = "https://github.com/EzzioMoreira/aws-terraform-module//modules/ecs-cluster?ref=v0.0.1-ecs-cluster-alb"
cluster_name = "ecs-cluster-example"
min_size = 1
max_size = 2
desired_size = 1
instance_type = "t3a.medium"
vpc_id = "vpc-xxxxxxxx"
tags = {
created_by = "terraform"
documentation = "null"
env = "prod"
repository = "ezziomoreira/aws-terraform-modules"
service = "observability"
team = "sre"
}
}
####################################################################################################
### Loadbalance o11y ###
####################################################################################################
module "loadbalance" {
source = "https://github.com/EzzioMoreira/aws-terraform-module//modules/loadbalance?ref=v0.0.1-ecs-cluster-alb"
name = "ecs-cluster-example-internal"
type = "application"
internal = true
subnet_ids = ["subnet-xyxyx", "subnet-yxyxyx"]
security_group_ids = [sg-123123123]
tags = {
created_by = "terraform"
documentation = "null"
env = "prod"
repository = "ezziomoreira/aws-terraform-modules"
service = "observability"
team = "sre"
}
}
Top comments (0)