forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
79 lines (72 loc) · 2.04 KB
/
Copy pathmain.tf
File metadata and controls
79 lines (72 loc) · 2.04 KB
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
resource "openstack_compute_keypair_v2" "terraform" {
name = "terraform"
public_key = "${file("${var.ssh_key_file}.pub")}"
}
resource "openstack_networking_network_v2" "terraform" {
name = "terraform"
admin_state_up = "true"
}
resource "openstack_networking_subnet_v2" "terraform" {
name = "terraform"
network_id = "${openstack_networking_network_v2.terraform.id}"
cidr = "10.0.0.0/24"
ip_version = 4
dns_nameservers = ["8.8.8.8","8.8.4.4"]
}
resource "openstack_networking_router_v2" "terraform" {
name = "terraform"
admin_state_up = "true"
external_gateway = "${var.external_gateway}"
}
resource "openstack_networking_router_interface_v2" "terraform" {
router_id = "${openstack_networking_router_v2.terraform.id}"
subnet_id = "${openstack_networking_subnet_v2.terraform.id}"
}
resource "openstack_compute_secgroup_v2" "terraform" {
name = "terraform"
description = "Security group for the Terraform example instances"
rule {
from_port = 22
to_port = 22
ip_protocol = "tcp"
cidr = "0.0.0.0/0"
}
rule {
from_port = 80
to_port = 80
ip_protocol = "tcp"
cidr = "0.0.0.0/0"
}
rule {
from_port = -1
to_port = -1
ip_protocol = "icmp"
cidr = "0.0.0.0/0"
}
}
resource "openstack_compute_floatingip_v2" "terraform" {
pool = "${var.pool}"
depends_on = ["openstack_networking_router_interface_v2.terraform"]
}
resource "openstack_compute_instance_v2" "terraform" {
name = "terraform"
image_name = "${var.image}"
flavor_name = "${var.flavor}"
key_pair = "${openstack_compute_keypair_v2.terraform.name}"
security_groups = [ "${openstack_compute_secgroup_v2.terraform.name}" ]
floating_ip = "${openstack_compute_floatingip_v2.terraform.address}"
network {
uuid = "${openstack_networking_network_v2.terraform.id}"
}
provisioner "remote-exec" {
connection {
user = "${var.ssh_user_name}"
key_file = "${var.ssh_key_file}"
}
inline = [
"sudo apt-get -y update",
"sudo apt-get -y install nginx",
"sudo service nginx start"
]
}
}