From ae61177661a89e3a8128b82f19be56ad6a1779e4 Mon Sep 17 00:00:00 2001 From: shockrah Date: Fri, 16 Dec 2022 22:51:05 -0800 Subject: [PATCH] Alpha configuration which still wont register --- infra/alpha.tf | 77 +++++++++----------------------------------------- 1 file changed, 14 insertions(+), 63 deletions(-) diff --git a/infra/alpha.tf b/infra/alpha.tf index ff7cfa7..255d740 100644 --- a/infra/alpha.tf +++ b/infra/alpha.tf @@ -2,60 +2,7 @@ # Essentially it is a cluster with services that we # choose to expose to the internet in one form or another -# Logging Configuration for services inside the cluster -####################################################### -locals { - subnet = "subnet-09302319a6678643f" -} -# Alpha Cloudwatch logging configuration -######################################## -resource "aws_cloudwatch_log_group" "alpha" { - name = "${var.athens_prefix}-alpha-log" - retention_in_days = 7 -} - -# Alpha logging role -##################### -resource "aws_iam_role" "alpha_iam_role" { - name = "${var.athens_prefix}-alpha-iam-role" - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Principal = { - Service = [ "ecs-tasks.amazonaws.com" ] - } - Effect = "Allow" - } - ] - }) -} - -resource "aws_iam_policy" "alpha_iam_policy" { - name = "${var.athens_prefix}-alpha-iam-policy" - policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Effect = "Allow" - Action = [ - "logs:CreateLogGroup", - "logs:CreateLogStream", - "logs:DescribeLogStreams", - "logs:PutLogEvents", - ] - "Resource" = "*" - } - ] - }) -} - -resource "aws_iam_role_policy_attachment" "alpha_logs" { - role = aws_iam_role.alpha_iam_role.name - policy_arn = aws_iam_policy.alpha_iam_policy.arn -} # Alpha cluster definition @@ -73,8 +20,9 @@ resource "aws_ecs_cluster" "alpha" { } -# Lewdlad Service Definition -############################ +# Lewdlad Task Definition +# This is what the service will launch to actually provide the lewdlad service +############################################################################## resource "aws_ecs_task_definition" "sample" { family = "${var.athens_prefix}-sample" @@ -88,14 +36,14 @@ resource "aws_ecs_task_definition" "sample" { container_definitions = jsonencode([ { name = "${var.athens_prefix}-sample-container" - image = "nginxdemos/nginx-hello:latest" - cpu = 128 - memory = 256 + image = "nginx" + cpu = 256 + memory = 512 essential = true portMappings = [ { - containerPort = 8080 - hostPort = 8080 + containerPort = 80 + hostPort = 80 } ] logConfiguration = { @@ -124,15 +72,18 @@ resource "aws_ecs_service" "sample" { load_balancer { target_group_arn = aws_lb_target_group.alpha_cluster.arn container_name = "${var.athens_prefix}-sample-container" - container_port = 8080 + container_port = 80 } network_configuration { assign_public_ip = true - subnets = [ local.subnet ] + 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 - ] + ] } }