Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 09476eb

Browse files
committed
fix: reduce permission required for session manager (#1018)
1 parent f8f8981 commit 09476eb

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

modules/runners/policies-runner.tf

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ resource "aws_iam_instance_profile" "runner" {
1414
path = local.instance_profile_path
1515
}
1616

17-
resource "aws_iam_role_policy_attachment" "runner_session_manager_aws_managed" {
18-
count = var.enable_ssm_on_runners ? 1 : 0
19-
role = aws_iam_role.runner.name
20-
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
17+
resource "aws_iam_role_policy" "runner_session_manager_aws_managed" {
18+
name = "runner-ssm-session"
19+
count = var.enable_ssm_on_runners ? 1 : 0
20+
role = aws_iam_role.runner.name
21+
policy = templatefile("${path.module}/policies/instance-ssm-policy.json", {})
2122
}
2223

2324
resource "aws_iam_role_policy" "ssm_parameters" {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Effect": "Allow",
6+
"Action": [
7+
"ssm:DescribeAssociation",
8+
"ssm:GetDeployablePatchSnapshotForInstance",
9+
"ssm:GetDocument",
10+
"ssm:DescribeDocument",
11+
"ssm:GetManifest",
12+
"ssm:ListAssociations",
13+
"ssm:ListInstanceAssociations",
14+
"ssm:PutInventory",
15+
"ssm:PutComplianceItems",
16+
"ssm:PutConfigurePackageResult",
17+
"ssm:UpdateAssociationStatus",
18+
"ssm:UpdateInstanceAssociationStatus",
19+
"ssm:UpdateInstanceInformation"
20+
],
21+
"Resource": "*"
22+
},
23+
{
24+
"Effect": "Allow",
25+
"Action": [
26+
"ssmmessages:CreateControlChannel",
27+
"ssmmessages:CreateDataChannel",
28+
"ssmmessages:OpenControlChannel",
29+
"ssmmessages:OpenDataChannel"
30+
],
31+
"Resource": "*"
32+
},
33+
{
34+
"Effect": "Allow",
35+
"Action": [
36+
"ec2messages:AcknowledgeMessage",
37+
"ec2messages:DeleteMessage",
38+
"ec2messages:FailMessage",
39+
"ec2messages:GetEndpoint",
40+
"ec2messages:GetMessages",
41+
"ec2messages:SendReply"
42+
],
43+
"Resource": "*"
44+
}
45+
]
46+
}

0 commit comments

Comments
 (0)