-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-server.tf
107 lines (100 loc) · 3.23 KB
/
main-server.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
resource "ncloud_access_control_group" "develop_bastion_acg" {
name = "${var.zone_name}-${var.terraform_name}-bastion-acg"
vpc_no = ncloud_vpc.develop_vpc.id
}
resource "ncloud_access_control_group_rule" "develop_bastion_acg" {
access_control_group_no = ncloud_access_control_group.develop_bastion_acg.id
inbound {
protocol = "TCP"
ip_block = "0.0.0.0/0"
port_range = "22"
description = "accept 22 port(all ip)"
}
inbound {
protocol = "TCP"
ip_block = "0.0.0.0/0"
port_range = "3000"
description = "accept 3000 port(all ip)"
}
inbound {
protocol = "TCP"
ip_block = "0.0.0.0/0"
port_range = "80"
description = "accept 80 port(all ip)"
}
inbound {
protocol = "TCP"
ip_block = "0.0.0.0/0"
port_range = "443"
description = "accept 443 port(all ip)"
}
inbound {
protocol = "TCP"
ip_block = "0.0.0.0/0"
port_range = "3306"
description = "accept 3306 port(all ip)"
}
inbound {
protocol = "TCP"
ip_block = "0.0.0.0/0"
port_range = "6379"
description = "accept 6379 port(all ip)"
}
inbound {
protocol = "TCP"
ip_block = "0.0.0.0/0"
port_range = "8080"
description = "accept 8080 port(all ip)"
}
inbound {
protocol = "UDP"
ip_block = "0.0.0.0/0"
port_range = "1194"
description = "accept 1194 port(all ip)"
}
outbound {
protocol = "TCP"
ip_block = "0.0.0.0/0"
port_range = "1-65535"
description = "accept TCP 1-65535 port"
}
outbound {
protocol = "UDP"
ip_block = "0.0.0.0/0"
port_range = "1-65535"
description = "accept UDP 1-65535 port"
}
outbound {
protocol = "ICMP"
ip_block = "0.0.0.0/0"
description = "accept ICMP"
}
}
resource "ncloud_network_interface" "develop_bastion_nic" {
name = "${var.terraform_name}-bastion-nic"
subnet_no = ncloud_subnet.develop_net_subnet.id
access_control_groups = [ncloud_access_control_group.develop_bastion_acg.id]
}
resource "ncloud_server" "develop_bastion_server" {
subnet_no = ncloud_subnet.develop_net_subnet.id
name = "${var.zone_name}-${var.terraform_name}-bastion"
server_image_product_code = "SW.VSVR.OS.LNX64.UBNTU.SVR2004.B050"
server_product_code = "SVR.VSVR.STAND.C002.M008.NET.HDD.B050.G002"
login_key_name = ncloud_login_key.develop_key.key_name
network_interface {
network_interface_no = ncloud_network_interface.develop_bastion_nic.id
order = 0
}
}
data "ncloud_root_password" "develop_bastion_root_password" {
server_instance_no = ncloud_server.develop_bastion_server.instance_no
private_key = ncloud_login_key.develop_key.private_key
}
resource "local_file" "develop_bastion_root_password_file" {
filename = "${ncloud_server.develop_bastion_server.name}-root-password.txt"
content = "${ncloud_server.develop_bastion_server.name} => ${data.ncloud_root_password.develop_bastion_root_password.root_password}"
}
resource "ncloud_public_ip" "develop_bastion_ip" {
server_instance_no = ncloud_server.develop_bastion_server.id
description = "for ${ncloud_server.develop_bastion_server.name} public ip"
}