-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
47 lines (39 loc) · 1.2 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
###Ecs Instance Profile Sequence####
resource "aws_iam_instance_profile" "ecs_instance_profile" {
name = "${var.name}-ecs-agent-profile"
role = aws_iam_role.ecs_instance.name
}
data "aws_iam_policy_document" "ec2_assume_role" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_role" "ecs_instance" {
name = "${var.name}-ecs-instance-role"
path = "/grafana/ecs/"
assume_role_policy = data.aws_iam_policy_document.ec2_assume_role.json
managed_policy_arns = [
"arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonSSMManagedInstanceCore",
"arn:${data.aws_partition.current.partition}:iam::aws:policy/CloudWatchLogsFullAccess",
"arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
]
inline_policy {
name = "s3-resources-reader"
policy = data.aws_iam_policy_document.s3_resources_access.json
}
}
data "aws_iam_policy_document" "s3_resources_access" {
statement {
actions = [
"s3:GetObject",
"s3:ListBucket"
]
resources = [
aws_s3_bucket.resources.arn, "${aws_s3_bucket.resources.arn}/*"
]
}
}