# Define required providers terraform { required_version = ">= 0.14.0" required_providers { openstack = { source = "terraform-provider-openstack/openstack" version = "~> 1.53.0" } } } data "terraform_remote_state" "privnet_dns_router" { backend = "local" config = { path = "../main_net_dns_router/terraform.tfstate" } } module "ssh_settings" { source = "../../modules/ssh-key-ref" } # # Uses common_variables as module # module "common_variables" { source = "../../modules/labs_common_variables" } resource "openstack_compute_instance_v2" "wp_ecir2025" { name = "wp-ecir2025" availability_zone_hints = module.common_variables.availability_zone_no_gpu_name flavor_name = module.common_variables.flavor_list.m1_medium key_pair = module.ssh_settings.ssh_key_name security_groups = [data.terraform_remote_state.privnet_dns_router.outputs.default_security_group_name] block_device { uuid = module.common_variables.ubuntu_2204.uuid source_type = "image" volume_size = 30 boot_index = 0 destination_type = "volume" delete_on_termination = false } network { name = data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.name } user_data = file("${data.terraform_remote_state.privnet_dns_router.outputs.ubuntu2204_data_file}") # Do not replace the instance when the ssh key changes lifecycle { ignore_changes = [ # Ignore changes to tags, e.g. because a management agent # updates these based on some ruleset managed elsewhere. key_pair, user_data, network ] } } # Allocate and associate a floating IP address # resource "openstack_networking_floatingip_v2" "wp_ecir2025_ip" { pool = module.common_variables.floating_ip_pools.main_public_ip_pool # The DNS association does not work because of a bug in the OpenStack API description = "Wordpress for the ecir2025 conference" } resource "openstack_compute_floatingip_associate_v2" "wp_ecir2025" { floating_ip = openstack_networking_floatingip_v2.wp_ecir2025_ip.address instance_id = openstack_compute_instance_v2.wp_ecir2025.id } # # Add a DNS record to the floating IP address # module "dns_records_create" { source = "../../modules/dns_resources" dns_resources_map = { dm-pool-manager-pre = { zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id name = join(".", ["wp-ecir2025", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.name]) description = "Wordpress for the ecir2025 conference" ttl = 8600 type = "A" records = [openstack_networking_floatingip_v2.wp_ecir2025_ip.address] } } }