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

Importing azurerm_virtual_network subnets have null address_prefix #27076

Closed
1 task done
MattGarnerAWR opened this issue Aug 16, 2024 · 1 comment
Closed
1 task done

Comments

@MattGarnerAWR
Copy link

MattGarnerAWR commented Aug 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.8.3

AzureRM Provider Version

3.115.0

Affected Resource(s)/Data Source(s)

azurerm_virtual_network

Terraform Configuration Files

resource "azurerm_virtual_network" "example" {
  name                = "vnet-uks-staging-test"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  address_space       = ["10.0.0.0/24"]

  subnet {
    name           = "snet-${var.env}-test"
    address_prefix = "10.0.0.192/26"
    security_group = azurerm_network_security_group.example.id
  }

  subnet {
    name           = "snet-${var.env}-test-test"
    address_prefix = "10.0.0.0/26"
    security_group = azurerm_network_security_group.example.id
  }
}

Debug Output/Panic Output

~ resource "azurerm_virtual_network" "example" {
        id                      = "/subscriptions/xxx/resourceGroups/rg-uks-staging-network/providers/Microsoft.Network/virtualNetworks/vnet-uks-staging-test"
        name                    = "vnet-uks-staging-test"
      ~ subnet                  = [
          - {
              - id             = "/subscriptions/xxx/resourceGroups/rg-uks-staging-network/providers/Microsoft.Network/virtualNetworks/vnet-uks-staging-test/subnets/snet-staging-test"
              - name           = "snet-staging-test"
              - security_group = "/subscriptions/xxx/resourceGroups/rg-uks-staging-network/providers/Microsoft.Network/networkSecurityGroups/nsg-uks-staging-test"
                # (1 unchanged attribute hidden)
            },
          - {
              - id             = "/subscriptions/xxx/resourceGroups/rg-uks-staging-network/providers/Microsoft.Network/virtualNetworks/vnet-uks-staging-test/subnets/snet-staging-test-test"
              - name           = "snet-staging-test-test"
              - security_group = "/subscriptions/xxx/resourceGroups/rg-uks-staging-network/providers/Microsoft.Network/networkSecurityGroups/nsg-uks-staging-test"
                # (1 unchanged attribute hidden)
            },
          + {
              + address_prefix = "10.0.0.0/26"
              + id             = (known after apply)
              + name           = "snet-staging-test-test"
              + security_group = "/subscriptions/xxx/resourceGroups/rg-uks-staging-network/providers/Microsoft.Network/networkSecurityGroups/nsg-uks-staging-test"
            },
          + {
              + address_prefix = "10.0.0.192/26"
              + id             = (known after apply)
              + name           = "snet-staging-test"
              + security_group = "/subscriptions/xxx/resourceGroups/rg-uks-staging-network/providers/Microsoft.Network/networkSecurityGroups/nsg-uks-staging-test"
            },
        ]
        tags                    = {}
        # (8 unchanged attributes hidden)
    }

Expected Behaviour

Terraform should import the subnet address prefixes into state.

Actual Behaviour

The address prefixes are set as null in state after import, meaning they are set to be recreated with what is set in code.

Steps to Reproduce

  1. terraform plan

Important Factoids

No response

References

No response

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2024
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

1 participant