generated from champ-oss/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
58 lines (53 loc) · 1.52 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
# tflint-ignore: terraform_comment_syntax
//noinspection ConflictingProperties
resource "aws_iam_role" "this" {
name = var.enable_iam_role_name_prefix ? null : substr("${var.git}-${var.name}", 0, 64)
name_prefix = var.enable_iam_role_name_prefix ? substr("${var.git}-state-machine-role", 0, 38) : null
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
data "aws_iam_policy_document" "assume_role" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
identifiers = [
"states.amazonaws.com",
"lambda.amazonaws.com"
]
type = "Service"
}
}
}
resource "aws_iam_policy" "this" {
name_prefix = var.git
policy = data.aws_iam_policy_document.this.json
}
resource "aws_iam_role_policy_attachment" "this" {
policy_arn = aws_iam_policy.this.arn
role = aws_iam_role.this.name
}
data "aws_iam_policy_document" "this" {
statement {
actions = [
"events:PutTargets",
"events:PutRule",
"events:DescribeRule",
"logs:CreateLogDelivery",
"logs:GetLogDelivery",
"logs:UpdateLogDelivery",
"logs:DeleteLogDelivery",
"logs:ListLogDeliveries",
"logs:PutResourcePolicy",
"logs:DescribeResourcePolicies",
"logs:DescribeLogGroups",
"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"xray:GetSamplingRules",
"xray:GetSamplingTargets",
"iam:ListRoles",
"iam:PassRole",
"sqs:SendMessage"
]
resources = ["*"]
}
}