-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpolicy.tf
50 lines (42 loc) · 1.28 KB
/
policy.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
48
49
50
// dynamodb table Read Policy
data "aws_iam_policy_document" "readpolicy" {
statement {
actions = [
"dynamodb:DescribeTable",
"dynamodb:GetItem",
"dynamodb:GetRecords",
"dynamodb:ListTables",
"dynamodb:Query",
"dynamodb:Scan",
]
resources = ["arn:aws:dynamodb:${var.region}:${data.aws_caller_identity.current.account_id}:table/tf-${var.app_name}"]
effect = "Allow"
}
}
resource "aws_iam_policy" "readpolicy" {
name = "${var.app_name}-${var.region}-DynamoDb-Read-Policy"
policy = "${data.aws_iam_policy_document.readpolicy.json}"
}
// dynamodb table Write Policy
data "aws_iam_policy_document" "writepolicy" {
statement {
actions = [
"dynamodb:DeleteItem",
"dynamodb:DescribeTable",
"dynamodb:GetItem",
"dynamodb:GetRecords",
"dynamodb:ListTables",
"dynamodb:PutItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:UpdateItem",
"dynamodb:UpdateTable",
]
resources = ["arn:aws:dynamodb:${var.region}:${data.aws_caller_identity.current.account_id}:table/tf-${var.app_name}"]
effect = "Allow"
}
}
resource "aws_iam_policy" "writepolicy" {
name = "${var.app_name}-${var.region}-DynamoDb-Write-Policy"
policy = "${data.aws_iam_policy_document.writepolicy.json}"
}