Skip to content

Commit d4c97dc

Browse files
author
nex9
committed
third times a charm
1 parent 9f77930 commit d4c97dc

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

iam.tf

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ resource "aws_iam_role" "iam_role" {
88
name = "${local.namespace}-tf-assume-role"
99

1010
assume_role_policy = <<-EOF
11-
{
12-
"Version": "2021-10-17",
13-
"Statement": [
14-
{
15-
"Action": "sts:AssumeRole",
16-
"Principal": {
17-
"AWS": ${jsonencode(local.principal_arns)}
18-
},
19-
"Effect": "Allow"
20-
}
21-
]
22-
}
11+
{
12+
"Version": "2012-10-17",
13+
"Statement": [
14+
{
15+
"Action": "sts:AssumeRole",
16+
"Principal": {
17+
"AWS": ${jsonencode(local.principal_arns)}
18+
},
19+
"Effect": "Allow"
20+
}
21+
]
22+
}
2323
EOF
2424

2525
tags = {
@@ -32,13 +32,15 @@ data "aws_iam_policy_document" "policy_doc" {
3232
actions = [
3333
"s3:ListBucket",
3434
]
35+
3536
resources = [
3637
aws_s3_bucket.s3_bucket.arn
3738
]
3839
}
3940

4041
statement {
41-
actions = ["s3.GetObject", "s3:PutObject", "s3:DeleteObject"]
42+
actions = ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"]
43+
4244
resources = [
4345
"${aws_s3_bucket.s3_bucket.arn}/*",
4446
]
@@ -52,15 +54,23 @@ data "aws_iam_policy_document" "policy_doc" {
5254
]
5355
resources = [aws_dynamodb_table.dynamodb_table.arn]
5456
}
57+
58+
statement {
59+
actions = [
60+
"kms:Decrypt",
61+
"kms:GenerateDataKey"
62+
]
63+
resources = [aws_kms_key.kms_key.arn]
64+
}
5565
}
5666

5767
resource "aws_iam_policy" "iam_policy" {
58-
name = "${local.namespace}-tf-policy"
59-
path = "/"
68+
name = "${local.namespace}-tf-policy"
69+
path = "/"
6070
policy = data.aws_iam_policy_document.policy_doc.json
6171
}
6272

6373
resource "aws_iam_role_policy_attachment" "policy_attach" {
64-
role = aws_iam_role.iam_role.name
74+
role = aws_iam_role.iam_role.name
6575
policy_arn = aws_iam_policy.iam_policy.arn
66-
}
76+
}

0 commit comments

Comments
 (0)