forked from ricardoteix/terraform-zabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
88 lines (79 loc) · 1.7 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
82
83
84
85
86
87
88
# IAM Role
resource "aws_iam_role" "projeto-role" {
name = "${var.tag-base}-role"
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
assume_role_policy = jsonencode(
{
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "ec2.amazonaws.com"
}
},
]
}
)
tags = {
Name = "${var.tag-base}-role"
}
}
resource "aws_iam_instance_profile" "projeto-profile" {
name = "${var.tag-base}-profile"
role = aws_iam_role.projeto-role.name
}
resource "aws_iam_role_policy" "projeto-policy" {
name = "${var.tag-base}-policy"
role = aws_iam_role.projeto-role.id
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"sns:Publish"
],
"Resource": [
"${aws_sns_topic.projeto-events.arn}"
]
}
]
}
EOF
}
resource "aws_iam_user" "zabbix-user" {
name = "zabbix-user"
tags = {
Name = "${var.tag-base}-zabbix-user"
}
}
resource "aws_iam_user_policy" "zabbix-user-policy" {
name = "zabbix-user-policy"
user = aws_iam_user.zabbix-user.name
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"cloudwatch:Describe*",
"cloudwatch:Get*",
"cloudwatch:List*",
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
}
resource "aws_iam_access_key" "zabbix-user-key" {
user = aws_iam_user.zabbix-user.name
}