-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.tf
35 lines (32 loc) · 1.07 KB
/
instance.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
resource "openstack_compute_instance_v2" "moninstance" {
name = "demo"
image_name = "${var.image}"
flavor_name = "${var.flavor_http}"
key_pair = "${openstack_compute_keypair_v2.user_key.name}"
user_data = "${file("scripts/webserver.sh")}"
network {
port = openstack_networking_port_v2.moninstance.id
}
}
# Create network port
resource "openstack_networking_port_v2" "moninstance" {
name = "moninstance-port"
network_id = openstack_networking_network_v2.generic.id
admin_state_up = true
security_group_ids = [
openstack_compute_secgroup_v2.ssh.id,
openstack_compute_secgroup_v2.http.id,
]
fixed_ip {
subnet_id = openstack_networking_subnet_v2.subnet.id
}
}
# Create floating ip
resource "openstack_networking_floatingip_v2" "fip_moninstance" {
pool = "${var.external_network_name}"
}
# Attach floating ip to instance
resource "openstack_compute_floatingip_associate_v2" "moninstance" {
floating_ip = openstack_networking_floatingip_v2.fip_moninstance.address
instance_id = openstack_compute_instance_v2.moninstance.id
}