Skip to content

Commit 49b523f

Browse files
Fix SSM Agent ability to upload to S3 for output associations (#12)
* Add IAM Role Inline Policy to allow actions on target s3 bucket for ssm output associations * SSM S3 Associations Output is environment-independent * Fix the name: it ends with -output * ${var.project} is not part of the ssm associations output S3 bucket name
1 parent e68ba65 commit 49b523f

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

terraform/data.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ data "aws_iam_policy" "cloudwatch_logs_full_access" {
4848
data "aws_iam_policy" "ssm_managed_instance_core" {
4949
arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
5050
}
51+
52+
data "aws_s3_bucket" "ssm_associations_output" {
53+
bucket = "${var.company}-${var.core_infrastructure_project}-ssm-associations-output"
54+
}

terraform/ethereum_ec2_iam_role.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ resource "aws_iam_role" "ethereum_node" {
2020
}
2121
}
2222

23+
resource "aws_iam_role_policy" "ethereum_node" {
24+
name = "${var.project}-${var.environment}-ethereum-node-inline-policy"
25+
role = aws_iam_role.ethereum_node.id
26+
27+
policy = jsonencode({
28+
Version = "2012-10-17"
29+
Statement = [
30+
{
31+
Effect = "Allow",
32+
Action = [
33+
"s3:PutObject",
34+
"s3:GetObject",
35+
"s3:ListBucket"
36+
],
37+
Resource = [
38+
"${data.aws_s3_bucket.ssm_associations_output.arn}",
39+
"${data.aws_s3_bucket.ssm_associations_output.arn}/*"
40+
]
41+
}
42+
]
43+
})
44+
}
45+
2346
resource "aws_iam_role_policy_attachment" "ethereum_node" {
2447
policy_arn = data.aws_iam_policy.cloudwatch_agent_server_policy.arn
2548
role = aws_iam_role.ethereum_node.name

0 commit comments

Comments
 (0)