Hi Team,
I am not able to get the Public IP in output when dynamic IP allocation is used with azurerm.
Below is the snippet from template:
# Create public IPs
resource "azurerm_public_ip" "myterraformpublicip" {
name = "myPublicIPTerraform"
location = "westus"
public_ip_address_allocation = "dynamic"
tags {
environment = "myTerraformDemo"
}
}
# Create network interface
resource "azurerm_network_interface" "myterraformnic1" {
name = "myNICTerraform1"
location = "westus"
ip_configuration {
name = "myNICTerraformConfiguration"
private_ip_address_allocation = "dynamic"
}
tags {
environment = "myTerraformDemo"
}
}
# Create virtual machine
resource "azurerm_virtual_machine" "myterraformvm" {
name = "myVMTerraform"
location = "westus"
vm_size = "Standard_DS3"
storage_os_disk {
name = "myOsDisk"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
storage_image_reference {
id="Image reference"
}
os_profile {
computer_name = "myVMTerraform"
admin_username = "azure_devops"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
path = "path to ssh key"
key_data = "ssh key here"
}
}
boot_diagnostics {
enabled = "true"
storage_uri = "${azurerm_storage_account.mystorageaccount.primary_blob_endpoint}"
}
tags {
environment = "myTerraformDemo"
}
}
output "public_ip" {
value = "${azurerm_public_ip.myterraformpublicip.ip_address}"
}
But this gives error as "does not have attribute 'ip_address' for variable".
Can anyone please help here.
Terraform version:
Terraform v0.11.7
+ provider.azurerm v1.5.0
Thanks,
Suraj Muthreja.