forked from guangie88/terraform-aws-emr-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
81 lines (67 loc) · 2.21 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
# EMR IAM resources
#
data "aws_iam_policy_document" "emr_assume_role" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["elasticmapreduce.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
resource "aws_iam_role" "emr_service_role" {
name = "emr${var.environment}ServiceRole"
assume_role_policy = "${data.aws_iam_policy_document.emr_assume_role.json}"
}
resource "aws_iam_role_policy_attachment" "emr_service_role" {
role = "${aws_iam_role.emr_service_role.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole"
}
#
# EMR IAM resources for EC2
#
data "aws_iam_policy_document" "ec2_assume_role" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
resource "aws_iam_role" "emr_ec2_instance_profile" {
name = "${var.environment}JobFlowInstanceProfile"
assume_role_policy = "${data.aws_iam_policy_document.ec2_assume_role.json}"
}
resource "aws_iam_role_policy_attachment" "emr_ec2_instance_profile" {
role = "${aws_iam_role.emr_ec2_instance_profile.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role"
}
resource "aws_iam_instance_profile" "emr_ec2_instance_profile" {
name = "${aws_iam_role.emr_ec2_instance_profile.name}"
role = "${aws_iam_role.emr_ec2_instance_profile.name}"
}
#
# EMR IAM resources for auto scaling
#
data "aws_iam_policy_document" "emr_autoscaling_role_policy" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals = {
type = "Service"
identifiers = ["elasticmapreduce.amazonaws.com","application-autoscaling.amazonaws.com"]
}
}
}
resource "aws_iam_role" "emr_autoscaling_role" {
name = "emr${var.environment}AutoScalingRole"
assume_role_policy = "${data.aws_iam_policy_document.emr_autoscaling_role_policy.json}"
}
resource "aws_iam_role_policy_attachment" "emr_autoscaling_role" {
role = "${aws_iam_role.emr_autoscaling_role.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforAutoScalingRole"
}