-
Notifications
You must be signed in to change notification settings - Fork 0
/
roles.tf
85 lines (72 loc) · 1.92 KB
/
roles.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
data "aws_iam_policy_document" "lambda_job_policy" {
statement {
effect = "Allow"
actions = [
"logs:CreateLogStream",
"logs:PutLogEvents",
"medialive:*",
"mediapackage:*",
"dynamodb:*",
"cloudfront:*",
"events:*",
"lambda:*",
"ssm:*",
"s3:*",
"ecs:*",
"ivs:*",
"autoscaling:SetDesiredCapacity"
]
resources = ["*"]
}
statement {
effect = "Allow"
actions = [
"iam:PassRole"
]
resources = [
aws_iam_role.medialive_job.arn
]
}
}
data "aws_iam_policy_document" "lambda_job_trust" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}
resource "aws_iam_role" "lambda_job" {
name = "${var.project_base_name}medialive-lambda-role"
assume_role_policy = data.aws_iam_policy_document.lambda_job_trust.json
}
resource "aws_iam_role_policy" "lambda_job" {
name = "${var.project_base_name}medialive-lambda-policy"
role = aws_iam_role.lambda_job.id
policy = data.aws_iam_policy_document.lambda_job_policy.json
}
resource "aws_iam_role_policy_attachment" "basic_execution" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
role = aws_iam_role.lambda_job.name
}
data "aws_iam_policy_document" "medialive_job_trust" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = [
"mediapackage.amazonaws.com",
"medialive.amazonaws.com"
]
}
}
}
resource "aws_iam_role" "medialive_job" {
name = "${var.project_base_name}medialive-api-role"
assume_role_policy = data.aws_iam_policy_document.medialive_job_trust.json
}
resource "aws_iam_role_policy_attachment" "admin" {
policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
role = aws_iam_role.medialive_job.name
}