Skip to content

Commit

Permalink
Upgrade examples to work with terraform 12
Browse files Browse the repository at this point in the history
  • Loading branch information
Renat Nurgaliyev committed Jul 31, 2019
1 parent 00c6107 commit f1d74c2
Show file tree
Hide file tree
Showing 32 changed files with 261 additions and 195 deletions.
18 changes: 9 additions & 9 deletions DNSaaS/main.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
resource "openstack_dns_zone_v2" "example_zone" {
name = "example.com."
email = "email2@example.com"
name = "example.com."
email = "email2@example.com"
description = "a zone"
ttl = 6000
type = "PRIMARY"
ttl = 6000
type = "PRIMARY"
}

resource "openstack_dns_recordset_v2" "rs_example_com" {
zone_id = "${openstack_dns_zone_v2.example_zone.id}"
name = "rs.example.com."
zone_id = openstack_dns_zone_v2.example_zone.id
name = "rs.example.com."
description = "An example record set"
ttl = 3000
type = "A"
records = ["10.0.0.1"]
ttl = 3000
type = "A"
records = ["10.0.0.1"]
}

4 changes: 4 additions & 0 deletions DNSaaS/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}
10 changes: 6 additions & 4 deletions FWaaS/fw.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ resource "openstack_fw_rule_v1" "rule_2" {
resource "openstack_fw_policy_v1" "policy_1" {
name = "my-policy"

rules = ["${openstack_fw_rule_v1.rule_1.id}",
"${openstack_fw_rule_v1.rule_2.id}",
rules = [
openstack_fw_rule_v1.rule_1.id,
openstack_fw_rule_v1.rule_2.id,
]
}

resource "openstack_fw_firewall_v1" "firewall_1" {
name = "my-firewall"
policy_id = "${openstack_fw_policy_v1.policy_1.id}"
associated_routers = ["${openstack_networking_router_v2.router.id}"]
policy_id = openstack_fw_policy_v1.policy_1.id
associated_routers = [openstack_networking_router_v2.router.id]
}

29 changes: 14 additions & 15 deletions FWaaS/instaces.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ data "openstack_images_image_v2" "image" {

resource "openstack_compute_instance_v2" "instance_red" {
name = "RED Instance"
image_id = "${data.openstack_images_image_v2.image.id}"
image_id = data.openstack_images_image_v2.image.id
flavor_name = "m1.micro"
key_pair = "${openstack_compute_keypair_v2.kp_adminuser.name}"
security_groups = ["${openstack_compute_secgroup_v2.sg_ssh.name}"]
key_pair = openstack_compute_keypair_v2.kp_adminuser.name
security_groups = [openstack_compute_secgroup_v2.sg_ssh.name]

network {
name = "${openstack_networking_network_v2.net_red.name}"
name = openstack_networking_network_v2.net_red.name
}
}

Expand All @@ -24,25 +24,23 @@ resource "openstack_compute_floatingip_v2" "fip_red" {
}

resource "openstack_compute_floatingip_associate_v2" "fipas_red" {
floating_ip = "${openstack_compute_floatingip_v2.fip_red.address}"
instance_id = "${openstack_compute_instance_v2.instance_red.id}"
floating_ip = openstack_compute_floatingip_v2.fip_red.address
instance_id = openstack_compute_instance_v2.instance_red.id
}

resource "openstack_compute_instance_v2" "instance_blue" {
name = "BLUE Instance"
image_id = "${data.openstack_images_image_v2.image.id}"
image_id = data.openstack_images_image_v2.image.id
flavor_name = "m1.micro"
key_pair = "${openstack_compute_keypair_v2.kp_adminuser.name}"
security_groups = ["${openstack_compute_secgroup_v2.sg_ssh.name}"]
key_pair = openstack_compute_keypair_v2.kp_adminuser.name
security_groups = [openstack_compute_secgroup_v2.sg_ssh.name]

network {
name = "${openstack_networking_network_v2.net_blue.name}"
name = openstack_networking_network_v2.net_blue.name
}

lifecycle {
ignore_changes = [
"image_id",
]
ignore_changes = [image_id]
}
}

Expand All @@ -51,6 +49,7 @@ resource "openstack_compute_floatingip_v2" "fip_blue" {
}

resource "openstack_compute_floatingip_associate_v2" "fipas_blue" {
floating_ip = "${openstack_compute_floatingip_v2.fip_blue.address}"
instance_id = "${openstack_compute_instance_v2.instance_blue.id}"
floating_ip = openstack_compute_floatingip_v2.fip_blue.address
instance_id = openstack_compute_instance_v2.instance_blue.id
}

17 changes: 9 additions & 8 deletions FWaaS/networks.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "openstack_networking_network_v2" "ext-net" {
name = "${var.external_network}"
name = var.external_network
}

resource "openstack_networking_network_v2" "net_red" {
Expand All @@ -14,15 +14,15 @@ resource "openstack_networking_network_v2" "net_blue" {

resource "openstack_networking_subnet_v2" "subnet_red" {
name = "subnet_red"
network_id = "${openstack_networking_network_v2.net_red.id}"
network_id = openstack_networking_network_v2.net_red.id
dns_nameservers = ["8.8.8.8", "8.8.4.4"]
cidr = "192.168.1.0/24"
ip_version = 4
}

resource "openstack_networking_subnet_v2" "subnet_blue" {
name = "subnet_blue"
network_id = "${openstack_networking_network_v2.net_blue.id}"
network_id = openstack_networking_network_v2.net_blue.id
dns_nameservers = ["8.8.8.8", "8.8.4.4"]
cidr = "192.168.2.0/24"
ip_version = 4
Expand All @@ -31,15 +31,16 @@ resource "openstack_networking_subnet_v2" "subnet_blue" {
resource "openstack_networking_router_v2" "router" {
name = "router"
admin_state_up = true
external_network_id = "${data.openstack_networking_network_v2.ext-net.id}"
external_network_id = data.openstack_networking_network_v2.ext-net.id
}

resource "openstack_networking_router_interface_v2" "routerint_red" {
router_id = "${openstack_networking_router_v2.router.id}"
subnet_id = "${openstack_networking_subnet_v2.subnet_red.id}"
router_id = openstack_networking_router_v2.router.id
subnet_id = openstack_networking_subnet_v2.subnet_red.id
}

resource "openstack_networking_router_interface_v2" "routerint_blue" {
router_id = "${openstack_networking_router_v2.router.id}"
subnet_id = "${openstack_networking_subnet_v2.subnet_blue.id}"
router_id = openstack_networking_router_v2.router.id
subnet_id = openstack_networking_subnet_v2.subnet_blue.id
}

1 change: 1 addition & 0 deletions FWaaS/security-groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ resource "openstack_compute_secgroup_v2" "sg_ssh" {
cidr = "0.0.0.0/0"
}
}

3 changes: 2 additions & 1 deletion FWaaS/ssh-keys.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resource "openstack_compute_keypair_v2" "kp_adminuser" {
name = "kp_adminuser"
public_key = "${var.ssh_publickey}"
public_key = var.ssh_publickey
}

5 changes: 3 additions & 2 deletions FWaaS/vars.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
variable "external_network" {
type = "string"
type = string
description = "external network name"
default = "ext-net"
}

variable "ssh_publickey" {
type = "string"
type = string
description = "ssh-rsa public key in authorized_keys format (ssh-rsa AAAAB3Nz [...] ABAAACAC62Lw== user@host)"
}

4 changes: 4 additions & 0 deletions FWaaS/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}
Loading

0 comments on commit f1d74c2

Please sign in to comment.