From dfcc9b95183aae4d1fe815559e8df4a70766faef Mon Sep 17 00:00:00 2001 From: Martin Buchleitner Date: Wed, 5 Jun 2024 07:39:18 +0000 Subject: [PATCH] fix: getting dynamic ip from azure requires to fetch it again --- main.tf | 6 ++++++ outputs.tf | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 89be6e839..1d24b8bb4 100644 --- a/main.tf +++ b/main.tf @@ -109,6 +109,12 @@ resource "azurerm_public_ip" "catapp-pip" { domain_name_label = "${var.prefix}-meow" } +data "azurerm_public_ip" "catapp-pip" { + depends_on = [ azurerm_public_ip.catapp-pip ] + name = "${var.prefix}-ip" + resource_group_name = azurerm_resource_group.myresourcegroup.name +} + resource "azurerm_linux_virtual_machine" "catapp" { name = "${var.prefix}-meow" location = azurerm_resource_group.myresourcegroup.location diff --git a/outputs.tf b/outputs.tf index ca2ffb59c..696c26350 100644 --- a/outputs.tf +++ b/outputs.tf @@ -7,5 +7,5 @@ output "catapp_url" { } output "catapp_ip" { - value = "http://${azurerm_public_ip.catapp-pip.ip_address}" + value = "http://${data.azurerm_public_ip.catapp-pip.ip_address}" }