From fafaae4ba77448f1897cf7eb88d7ae736f8260f2 Mon Sep 17 00:00:00 2001 From: shockrah Date: Fri, 16 Dec 2022 22:05:21 -0800 Subject: [PATCH] Logging and role configuration speerated --- infra/cluster-logging.tf | 28 ++++++++++++++++++++++++++++ infra/roles.tf | 24 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 infra/cluster-logging.tf create mode 100644 infra/roles.tf diff --git a/infra/cluster-logging.tf b/infra/cluster-logging.tf new file mode 100644 index 0000000..f06ed82 --- /dev/null +++ b/infra/cluster-logging.tf @@ -0,0 +1,28 @@ +# Logging Configuration for services inside the cluster +####################################################### + +# 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" + } + ] + }) +} + diff --git a/infra/roles.tf b/infra/roles.tf new file mode 100644 index 0000000..a21bd56 --- /dev/null +++ b/infra/roles.tf @@ -0,0 +1,24 @@ +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 +} +