-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ec2.tf
184 lines (155 loc) · 4.4 KB
/
ec2.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
180
181
182
183
184
# TODO: 없앨 예정
# https://github.com/femiwiki/femiwiki/issues/132
resource "aws_key_pair" "femiwiki" {
key_name = "femiwiki-2018-09-15"
public_key = file("res/femiwiki_rsa.pub")
}
# 김지현이 소지하고있는 비상용 키페어
resource "aws_key_pair" "femiwiki_green" {
key_name = "femiwiki-emergency-key"
public_key = file("res/femiwiki_rsa_green.pub")
}
resource "aws_eip" "femiwiki" {
instance = aws_instance.femiwiki.id
vpc = true
}
resource "aws_eip" "test_femiwiki" {
instance = aws_instance.femiwiki_consul_test.id
vpc = true
}
data "aws_availability_zone" "femiwiki" {
name = "ap-northeast-1a"
}
#
# EBS volumes
#
resource "aws_ebs_volume" "persistent_data_mysql" {
availability_zone = data.aws_availability_zone.femiwiki.name
type = "gp3"
size = 8
tags = {
Name = "Mysql data directory for Main Server"
}
}
resource "aws_ebs_volume" "persistent_data_caddycerts" {
availability_zone = data.aws_availability_zone.femiwiki.name
type = "gp3"
size = 1
tags = {
Name = "Caddycerts for Main Server"
}
}
#
# Femiwiki main server
#
resource "aws_instance" "femiwiki" {
ebs_optimized = true
ami = data.aws_ami.amazon_linux_2_arm64.image_id
instance_type = "t4g.small"
key_name = aws_key_pair.femiwiki.key_name
monitoring = false
iam_instance_profile = aws_iam_instance_profile.femiwiki.name
disable_api_termination = true
availability_zone = data.aws_availability_zone.femiwiki.name
vpc_security_group_ids = [
aws_default_security_group.default.id,
aws_security_group.femiwiki.id,
aws_security_group.nomad_cluster.id,
]
root_block_device {
delete_on_termination = true
volume_size = 12
volume_type = "gp3"
}
credit_specification {
cpu_credits = "unlimited"
}
tags = {
Name = "Main Server"
}
user_data = file("res/bootstrap.sh")
lifecycle {
ignore_changes = [
ami,
user_data,
# https://github.com/femiwiki/infra/issues/88
volume_tags,
]
}
}
#
# Exprimental instances for consul test
# https://github.com/femiwiki/femiwiki/issues/253
#
resource "aws_instance" "femiwiki_consul_test" {
ebs_optimized = true
ami = data.aws_ami.amazon_linux_2_arm64.image_id
instance_type = "t4g.micro"
key_name = aws_key_pair.femiwiki.key_name
monitoring = false
iam_instance_profile = aws_iam_instance_profile.femiwiki.name
disable_api_termination = false # during test period
availability_zone = data.aws_availability_zone.femiwiki.name
vpc_security_group_ids = [
aws_default_security_group.default.id,
aws_security_group.femiwiki.id,
aws_security_group.nomad_cluster.id,
]
root_block_device {
delete_on_termination = true
volume_size = 12
volume_type = "gp3"
}
credit_specification {
cpu_credits = "unlimited"
}
tags = {
Name = "Experimetal micro instance for nomad clustrering"
Nomad = "femiwiki"
}
user_data = file("res/bootstrap-consul.sh")
lifecycle {
ignore_changes = [
ami,
user_data,
# https://github.com/femiwiki/infra/issues/88
volume_tags,
]
}
}
resource "aws_instance" "femiwiki_consul_test2" {
ebs_optimized = true
ami = data.aws_ami.amazon_linux_2_arm64.image_id
instance_type = "t4g.micro"
key_name = aws_key_pair.femiwiki.key_name
monitoring = false
iam_instance_profile = aws_iam_instance_profile.femiwiki.name
disable_api_termination = false # during test period
availability_zone = data.aws_availability_zone.femiwiki.name
vpc_security_group_ids = [
aws_default_security_group.default.id,
aws_security_group.femiwiki.id,
aws_security_group.nomad_cluster.id,
]
root_block_device {
delete_on_termination = true
volume_size = 12
volume_type = "gp3"
}
credit_specification {
cpu_credits = "unlimited"
}
tags = {
Name = "Second experimetal micro instance for nomad clustrering"
Nomad = "femiwiki"
}
user_data = file("res/bootstrap-consul.sh")
lifecycle {
ignore_changes = [
ami,
user_data,
# https://github.com/femiwiki/infra/issues/88
volume_tags,
]
}
}