-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathiam.tf
34 lines (27 loc) · 968 Bytes
/
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
## Nessus IAM role ##
resource "aws_iam_role" "nessus-server-role" {
name = "${local.instance_tags["Name"]}-role"
assume_role_policy = data.aws_iam_policy_document.nessus-instance-assume-role-policy.json
}
# Role assumption policy
data "aws_iam_policy_document" "nessus-instance-assume-role-policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
## Role policy/permissions ##
# Attach canned ec2 read-only policy to the IAM role
resource "aws_iam_role_policy_attachment" "nessus-ec2-read-only" {
role = aws_iam_role.nessus-server-role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess"
}
## Instance Profile ##
# Assign the role to the instance profile
resource "aws_iam_instance_profile" "nessus-server-profile" {
name = "${local.instance_tags["Name"]}-profile"
role = aws_iam_role.nessus-server-role.name
}