shockrah
904b730362
Also updated the image so that it has the right baseURL which gets configured during the service build ( Hugo )
68 lines
1.9 KiB
HCL
68 lines
1.9 KiB
HCL
# This nginx service will replace the beta host so that
|
|
# we leverage nginx as a reverse proxy in fargate instead
|
|
|
|
resource "aws_ecs_task_definition" "beta" {
|
|
family = "${var.athens_prefix}-beta"
|
|
|
|
network_mode = "awsvpc"
|
|
requires_compatibilities = ["FARGATE"]
|
|
execution_role_arn = aws_iam_role.alpha_iam_role.arn
|
|
|
|
cpu = 256
|
|
memory = 512
|
|
|
|
container_definitions = jsonencode([
|
|
{
|
|
name = "${var.athens_prefix}-beta-container"
|
|
image = "805875567437.dkr.ecr.us-west-1.amazonaws.com/reverse-proxy:latest"
|
|
cpu = 256
|
|
memory = 512
|
|
essential = true
|
|
portMappings = [
|
|
# blog.shockrah.xyz
|
|
{
|
|
containerPort = var.shockrah_xyz_nginx_port,
|
|
hostPort = var.shockrah_xyz_nginx_port
|
|
}
|
|
]
|
|
logConfiguration = {
|
|
logDriver = "awslogs"
|
|
options = {
|
|
awslogs-group = aws_cloudwatch_log_group.alpha.name
|
|
awslogs-region = "us-west-1"
|
|
awslogs-stream-prefix = "beta-container"
|
|
}
|
|
}
|
|
}
|
|
])
|
|
tags = {
|
|
Name = "${var.athens_prefix}-beta-task-def-container"
|
|
Description = "Reverse proxy for all static content"
|
|
}
|
|
}
|
|
|
|
resource "aws_ecs_service" "beta_reverse_proxy" {
|
|
name = "${var.athens_prefix}-beta-reverse-proxy"
|
|
cluster = aws_ecs_cluster.alpha.id
|
|
task_definition = aws_ecs_task_definition.beta.arn
|
|
desired_count = 1
|
|
launch_type = "FARGATE"
|
|
load_balancer {
|
|
target_group_arn = aws_lb_target_group.shockrah_xyz.arn
|
|
container_name = "${var.athens_prefix}-beta-container"
|
|
container_port = var.shockrah_xyz_nginx_port
|
|
}
|
|
|
|
network_configuration {
|
|
assign_public_ip = true
|
|
subnets = [
|
|
aws_subnet.delphi.id,
|
|
aws_subnet.crete_subnet.id,
|
|
]
|
|
security_groups = [
|
|
aws_security_group.ecs_web_ingress.id,
|
|
aws_security_group.base_ecs.id,
|
|
]
|
|
}
|
|
}
|