-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecurity.tf
65 lines (54 loc) · 1.36 KB
/
security.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
data "aws_iam_policy_document" "assume" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "this" {
statement {
effect = "Allow"
resources = ["arn:aws:logs:*:*:*"]
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
]
}
statement {
effect = "Allow"
actions = [
"ec2:AttachVolume",
"ec2:DetachVolume"
]
resources = [
aws_ebs_volume.this.arn,
aws_instance.this.arn
]
condition {
test = "ArnEquals"
values = [aws_instance.this.arn]
variable = "ec2:SourceInstanceARN"
}
}
}
resource "aws_iam_policy" "this" {
name_prefix = "thehive-ec2-policy"
policy = data.aws_iam_policy_document.this.json
}
resource "aws_iam_role" "this" {
name_prefix = "thehive_role"
assume_role_policy = data.aws_iam_policy_document.assume.json
path = "/"
}
resource "aws_iam_role_policy_attachment" "this" {
policy_arn = aws_iam_policy.this.arn
role = aws_iam_role.this.name
}
resource "aws_iam_instance_profile" "this" {
name_prefix = "thehive_instance_profile"
role = aws_iam_role.this.name
}