Last active
March 17, 2022 15:55
-
-
Save networkprogrammer/3c64d16d379098260309fea2e8aa7af4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
# supply your locals here | |
private_subnet_ids = [ | |
"subnet-a", | |
"subnet-b" | |
] | |
vpc_id= "vpc-id" | |
} | |
module "nlb" { | |
source = "umotif-public/alb/aws" | |
version = "~> 2.0" | |
name_prefix = "fargate-nlb" | |
load_balancer_type = "network" | |
internal = true | |
vpc_id = local.vpc_id | |
subnets = local.private_subnet_ids | |
} | |
resource "aws_lb_listener" "port80" { | |
load_balancer_arn = module.nlb.arn | |
port = "80" | |
protocol = "TCP" | |
default_action { | |
type = "forward" | |
target_group_arn = module.fargate.target_group_arn[0] | |
} | |
} | |
resource "aws_lb_listener" "port5672" { | |
load_balancer_arn = module.nlb.arn | |
port = "5672" | |
protocol = "TCP" | |
default_action { | |
type = "forward" | |
target_group_arn = module.fargate.target_group_arn[1] | |
} | |
} | |
resource "aws_lb_listener" "port5673" { | |
load_balancer_arn = module.nlb.arn | |
port = "5673" | |
protocol = "TCP" | |
default_action { | |
type = "forward" | |
target_group_arn = module.fargate.target_group_arn[2] | |
} | |
} | |
resource "aws_lb_listener" "port5674" { | |
load_balancer_arn = module.nlb.arn | |
port = "5674" | |
protocol = "TCP" | |
default_action { | |
type = "forward" | |
target_group_arn = module.fargate.target_group_arn[3] | |
} | |
} | |
resource "aws_ecs_cluster" "cluster" { | |
name = "example-ecs-cluster" | |
} | |
module "fargate" { | |
source = "umotif-public/ecs-fargate/aws" | |
version = "6.4.2" | |
name_prefix = "ecs-fargate-example" | |
desired_count = 1 | |
vpc_id = local.vpc_id | |
private_subnet_ids = local.private_subnet_ids | |
cluster_id = aws_ecs_cluster.cluster.id | |
target_groups = [ | |
{ | |
target_group_name = "port80" | |
container_port = 80 | |
protocol = "TCP" | |
}, | |
{ | |
target_group_name = "port5672" | |
container_port = 5672 | |
protocol = "TCP" | |
}, | |
{ | |
target_group_name = "port5673" | |
container_port = 5673 | |
protocol = "TCP" | |
}, | |
{ | |
target_group_name = "port5674" | |
container_port = 5674 | |
protocol = "TCP" | |
} | |
] | |
task_container_protocol = "TCP" | |
wait_for_steady_state = true | |
# platform_version = "1.4.0" # defaults to LATEST | |
task_container_image = "marcincuber/2048-game:latest" | |
task_definition_cpu = 256 | |
task_definition_memory = 512 | |
task_container_port = 80 | |
health_check = { | |
port = 80 | |
path = "/healthy" | |
} | |
task_stop_timeout = 90 | |
depends_on = [ | |
module.nlb | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment