Skip to content

Commit

Permalink
Add ecs fargate cluster (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenmartius authored Apr 22, 2024
2 parents b2d171d + 895ecbd commit e45154a
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stacks/prod/config.tm.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
globals "terraform" "module" "version" {
vpc = "5.7.1"
vpc = "5.7.1"
ecs_cluster = "5.11.1"
}

globals "vpc" {
Expand All @@ -8,6 +9,10 @@ globals "vpc" {
azs = ["us-east-1a", "us-east-1b", "us-east-1c"]
}

globals "ecs" {
cluster_name = "prd-ecs-cluster"
}

globals {
tags = {
Environment = "prd"
Expand Down
11 changes: 11 additions & 0 deletions stacks/prod/us-east-1/ecs-fargate-cluster/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT

terraform {
backend "s3" {
bucket = "terramate-example-terraform-state-backend"
dynamodb_table = "terraform-lock"
encrypt = true
key = "terraform/stacks/by-id/ac1cbc21-a7d8-451e-a12e-f390bbcc1a51/terraform.tfstate"
region = "us-east-1"
}
}
24 changes: 24 additions & 0 deletions stacks/prod/us-east-1/ecs-fargate-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT

module "ecs_cluster" {
cluster_name = "prd-ecs-cluster"
fargate_capacity_providers = {
FARGATE = {
default_capacity_provider_strategy = {
base = 20
weight = 50
}
}
FARGATE_SPOT = {
default_capacity_provider_strategy = {
weight = 50
}
}
}
source = "terraform-aws-modules/ecs/aws//modules/cluster"
tags = {
Environment = "prd"
Terraform = "true"
}
version = "5.11.1"
}
29 changes: 29 additions & 0 deletions stacks/prod/us-east-1/ecs-fargate-cluster/main.tm.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
generate_hcl "main.tf" {
inherit = false

content {
module "ecs_cluster" {
source = "terraform-aws-modules/ecs/aws//modules/cluster"
version = global.terraform.module.version.ecs_cluster

cluster_name = global.ecs.cluster_name

# Capacity provider
fargate_capacity_providers = tm_try(global.ecs_fargate.fargate_capacity_providers, {
FARGATE = {
default_capacity_provider_strategy = {
weight = 50
base = 20
}
}
FARGATE_SPOT = {
default_capacity_provider_strategy = {
weight = 50
}
}
})

tags = tm_try(global.tags, {})
}
}
}
5 changes: 5 additions & 0 deletions stacks/prod/us-east-1/ecs-fargate-cluster/stack.tm.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
stack {
name = "ECS Fargate Cluster Production"
description = "Production ECS Fargate Cluster deployed in us-east-1"
id = "ac1cbc21-a7d8-451e-a12e-f390bbcc1a51"
}
16 changes: 16 additions & 0 deletions stacks/prod/us-east-1/ecs-fargate-cluster/terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT

terraform {
required_version = "1.7.5"
}
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.31"
}
}
}
provider "aws" {
region = "us-east-1"
}

0 comments on commit e45154a

Please sign in to comment.