From ae81f5371ff5b31bf4e485e4d31f8f8d6442ce15 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Wed, 5 Jul 2023 16:56:19 +0100 Subject: [PATCH] Add fip and security groups to instance --- openstack/init/05-instance.tf | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openstack/init/05-instance.tf b/openstack/init/05-instance.tf index 38b2ac6..a66bd86 100644 --- a/openstack/init/05-instance.tf +++ b/openstack/init/05-instance.tf @@ -6,7 +6,11 @@ resource "openstack_compute_instance_v2" "test_server_01" { name = "test_server_01" flavor_id = data.openstack_compute_flavor_v2.m1_small.id key_pair = openstack_compute_keypair_v2.arif-key.name - security_groups = ["default"] + security_groups = [ + "default", + openstack_compute_secgroup_v2.allow_ssh.name, + openstack_compute_secgroup_v2.allow_ping.name, + ] block_device { uuid = openstack_images_image_v2.bionic-raw.id @@ -22,3 +26,12 @@ resource "openstack_compute_instance_v2" "test_server_01" { } } +resource "openstack_networking_floatingip_v2" "fip" { + pool = "ext_net" +} + +resource "openstack_compute_floatingip_associate_v2" "fip" { + floating_ip = openstack_networking_floatingip_v2.fip.address + instance_id = openstack_compute_instance_v2.test_server_01.id +} +