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 can not use Count attribute correctly #6516

Closed
clintonm9 opened this issue May 6, 2016 · 8 comments
Closed

azurerm can not use Count attribute correctly #6516

clintonm9 opened this issue May 6, 2016 · 8 comments

Comments

@clintonm9
Copy link

When using the asurerm provider and a count attribute, I can get the initial vm's up and running. When I adjust the count up it tries and change some of the already running vm's.

Config:
https://gist.github.com/clintonm9/b568686fc25456250d5a206e4017e26a

Changing the count from 2 to 3 then running a plan:

~ azurerm_virtual_machine.test.0
    network_interface_ids.#: "" => "<computed>"

~ azurerm_virtual_machine.test.1
    network_interface_ids.#: "" => "<computed>"

If I try and apply I get the following error:
https://gist.github.com/clintonm9/c222763a91be6aca7be57478b9f8e8a0

@stack72
Copy link
Contributor

stack72 commented Jun 2, 2016

Hi @clintonm9

Just a FYI, I am looking at this issue right now

Paul

@stack72 stack72 self-assigned this Jun 2, 2016
@stack72
Copy link
Contributor

stack72 commented Jun 17, 2016

Hi @clintonm9

So I have been speaking to @jen20 about this issue. He has said that it is fixed in master. I will see if he can comment here with some answers on how it was fixed :)

Paul

@stack72
Copy link
Contributor

stack72 commented Jun 17, 2016

Using Terraform master, I was able to create everything with a count of 2

Apply complete! Resources: 11 added, 0 changed, 0 destroyed.

When i increase the count to 3, the plan looks as follows:

~ azurerm_network_interface.test.0
    ip_configuration.1831732895.name:                                      "countconfiguration10" => ""
    ip_configuration.1831732895.private_ip_address_allocation:             "Dynamic" => ""
    ip_configuration.1831732895.subnet_id:                                 "/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet" => ""
    ip_configuration.~618711663.load_balancer_backend_address_pools_ids.#: "" => "<computed>"
    ip_configuration.~618711663.load_balancer_inbound_nat_rules_ids.#:     "" => "<computed>"
    ip_configuration.~618711663.name:                                      "" => "countconfiguration10"
    ip_configuration.~618711663.private_ip_address:                        "" => "<computed>"
    ip_configuration.~618711663.private_ip_address_allocation:             "" => "Dynamic"
    ip_configuration.~618711663.public_ip_address_id:                      "" => "${element(azurerm_public_ip.vm.*.id, count.index)}"
    ip_configuration.~618711663.subnet_id:                                 "" => "/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet"

~ azurerm_network_interface.test.1
    ip_configuration.2120921122.name:                                       "countconfiguration11" => ""
    ip_configuration.2120921122.private_ip_address_allocation:              "Dynamic" => ""
    ip_configuration.2120921122.subnet_id:                                  "/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet" => ""
    ip_configuration.~3339469544.load_balancer_backend_address_pools_ids.#: "" => "<computed>"
    ip_configuration.~3339469544.load_balancer_inbound_nat_rules_ids.#:     "" => "<computed>"
    ip_configuration.~3339469544.name:                                      "" => "countconfiguration11"
    ip_configuration.~3339469544.private_ip_address:                        "" => "<computed>"
    ip_configuration.~3339469544.private_ip_address_allocation:             "" => "Dynamic"
    ip_configuration.~3339469544.public_ip_address_id:                      "" => "${element(azurerm_public_ip.vm.*.id, count.index)}"
    ip_configuration.~3339469544.subnet_id:                                 "" => "/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet"

+ azurerm_network_interface.test.2
    applied_dns_servers.#:                                                 "<computed>"
    dns_servers.#:                                                         "<computed>"
    enable_ip_forwarding:                                                  "false"
    internal_dns_name_label:                                               "<computed>"
    internal_fqdn:                                                         "<computed>"
    ip_configuration.#:                                                    "1"
    ip_configuration.~944299296.load_balancer_backend_address_pools_ids.#: "<computed>"
    ip_configuration.~944299296.load_balancer_inbound_nat_rules_ids.#:     "<computed>"
    ip_configuration.~944299296.name:                                      "countconfiguration12"
    ip_configuration.~944299296.private_ip_address:                        "<computed>"
    ip_configuration.~944299296.private_ip_address_allocation:             "Dynamic"
    ip_configuration.~944299296.public_ip_address_id:                      "${element(azurerm_public_ip.vm.*.id, count.index)}"
    ip_configuration.~944299296.subnet_id:                                 "/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet"
    location:                                                              "westus"
    mac_address:                                                           "<computed>"
    name:                                                                  "countnic2"
    network_security_group_id:                                             "<computed>"
    private_ip_address:                                                    "<computed>"
    resource_group_name:                                                   "tf-6516"
    virtual_machine_id:                                                    "<computed>"

+ azurerm_public_ip.vm.2
    fqdn:                         "<computed>"
    ip_address:                   "<computed>"
    location:                     "westus"
    name:                         "countip2"
    public_ip_address_allocation: "static"
    resource_group_name:          "tf-6516"

~ azurerm_virtual_machine.test.0
    network_interface_ids.#: "" => "<computed>"

~ azurerm_virtual_machine.test.1
    network_interface_ids.#: "" => "<computed>"

