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

provider/azure: Some changes to azurerm_network_interface are ignored #6796

Closed
Bowbaq opened this issue May 20, 2016 · 7 comments
Closed

provider/azure: Some changes to azurerm_network_interface are ignored #6796

Bowbaq opened this issue May 20, 2016 · 7 comments

Comments

@Bowbaq
Copy link
Contributor

Bowbaq commented May 20, 2016

Terraform Version

Terraform v0.7.0-dev (84a0a32b1947f52deeac344ec5e49393e8a432e1)

Affected Resource(s)

  • azurerm_network_interface

Terraform Configuration Files

resource "azurerm_network_interface" "public-slave" {
  name                = "${var.name}-public-slave-${count.index}-nic"
  location            = "${var.location}"
  resource_group_name = "${azurerm_resource_group.dcos.name}"

  ip_configuration {
    name      = "public-slave-${count.index}"
    subnet_id = "${azurerm_subnet.public-slave.id}"

    private_ip_address_allocation = "dynamic"
    load_balancer_backend_address_pools_ids = ["${azurerm_simple_lb.public-slave.backend_pool_id}"]
  }

  count = 2
}

Expected Behavior

Adding the load_balancer_backend_address_pools_ids key should trigger an update or the network interface

Actual Behavior

The change of configuration is not detected by Terraform

Steps to Reproduce

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

  1. Create a network interface, without specifying load_balancer_backend_address_pools_ids
  2. Add a value for load_balancer_backend_address_pools_ids and run terraform plan

References

I believe the problem is the hash function for the sub-resource:

func resourceArmNetworkInterfaceIpConfigurationHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["subnet_id"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["private_ip_address_allocation"].(string)))
return hashcode.String(buf.String())
}

Some of the keys are hashed, but not all of them. I'm not sure why that is. Rewriting it as the following seems to fix the diff problem, but might have undesirable side-effects:

func resourceArmNetworkInterfaceIpConfigurationHash(v interface{}) int {
    var buf bytes.Buffer
    m := v.(map[string]interface{})
    buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
    buf.WriteString(fmt.Sprintf("%s-", m["subnet_id"].(string)))
    buf.WriteString(fmt.Sprintf("%s-", m["private_ip_address"].(string)))
    buf.WriteString(fmt.Sprintf("%s-", m["private_ip_address_allocation"].(string)))
    buf.WriteString(fmt.Sprintf("%s-", m["public_ip_address_id"].(string)))
    buf.WriteString(fmt.Sprintf("%s-", m["load_balancer_backend_address_pools_ids"].(*schema.Set).GoString()))
    buf.WriteString(fmt.Sprintf("%s-", m["load_balancer_inbound_nat_rules_ids"].(*schema.Set).GoString()))

    return hashcode.String(buf.String())
}
@stack72
Copy link
Contributor

stack72 commented May 20, 2016

Hi @Bowbaq

I have already submitted 1 update to this today :) #6790

This will help the majority of TF users right now. I haven't included the load_balancer as TF doesn't manage those yet

P.

@Bowbaq
Copy link
Contributor Author

Bowbaq commented May 20, 2016

Even if it's not currently managed by TF, I think it should be included. It could be passed in as a variable, or be provisioned through the CLI with local-exec. In my case, I've merged in #6429 (although that doesn't seem to be quite working)

@stack72
Copy link
Contributor

stack72 commented May 20, 2016

Hi @Bowbaq

I will try and get this updated now to work with the load balancer stuff. I don't have any load balancers to test this with though (thus why i left it out of this update)

P.

@enieuw
Copy link
Contributor

enieuw commented May 24, 2016

I use the following diff in combination with #6429 and #6467

diff --git a/builtin/providers/azurerm/resource_arm_network_interface_card.go b/builtin/providers/azurerm/resource_arm_network_interface_card.go
index 174afc5..a165051 100644
--- a/builtin/providers/azurerm/resource_arm_network_interface_card.go
+++ b/builtin/providers/azurerm/resource_arm_network_interface_card.go
@@ -345,6 +345,11 @@ func resourceArmNetworkInterfaceIpConfigurationHash(v interface{}) int {
        buf.WriteString(fmt.Sprintf("%s-", m["public_ip_address_id"].(string)))
    }

+   pools := m["load_balancer_backend_address_pools_ids"].(*schema.Set).List()
+   for _, p := range pools {
+       buf.WriteString(fmt.Sprintf("%s-", p.(string)))
+   }
+
    return hashcode.String(buf.String())
 }

Perhaps this could be included in one of the open load balancer pull requests as it's not really needed without the load balancer functionality.

@pmcatominey
Copy link
Contributor

@Bowbaq those properties are written to the hash now if present, should resolve your issue :).

@stack72
Copy link
Contributor

stack72 commented Nov 28, 2016

Closed via #6429

@stack72 stack72 closed this as completed Nov 28, 2016
@ghost
Copy link

ghost commented Apr 19, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 19, 2020
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

4 participants