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_route_table with azurerm_route flipping resources #447

Closed
thiagocaiubi opened this issue Oct 20, 2017 · 10 comments
Closed

azurerm_route_table with azurerm_route flipping resources #447

thiagocaiubi opened this issue Oct 20, 2017 · 10 comments
Assignees

Comments

@thiagocaiubi
Copy link
Contributor

thiagocaiubi commented Oct 20, 2017

Terraform Version

0.10.7

AzureRM Provider Version

0.3.0

Affected Resource(s)

Please list the resources as a list, for example:

  • azurerm_route_table
  • azurerm_route

Terraform Configuration Files

resource "azurerm_resource_group" "test" {
  name     = "acceptanceTestResourceGroup1"
  location = "West US"
}

resource "azurerm_route_table" "test" {
  name                = "acceptanceTestRouteTable1"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"
}

resource "azurerm_route" "test" {
  name                = "acceptanceTestRoute1"
  resource_group_name = "${azurerm_resource_group.test.name}"
  route_table_name    = "${azurerm_route_table.test.name}"
  address_prefix      = "10.1.0.0/16"
  next_hop_type       = "vnetlocal"
}

Debug Output

https://gist.github.com/thiagocaiubi/1c39ca2a9e40f866cc8ae3473b273cf1

Expected Behavior

First terraform apply must create the infrastructure.
Second terraform apply must do nothing.

Actual Behavior

Subsequent terraform apply are creating/destroying the resources.

Steps to Reproduce

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

  1. terraform init
  2. terraform apply
  3. terraform apply

References

I guess is something related to the refactoring from Set to List.
Pretty sure that I'm facing the same issue with azurerm_network_security_group and azurerm_network_security_rule.

@thiagocaiubi
Copy link
Contributor Author

I've tested the same HCL against terraform v0.10.7 and azurerm provider v0.2.2 and get the expected behavior successfully.

Debug output: https://gist.github.com/thiagocaiubi/4030764cf958207a125c28e9e856253e

@fstuck37
Copy link

I appear to have this issue as well.
I'm adding a default route via azurerm_route and when I do a subsequent plan it wants to delete it from the azurerm_route_table. If I apply, allow it to remove it, and than plan again; it wants to add it based on azurerm_route. So it is flipping the route between the azurerm_route and azurerm_route_table.

~ module.vnet.azurerm_route_table.privrt
route.#: "1" => "0"
route.0.address_prefix: "0.0.0.0/0" => ""
route.0.name: "DefaultGateway" => ""
route.0.next_hop_type: "VirtualAppliance" => ""

I'm using 0.10.7 as well and Azure provider 0.3.1.
(terraform-provider-azurerm_v0.3.1_x4.exe)
I didn't have this issue with a previous version v0.1.7.
(terraform-provider-azurerm_v0.1.7_x4.exe)

Still reviewing to see if I can work around it and will provide additional information if I find any.

Thanks,
Fred

@VaijanathB
Copy link
Contributor

Hello @thiagocaiubi ,

Since you have already confirmed that this is no longer an issue, can you please go ahead and close this.

Thanks,
VJ

@fstuck37
Copy link

VJ,
I still have this issue. I think thiagocaiubi was saying that this issue didn't exist in an older version (Terraform v0.10.7 and azurerm provider v0.2.2) and for me, I didn't have this issue with Azure version v0.1.7.

Seems like this issue was introduced between v0.2.2 and v0.3.0.
(v0.2.2 < v?.?.? <= v0.3.0)

Hope this helps

Thanks,
Fred

@thiagocaiubi
Copy link
Contributor Author

Thanks, @fstuck37. That's it!

@VaijanathB
Copy link
Contributor

Hello @thiagocaiubi , @fstuck37 ,

Thanks for the clarification. I tried the above repro provided by @thiagocaiubi , with Terraform version 0.10.9 and Azure provider version 0.3.2 and could not reproduce it.
When I perform, tf apply multiple times I get the following output.
tf apply
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
tf apply
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

If this is still an issue with latest version of Terraform and provider, can you provide with me updated repro steps ?

Thanks,
VJ

@fstuck37
Copy link

fstuck37 commented Nov 2, 2017

@VaijanathB - seems like v0.3.2 fixes the issue. Not sure what caused it but looks better now.
Thanks,
Fred

@thiagocaiubi
Copy link
Contributor Author

thiagocaiubi commented Nov 3, 2017

Hi @VaijanathB .

I've tested with terraform v0.10.8 and azurerm provider v0.3.2 and it worked as expected. I will now close the issue. Thanks!

PS: You mentioned terraform v0.10.9, I'm afraid it doesn't exists.
https://github.com/hashicorp/terraform/blob/f25d08061d8c68a5e205f0e82b8bab8c30afc63f/CHANGELOG.md

@clarkcode
Copy link
Contributor

@thiagocaiubi
Seeing the same issue:
Terraform v0.12.0
azurerm v1.30

  • First-time plan + apply works as expected.
  • Second plan sets the azurerm_route.example-route for destroy.

Example:

resource "azurerm_resource_group" "example-rsg" {
    name     = "example-rsg"
    location = "uksouth"
}

resource "azurerm_virtual_network" "example-vnet" {
    name                = "example-vnet"
    location            = "uksouth"
    resource_group_name = "example-rsg"
    address_space       = ["10.0.0.0/24"]
}

resource "azurerm_subnet" "example-subnet" {
    name                        = "example-subnet"
    resource_group_name         = "example-rsg"
    virtual_network_name        = "${azurerm_virtual_network.example-vnet.name}"
    address_prefix              = "10.0.0.0/24"
    route_table_id              = "${azurerm_route_table.example-udr.id}"
    lifecycle { 
        ignore_changes = ["route_table_id"]
    }
}

resource "azurerm_route_table" "example-udr" {
    name                = "example-udr"
    location            = "uksouth"
    resource_group_name = "example-rsg"
    route {
        name           = "default-route"
        address_prefix = "0.0.0.0/0"
        next_hop_type  = "Internet"
    }
}

resource "azurerm_subnet_route_table_association" "perimeter-subnet-association" {
  subnet_id                 = "${azurerm_subnet.example-subnet.id}"
  route_table_id            = "${azurerm_route_table.example-udr.id}"
}

resource "azurerm_route" "example-route" {
    name                    = "example-route"
    resource_group_name     = "example-rsg"
    route_table_name        = "${azurerm_route_table.example-udr.name}"
    address_prefix          = "192.168.0.0/24"
    next_hop_type           = "VirtualAppliance"
    next_hop_in_ip_address  = "10.0.0.1"
}

@ghost
Copy link

ghost commented Jun 17, 2019

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 Jun 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants