forked from HwanGonJang/terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiam_roles.tf
86 lines (72 loc) · 2.39 KB
/
iam_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
86
resource "aws_iam_role" "elastic_beanstalk_instance" {
name = local.common_project_name
assume_role_policy = data.aws_iam_policy_document.assume.json
}
resource "aws_iam_instance_profile" "elastic_beanstalk_instance" {
name = local.common_project_name
role = aws_iam_role.elastic_beanstalk_instance.name
}
resource "aws_iam_role_policy" "elastic_beanstalk_instance" {
name = "${local.common_project_name}-elastic-beanstalk-instance"
role = aws_iam_role.elastic_beanstalk_instance.id
policy = data.aws_iam_policy_document.elastic_beanstalk.json
}
resource "aws_iam_role_policy_attachment" "elastic_beanstalk_instance" {
role = aws_iam_role.elastic_beanstalk_instance.id
policy_arn = data.aws_iam_policy.AWSElasticBeanstalkWebTier.arn
}
resource "aws_iam_role_policy_attachment" "elastic_beanstalk_instance_with_s3" {
role = aws_iam_role.elastic_beanstalk_instance.id
policy_arn = data.aws_iam_policy.AmazonS3FullAccess.arn
}
data "aws_iam_policy" "AWSElasticBeanstalkWebTier" {
name = "AWSElasticBeanstalkWebTier"
}
data "aws_iam_policy" "AWSElasticBeanstalkRoleCore" {
name = "AWSElasticBeanstalkRoleCore"
}
data "aws_iam_policy" "AWSElasticBeanstalkEnhancedHealth" {
name = "AWSElasticBeanstalkEnhancedHealth"
}
data "aws_iam_policy" "AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy" {
name = "AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy"
}
data "aws_iam_policy" "AmazonS3FullAccess" {
name = "AmazonS3FullAccess"
}
data "aws_iam_policy_document" "elastic_beanstalk" {
statement {
sid = "AllowGetSSMParameter"
actions = [
"ssm:GetParameter",
]
effect = "Allow"
resources = toset([
"arn:aws:ssm:${local.region}:${local.account_id}:parameter/${local.common_project_name}-*"
])
}
statement {
sid = "AllowDescribeEnvironments"
actions = [
"elasticbeanstalk:DescribeEnvironments",
]
effect = "Allow"
resources = toset([
"arn:aws:elasticbeanstalk:${local.region}:${local.account_id}:environment/${local.common_project_name}/*",
])
}
}
data "aws_iam_policy_document" "elastic_beanstalk_assume_role" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["elasticbeanstalk.amazonaws.com"]
}
condition {
test = "StringEquals"
values = ["elasticbeanstalk"]
variable = "sts:ExternalId"
}
}
}