-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnagios.tf
More file actions
92 lines (80 loc) · 2.34 KB
/
nagios.tf
File metadata and controls
92 lines (80 loc) · 2.34 KB
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
89
90
91
92
resource "aws_instance" "nagios" {
count = "${var.region != "ap-south-1" ? 1 : 0}"
ami = "${var.ec2_ami}"
ebs_optimized = false
instance_type = "m3.medium"
monitoring = false
key_name = "${var.common_key}"
subnet_id = "${aws_subnet.public.0.id}"
vpc_security_group_ids = ["${aws_security_group.nagios-ingress.id}"]
associate_public_ip_address = true
source_dest_check = true
iam_instance_profile = "nagios"
user_data = "${file("userdata/nagios-${var.environment}.sh")}"
root_block_device {
volume_type = "gp2"
volume_size = 30
delete_on_termination = false
}
tags {
"Service" = "maintenance"
"Name" = "${var.region}-nagios"
}
lifecycle {
ignore_changes = [
"user_data",
"ami",
"key_name",
"root_block_device.0.volume_type",
"subnet_id",
"vpc_security_group_ids",
"ebs_optimized"
]
}
}
resource "aws_alb_target_group_attachment" "nagios" {
count = "${var.region != "ap-south-1" ? 1 : 0}"
target_group_arn = "${aws_alb_target_group.nagios.arn}"
target_id = "${aws_instance.nagios.id}"
port = 80
}
resource "aws_security_group" "nagios-ingress" {
count = "${var.region != "ap-south-1" ? 1 : 0}"
name = "nagios-ingress"
description = "nagios Security Group"
vpc_id = "${aws_vpc.default-vpc.id}"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${aws_vpc.default-vpc.cidr_block}"]
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
security_groups = ["${aws_security_group.alb.id}"]
}
ingress {
from_port = 24224
to_port = 24224
protocol = "tcp"
cidr_blocks = ["${aws_vpc.default-vpc.cidr_block}"]
}
ingress {
from_port = 24224
to_port = 24224
protocol = "udp"
cidr_blocks = ["${aws_vpc.default-vpc.cidr_block}"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
"Name" = "nagios-ingress"
"Service" = "default"
}
}