forked from hyprnz/terraform-aws-data-storage-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamodb_iam.tf
47 lines (35 loc) · 1.06 KB
/
dynamodb_iam.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
data "aws_iam_policy_document" "dynamodb_table_datastore" {
count = local.create_dynamodb ? 1 : 0
statement {
sid = "DataStorageDynamodbActions"
effect = "Allow"
actions = [
"dynamodb:BatchGetItem",
"dynamodb:GetItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:BatchWriteItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem"
]
resources = [
join("", aws_dynamodb_table.this[*].arn)
]
}
statement {
sid = "DataStorageDynamodbStreamActions"
effect = "Allow"
actions = [
"dynamodb:GetRecords"
]
resources = [
"arn:aws:dynamodb:*:*:table/${join("", aws_dynamodb_table.this[*].name)}/stream/*"
]
}
}
resource "aws_iam_policy" "dynamodb_table_datastore" {
count = local.create_dynamodb ? 1 : 0
name = "DataStorage-Dynamodb-${replace(var.dynamodb_table_name, "/-| |_/", "")}-Policy"
policy = data.aws_iam_policy_document.dynamodb_table_datastore[0].json
description = "Grants permissions to access the dynamodb table and associated objects"
}