-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
179 lines (151 loc) · 4.6 KB
/
main.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
terraform {
required_version = ">= 0.12"
}
####
#ES
####
# Use this data source to get the access to the effective Account ID in which
# Terraform is working.
data "aws_caller_identity" "current" {}
# To obtain the name of the AWS region configured on the provider
data "aws_region" "current" {}
module "es_security_group" {
source = ".//modules/security-group"
vpc_id = var.vpc_id
security-groups = {
"aws-es-sg" = {
description = "Elasticsearch security group"
tags = {
"Name" = "elk-dev-sg"
}
rules = {
egress = {
type = "egress"
description = "outbound"
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
self = false
}
logstash = {
type = "ingress"
description = "Allow Logstash inbound"
protocol = "tcp"
from_port = 0
to_port = 65535
cidr_blocks = ["172.10.0.0/24"]
self = false
}
https = {
type = "ingress"
description = "Allow Logstash inbound"
protocol = "tcp"
from_port = 443
to_port = 443
cidr_blocks = ["10.0.0.0/16"]
self = false
}
}
}
}
}
module "aws_es" {
vpc_id = var.vpc_id
source = ".//modules/es"
domain_name = var.es_domain_name
elasticsearch_version = var.es_version
create_service_link_role = false
vpc_options = {
subnet_ids = ["subnet-yoursubnetidhere", "subnet-yoursubnetidhere"]
security_group_ids = [module.es_security_group.security_group["aws-es-sg"].id]
}
cluster_config = {
dedicated_master_enabled = "false"
instance_count = "2"
instance_type = "t2.small.elasticsearch"
zone_awareness_enabled = "true"
availability_zone_count = "2"
}
ebs_options = {
ebs_enabled = "true"
volume_size = "25"
}
encrypt_at_rest = {
enabled = "false"
kms_key_id = "alias/aws/es"
}
node_to_node_encryption_enabled = true
snapshot_options_automated_snapshot_start_hour = 23
access_policies = templatefile("${path.module}/es-access_policies.tpl", {
region = data.aws_region.current.name,
account = data.aws_caller_identity.current.account_id,
domain_name = var.es_domain_name
})
timeouts_update = "60m"
tags = {
"department" = var.department
"environment" = var.environment
"project" = var.project
"ticket_no" = var.ticket
}
}
####
#EC2 & NLB
####
module "aws_security_group" {
source = ".//modules/security-group"
vpc_id = var.vpc_id
security-groups = {
"logstash-sg" = {
description = "Logstash security group"
tags = {
"Name" = "logstash-dev-sg"
}
rules = {
egress = {
type = "egress"
description = "Logstash Outbound to Elasticsearch"
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
self = false
}
ingress = {
type = "ingress"
description = "Allow Filebeat inbound"
protocol = "tcp"
from_port = 5044
to_port = 5044
cidr_blocks = ["10.252.0.0/16"]
self = false
}
}
}
}
}
module "ec2-logstash" {
source = ".//modules/ec2_nlb"
instance_type = "t3a.small"
name = "logstash-dev"
department = "cse"
environment = "development"
project = "elk-project"
ticket = "CS-239"
nlb_config = var.nlb_config
forwarding_config = var.forwarding_config
tg_config = var.tg_config
security_group_ids = [module.aws_security_group.security_group["logstash-sg"].id]
}
module "logstashec2-role" {
source = ".//modules/iamprofile"
}
module "elkdev_com" {
source = ".//modules/route53"
vpc_id = var.vpc_id
department = "cse"
environment = "development"
project = "elk-project"
ticket = "CS-239"
}