+ azurerm_virtual_machine.test.2
    availability_set_id:                                                "<computed>"
    license_type:                                                       "<computed>"
    location:                                                           "westus"
    name:                                                               "countvm2"
    network_interface_ids.#:                                            "<computed>"
    os_profile.#:                                                       "1"
    os_profile.1286505492.admin_password:                               "Password4321"
    os_profile.1286505492.admin_username:                               "testadmin"
    os_profile.1286505492.computer_name:                                "hostname2"
    os_profile.1286505492.custom_data:                                  "<computed>"
    os_profile_linux_config.#:                                          "1"
    os_profile_linux_config.2972667452.disable_password_authentication: "false"
    os_profile_linux_config.2972667452.ssh_keys.#:                      "0"
    plan.#:                                                             "<computed>"
    resource_group_name:                                                "tf-6516"
    storage_image_reference.#:                                          "1"
    storage_image_reference.1807630748.offer:                           "UbuntuServer"
    storage_image_reference.1807630748.publisher:                       "Canonical"
    storage_image_reference.1807630748.sku:                             "14.04.2-LTS"
    storage_image_reference.1807630748.version:                         "latest"
    storage_os_disk.#:                                                  "1"
    storage_os_disk.4080382276.caching:                                 "ReadWrite"
    storage_os_disk.4080382276.create_option:                           "FromImage"
    storage_os_disk.4080382276.image_uri:                               ""
    storage_os_disk.4080382276.name:                                    "myosdisk2"
    storage_os_disk.4080382276.os_type:                                 ""
    storage_os_disk.4080382276.vhd_uri:                                 "https://countsatest1.blob.core.windows.net/countsc/myosdisk2.vhd"
    vm_size:                                                            "Standard_A0"


Plan: 3 to add, 4 to change, 0 to destroy.

the apply throws the error:

Error applying plan:

2 error(s) occurred:

* azurerm_network_interface.test.0: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.

Please include the following information in your report:

    Terraform Version: 0.7.0
    Resource ID: azurerm_network_interface.test.0
    Mismatch reason: attribute mismatch: ip_configuration.~618711663.name
    Diff One (usually from plan): *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"ip_configuration.1831732895.name":*terraform.ResourceAttrDiff{Old:"countconfiguration10", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~618711663.public_ip_address_id":*terraform.ResourceAttrDiff{Old:"", New:"${element(azurerm_public_ip.vm.*.id, count.index)}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~618711663.load_balancer_backend_address_pools_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~618711663.private_ip_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~618711663.load_balancer_inbound_nat_rules_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~618711663.name":*terraform.ResourceAttrDiff{Old:"", New:"countconfiguration10", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1831732895.subnet_id":*terraform.ResourceAttrDiff{Old:"/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1831732895.private_ip_address_allocation":*terraform.ResourceAttrDiff{Old:"Dynamic", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~618711663.subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~618711663.private_ip_address_allocation":*terraform.ResourceAttrDiff{Old:"", New:"Dynamic", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyTainted:false}
    Diff Two (usually from apply): *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff(nil), Destroy:false, DestroyTainted:false}

Also include as much context as you can about your config, state, and the steps you performed to trigger this error.

* azurerm_network_interface.test.1: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.

Please include the following information in your report:

    Terraform Version: 0.7.0
    Resource ID: azurerm_network_interface.test.1
    Mismatch reason: attribute mismatch: ip_configuration.~3339469544.name
    Diff One (usually from plan): *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"ip_configuration.~3339469544.subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.2120921122.private_ip_address_allocation":*terraform.ResourceAttrDiff{Old:"Dynamic", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~3339469544.private_ip_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~3339469544.private_ip_address_allocation":*terraform.ResourceAttrDiff{Old:"", New:"Dynamic", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~3339469544.public_ip_address_id":*terraform.ResourceAttrDiff{Old:"", New:"${element(azurerm_public_ip.vm.*.id, count.index)}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.2120921122.name":*terraform.ResourceAttrDiff{Old:"countconfiguration11", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~3339469544.name":*terraform.ResourceAttrDiff{Old:"", New:"countconfiguration11", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.2120921122.subnet_id":*terraform.ResourceAttrDiff{Old:"/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourceGroups/tf-6516/providers/Microsoft.Network/virtualNetworks/countvnet/subnets/countsubnet", New:"", NewComputed:false, NewRemoved:true, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~3339469544.load_balancer_backend_address_pools_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.~3339469544.load_balancer_inbound_nat_rules_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyTainted:false}
    Diff Two (usually from apply): *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff(nil), Destroy:false, DestroyTainted:false}

Also include as much context as you can about your config, state, and the steps you performed to trigger this error.


Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

So looks like this is still not fixed. Will follow up with @jen20 again

@jen20
Copy link
Contributor

jen20 commented Jun 17, 2016

OK this looks like a different problem to the one I was expecting. We will investigate.

@stack72 stack72 removed their assignment Aug 14, 2016
@StephenWeatherford
Copy link
Contributor

@clintonm9 Do you still see this error? Everything seems to be working fine for me. I was able to change count from 1 to 2 to 1 without problems. Thx.

@clintonm9
Copy link
Author

It looks like now when I run an apply and then a plan afterward, it does not try and change the current vms.

Once I change the count from 3 to 4 I get the following change (this is brief):

~ azurerm_virtual_machine.test.0
    network_interface_ids.#: "" => "<computed>"

~ azurerm_virtual_machine.test.1
    network_interface_ids.#: "" => "<computed>"

~ azurerm_virtual_machine.test.2
    network_interface_ids.#: "" => "<computed>"

Plan: 3 to add, 6 to change, 0 to destroy.

It looks like when I ran the apply that it seem liked it worked. I didnt check if the other VMs that were already up were reset or not.

@tombuildsstuff
Copy link
Contributor

Hi @clintonm9

Thanks for bearing with us here.

I've run the configuration posted above, including scaling the machine count up and down - and I can confirm @StephenWeatherford's comments in that this issue appears to be resolved. As such I'm going to close this issue for the moment - but please feel free to re-open it if there's still an issue here :)

Thanks!

@ghost
Copy link

ghost commented Apr 11, 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 11, 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

6 participants