-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathterraform-instances.tf
51 lines (37 loc) · 1.53 KB
/
terraform-instances.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
# Terraform Openstack
# Author: Rafael Belchior - [email protected]
# Elemets of the cloud such as virtual servers,
# networks, firewall rules are created as resources
# syntax is: resource RESOURCE_TYPE RESOURCE_NAME
# https://www.terraform.io/docs/configuration/resources.html
# https://www.terraform.io/docs/providers/openstack/
#Creates a keypair to be used on terraform-webserver
#https://www.terraform.io/docs/providers/openstack/r/compute_keypair_v2.html
resource "openstack_compute_keypair_v2" "terraform-key" {
name = "terraform-key-NAME"
public_key = "${file(var.ssh_key_public)}"
}
########### Web Server 1 #############
resource "openstack_compute_instance_v2" "web1" {
name = "web1"
image_name = "Ubuntu-18.04-Latest"
flavor_id = "0"
key_pair = "${openstack_compute_keypair_v2.terraform-key.name}"
security_groups = ["default", "${openstack_compute_secgroup_v2.sec.name}"]
network {
#name = "${openstack_networking_network_v2.frontend_network.name}"
name = "${var.unique_network_name}"
}
}
########### Web Server 2 #############
resource "openstack_compute_instance_v2" "web2" {
name = "web2"
image_name = "Ubuntu-18.04-Latest"
flavor_id = "0"
key_pair = "${openstack_compute_keypair_v2.terraform-key.name}"
security_groups = ["default","${openstack_compute_secgroup_v2.sec.name}"]
network {
#name = "${openstack_networking_network_v2.frontend_network.name}"
name = "${var.unique_network_name}"
}
}