Skip to content

Commit fe79626

Browse files
authored
bugfix: Add policies for logging (#389)
* Add policies for logging * Add policies for logging
1 parent 8f733c2 commit fe79626

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

modules/runners/logging.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,14 @@ resource "aws_cloudwatch_log_group" "runners" {
1818
retention_in_days = var.logging_retention_in_days
1919
tags = local.tags
2020
}
21+
22+
resource "aws_iam_role_policy" "cloudwatch" {
23+
count = var.enable_ssm_on_runners ? 1 : 0
24+
name = "CloudWatchLogginAndMetrics"
25+
role = aws_iam_role.runner.name
26+
policy = templatefile("${path.module}/policies/instance-cloudwatch-policy.json",
27+
{
28+
ssm_parameter_arn = aws_ssm_parameter.cloudwatch_agent_config_runner[0].arn
29+
}
30+
)
31+
}

modules/runners/policies-runner.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ resource "aws_iam_role_policy_attachment" "managed_policies" {
4545
role = aws_iam_role.runner.name
4646
policy_arn = element(var.runner_iam_role_managed_policy_arns, count.index)
4747
}
48+
49+
// see also logging.tf for logging and metrics policies
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Effect": "Allow",
6+
"Action": [
7+
"cloudwatch:PutMetricData",
8+
"ec2:DescribeVolumes",
9+
"ec2:DescribeTags",
10+
"logs:PutLogEvents",
11+
"logs:DescribeLogStreams",
12+
"logs:DescribeLogGroups",
13+
"logs:CreateLogStream"
14+
],
15+
"Resource": "*"
16+
},
17+
{
18+
"Effect": "Allow",
19+
"Action": [
20+
"ssm:GetParameter"
21+
],
22+
"Resource": "${ssm_parameter_arn}/*"
23+
}
24+
]
25+
}

0 commit comments

Comments
 (0)