Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_public_ip doesn't change from dynamic to static #1234

Closed
ghost opened this issue May 14, 2018 · 4 comments · Fixed by #1247
Closed

azurerm_public_ip doesn't change from dynamic to static #1234

ghost opened this issue May 14, 2018 · 4 comments · Fixed by #1247

Comments

@ghost
Copy link

ghost commented May 14, 2018

This issue was originally opened by @bernadinm as hashicorp/terraform#18045. It was migrated here as a result of the provider split. The original body of the issue is below.


When changing the azurerm_public_ip's public_ip_address_allocation from dynamic to static it fails to return a new IP.

Terraform Version

$ terraform -v
Terraform v0.11.7
+ provider.azurerm v1.4.0

Terraform Configuration Files

variable "azure_region" {
default = "West US"
}

resource "azurerm_public_ip" "frontend" {
  name                         = "frontend"
  location                     = "${var.azure_region}"
  resource_group_name          = "${azurerm_resource_group.testing.name}"
  public_ip_address_allocation = "dynamic"
}
output "voyager.default_ingress.ip" {
    value = "${azurerm_public_ip.frontend.ip_address}"
}

# Create a resource group
resource "azurerm_resource_group" "testing" {
  name     = "testing123"
  location = "${var.azure_region}"
}

Debug Output

Error: Error running plan: 1 error(s) occurred:

  • output.voyager.default_ingress.ip: Resource 'azurerm_public_ip.frontend' does not have attribute 'ip_address' for variable 'azurerm_public_ip.frontend.ip_address'

Expected Behavior

An IP address should be returned after switching public_ip_address_allocation from dynamic to static.

Actual Behavior

It fails.

Steps to Reproduce

Please list the full steps required to reproduce the issue, for example:

  1. terraform init
  2. terraform apply
  3. Observe failure
  4. Change public_ip_address_allocation from dynamic to static
  5. terraform apply
  6. Observe failure as new IP address is not defined.
@katbyte
Copy link
Collaborator

katbyte commented May 16, 2018

Hello @bernadinm,

As per the documentation , dynamic Public IP Addresses aren't allocated until they're attached to a device. The property should just be empty but due to an oversight it wasn't being set to anything so I've opened a PR to fix this in 1.6.0 onwards.

Thank you for opening this issue 🙂

@bernadinm
Copy link

Hi @katbyte, thanks for replying. I am aware that the it doesn't assign the IP address when it is set to dymanic. The issue here is when you set it from dynamic to static where it will provide an IP address even when a resource is not attached to it.

The work around here is that the user will first need to destroy the resources entirely first, change from dynamic to static, then perform a terraform apply. However this is an anti-pattern to terraform design if a manual destroy is required.

@katbyte
Copy link
Collaborator

katbyte commented May 25, 2018

Hey @bernadinm,

Just wanted to let you know we have released v1.6.0 of the provider hopefully fixing this issue 🙂

@ghost
Copy link
Author

ghost commented Mar 31, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants