forked from RackWare-Inc/Rackware-Golden-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rmm-non-byol-main.tf
82 lines (69 loc) · 1.92 KB
/
rmm-non-byol-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
data "ibm_is_vpc" "vpc" {
name = var.vpc_name
}
data "ibm_resource_group" "rg" {
name = var.resource_group
}
data "ibm_is_subnet" "subnet" {
name = var.subnet_name
}
data "ibm_is_ssh_key" "ssh_key_id" {
name = var.ssh_key
}
resource "ibm_is_security_group" "sg" {
name = "${var.host_name}-sg"
vpc = data.ibm_is_vpc.vpc.id
resource_group = data.ibm_resource_group.rg.id
}
resource "ibm_is_security_group_rule" "inbound_tcp_port_22" {
group = ibm_is_security_group.sg.id
direction = "inbound"
remote = "0.0.0.0/0"
tcp {
port_min = 22
port_max = 22
}
}
resource "ibm_is_security_group_rule" "inbound_tcp_port_443" {
group = ibm_is_security_group.sg.id
direction = "inbound"
remote = "0.0.0.0/0"
tcp {
port_min = 443
port_max = 443
}
}
resource "ibm_is_security_group_rule" "outbound_all" {
group = ibm_is_security_group.sg.id
direction = "outbound"
remote = "0.0.0.0/0"
}
resource "ibm_is_image" "custom_image" {
name = "${var.host_name}-cent-os-7"
href = var.image_url
operating_system = "centos-7-amd64"
resource_group = data.ibm_resource_group.rg.id
timeouts {
create = "90m"
delete = "90m"
}
}
resource "ibm_is_instance" "vsi" {
name = "${var.host_name}"
vpc = data.ibm_is_vpc.vpc.id
zone = var.zone
keys = [data.ibm_is_ssh_key.ssh_key_id.id]
resource_group = data.ibm_resource_group.rg.id
image = ibm_is_image.custom_image.id
profile = var.profile
primary_network_interface {
subnet = data.ibm_is_subnet.subnet.id
security_groups = [ibm_is_security_group.sg.id]
}
}
resource "ibm_is_floating_ip" "fip" {
count = var.attach_floating_ip ? 1 : 0
name = "${var.host_name}-fip"
target = ibm_is_instance.vsi.primary_network_interface[0].id
resource_group = data.ibm_resource_group.rg.id
}