Task definition now uses the correct image and env vars
Services are now mapped to their respective task definitions
This commit is contained in:
parent
28f8436768
commit
42e55f7313
@ -2,6 +2,7 @@
|
||||
# we leverage nginx as a reverse proxy in fargate instead
|
||||
|
||||
resource "aws_ecs_task_definition" "beta" {
|
||||
for_each = toset(local.buckets)
|
||||
family = "${var.athens_prefix}-beta"
|
||||
|
||||
network_mode = "awsvpc"
|
||||
@ -13,11 +14,18 @@ resource "aws_ecs_task_definition" "beta" {
|
||||
|
||||
container_definitions = jsonencode([
|
||||
{
|
||||
name = "${var.athens_prefix}-beta-container"
|
||||
name = "${var.athens_prefix}-${replace(each.value, ".", "-")}"
|
||||
image = "805875567437.dkr.ecr.us-west-1.amazonaws.com/reverse-proxy:latest"
|
||||
cpu = 256
|
||||
memory = 512
|
||||
essential = true
|
||||
environment = [
|
||||
{ name = "S3_ACCESS_KEY_ID", value = var.shockrah_xyz_s3_access_key_id },
|
||||
{ name = "S3_SECRET_KEY", value = var.shockrah_xyz_s3_secret_key },
|
||||
{ name = "S3_REGION", value = var.aws_region },
|
||||
{ name = "S3_SERVER", value = "s3-${var.aws_region}.amazonaws.com" },
|
||||
{ name = "S3_BUCKET_NAME", value = each.value },
|
||||
]
|
||||
portMappings = [
|
||||
{
|
||||
containerPort = var.nginx_port,
|
||||
@ -41,14 +49,16 @@ resource "aws_ecs_task_definition" "beta" {
|
||||
}
|
||||
|
||||
resource "aws_ecs_service" "beta_reverse_proxy" {
|
||||
name = "${var.athens_prefix}-beta-reverse-proxy"
|
||||
for_each = toset(local.buckets)
|
||||
|
||||
name = "${var.athens_prefix}-proxy-${replace(each.value, ".", "-")}"
|
||||
cluster = aws_ecs_cluster.alpha.id
|
||||
task_definition = aws_ecs_task_definition.beta.arn
|
||||
task_definition = aws_ecs_task_definition.beta[each.value].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"
|
||||
target_group_arn = aws_lb_target_group.nginx[each.value].arn
|
||||
container_name = "${var.athens_prefix}-${replace(each.value, ".", "-")}"
|
||||
container_port = var.nginx_port
|
||||
}
|
||||
|
||||
@ -63,4 +73,7 @@ resource "aws_ecs_service" "beta_reverse_proxy" {
|
||||
aws_security_group.base_ecs.id,
|
||||
]
|
||||
}
|
||||
depends_on = [
|
||||
aws_lb_target_group.nginx
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user