-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam_table_championship.tf
62 lines (50 loc) · 1.49 KB
/
iam_table_championship.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
51
52
53
54
55
56
57
58
59
60
61
62
# championship role
data "aws_iam_policy_document" "championship_table_assume_role" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = [
"appsync.amazonaws.com",
]
}
actions = [
"sts:AssumeRole",
]
}
}
resource "aws_iam_role" "championship_table" {
name = "${var.application}.${lookup(var.env_dns_zones_prefix, terraform.workspace)}${var.domain}_table-championship"
assume_role_policy = "${data.aws_iam_policy_document.championship_table_assume_role.json}"
tags = {
Application = "${var.application}"
Environment = "${lookup(var.env_names, terraform.workspace)}"
Workspace = "${terraform.workspace}"
terraformed = "true"
}
}
# championship role policy
data "aws_iam_policy_document" "championship_table" {
statement {
effect = "Allow"
actions = [
"dynamodb:BatchGetItem",
"dynamodb:BatchWriteItem",
"dynamodb:PutItem",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:Scan",
"dynamodb:Query",
"dynamodb:UpdateItem",
]
resources = [
"${aws_dynamodb_table.championship.arn}",
"${aws_dynamodb_table.championship.arn}/*",
]
}
}
resource "aws_iam_role_policy" "championship_table" {
name = "${var.application}.${lookup(var.env_dns_zones_prefix, terraform.workspace)}${var.domain}_table-championship-access"
role = "${aws_iam_role.championship_table.id}"
policy = "${data.aws_iam_policy_document.championship_table.json}"
}