-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Azure virtual machine interfaces are not being created and attached in the order they are defined within the main.tf script #99
Comments
is there a rough eta on when this will be fixed? it's blowing up my customer demonstrations. |
Hey @kblackstone So that we can take a look into this would it be possible to post the Terraform config associated with this Issue? The download link appears to have stopped working? Thanks! |
Sure Tom. https://www.dropbox.com/s/wxo2368wujb3bdn/main.tf?dl=0 This is the full main.tf and here are the specific parts. Create the network interfacesresource "azurerm_network_interface" "Untrust" {
} Create the network interfacesresource "azurerm_network_interface" "Trust" {
} *** further down in the file *** network_interface_ids = |
I just ran through it yesterday setting up a demo environment. 1 firewall had the interfaces in the right order, the other had them flipped. This is a non-starter for auto-deploying environments that rely on consistent interface placement. Until that gets fixed i have to tell customers to go in and manually check or potentially re-create the virtual machine via arm templates, which is exactly what they don't want to do, otherwise they would scrap terraform and template the whole thing. |
Pasting the full config here just incase the original download link 404's again:
|
any update on this? |
for what it's worth, the same behavior happens if you need to make network interfaces for multiple virtual machines (ubuntu for example). You'll see nic.0, nic.2, nic.1 in that order be created. |
Hi @kblackstone, Thanks, |
Hi, I ran into this very issue last friday and after much time spent debugging why my network interfaces are sometimes out of order, I figured what happens: A naiive fix would be just change diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go
index 26bbd00..22a228c 100644
--- a/azurerm/resource_arm_virtual_machine.go
+++ b/azurerm/resource_arm_virtual_machine.go
@@ -479,12 +479,11 @@ func resourceArmVirtualMachine() *schema.Resource {
},
"network_interface_ids": {
- Type: schema.TypeSet,
+ Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
- Set: schema.HashString,
},
"primary_network_interface_id": {
@@ -1432,7 +1431,7 @@ func expandAzureRmVirtualMachineImageReference(d *schema.ResourceData) (*compute
}
func expandAzureRmVirtualMachineNetworkProfile(d *schema.ResourceData) compute.NetworkProfile {
- nicIds := d.Get("network_interface_ids").(*schema.Set).List()
+ nicIds := d.Get("network_interface_ids").([]interface{})
primaryNicId := d.Get("primary_network_interface_id").(string)
network_interfaces := make([]compute.NetworkInterfaceReference, 0, len(nicIds)) Note that this will make supplying non-repeating values in A proper fix might be making OrderedSet schema type which does preserve order of elements passed into it, but I didn't wrote that. Hope this helps. |
My solution to this is to deploy another virtual machine (some bastion box) after the firewall. It seems to resolve the issue, or at least pass it down the line. |
hey @pzskc383 Thanks for looking into this and confirming that - I'd been meaning to look into that this week anyway whilst reviewing the VM and VMSS resources - so I'll include those changes in the PR's I'll be making later this week :) Thanks! |
This is fixed in #426 |
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 👉 hashibot-feedback@hashicorp.com. Thanks! |
This issue was originally opened by @kblackstone as hashicorp/terraform#15153. It was migrated here as part of the provider split. The original body of the issue is below.
Terraform Version
0.9.6
Affected Resource(s)
Terraform Configuration Files
https://www.dropbox.com/s/q4pnvy0bs2812vk/main.tf?dl=0
Expected Behavior
The interfaces should be consistently created and attached in the following order: management, untrust, trust as defined within the main.tf script.
Actual Behavior
Terraform plan is showing they will be attached in this order: management, trust, untrust. This is the actual order they get attached in on the virtual machine when launched via terraform apply, which is incorrect. The attachment order is inconsistent. On one run of terraform plan/apply it may create in the right order, on another run of terraform plan/apply it will be in the incorrect order. The first interface is ok due to primary_network_interface_id. I have screen shots of desired.
Steps to Reproduce
terraform plan
terraform apply
The text was updated successfully, but these errors were encountered: