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/azurerm: Fixes for azurerm subnet properties #8791

Closed
wants to merge 6 commits into from

Conversation

carinadigital
Copy link
Contributor

Partially fixes GH-8227

So far this implements the setting of address range, route table association and network security group association for azurerm subnet resource.

There is still failure when going from a set resource to none for route tables and nsg, e.g.

resource "azurerm_subnet" "test" {
    name = "testsubnet"
    resource_group_name = "${azurerm_resource_group.test.name}"
    virtual_network_name = "${azurerm_virtual_network.test.name}"
    address_prefix = "10.0.1.0/24"
    route_table_id = "${azurerm_route_table.test.id}"
    network_security_group_id = "${azurerm_network_security_group.test.id}"
}

to

resource "azurerm_subnet" "test" {
    name = "testsubnet"
    resource_group_name = "${azurerm_resource_group.test.name}"
    virtual_network_name = "${azurerm_virtual_network.test.name}"
    address_prefix = "10.0.1.0/24"
    route_table_id = ""
    network_security_group_id = ""
}

@carinadigital carinadigital changed the title Fixes for azurerm subnet propeties Fixes for azurerm subnet properties Sep 12, 2016
@carinadigital
Copy link
Contributor Author

I think the fact that network_security_group_id and route_table_id are computed resources is relevant. I don't completely understand the use of 'computed' in the schema, but when I compile without it, I get the correct behaviour.

It's perfectly reasonable to create route tables and NSGs and not link them with any subnets.

@carinadigital
Copy link
Contributor Author

So I think that 'computed' in the resource schema does not match the actual relationship of subnet to route_table_id and network_security_group_id.

A Route Table is not created when a Subnet is created, and neither is any relationship established. The linkage is manual and depends on the Route Table being created and it's ID provided to the subnet.

@carinadigital
Copy link
Contributor Author

carinadigital commented Sep 13, 2016

This is ready for review. Fully fixes GH-8227 and route_table_id &network_security_group_id associations in the azurerm subnet resource.

There will be an impact on those who have manually set route table or NSG associations and do not have a corresponding entry in the subnet resource. Previously during the plan it will ignore route table or NSG associations and leave real-life associations. The new behaviour will remove any existing associations if route_table_id and network_security_group_id are ommitted or set to "".

@carinadigital carinadigital changed the title Fixes for azurerm subnet properties provider/azurerm: Fixes for azurerm subnet properties Sep 27, 2016
@carinadigital carinadigital force-pushed the GH-8227 branch 2 times, most recently from a0257c1 to aa66a31 Compare October 10, 2016 13:32
@carinadigital carinadigital force-pushed the GH-8227 branch 3 times, most recently from cc90cbc to 79c425e Compare October 18, 2016 12:48
@carinadigital
Copy link
Contributor Author

carinadigital commented Oct 18, 2016

Added TestAccAzureRMSubnet_update() to show the problem with removing route table and NSG associations on the subnet.

Andreas Kyrris added 6 commits October 21, 2016 14:05
Computed attributed does not describe the relationship between subnet
and route tables or NSGs. They are independent resources linked
together. This is show by setting route_table_id to empty and you will
see the the route_table_id is not removed but left at whatever value
is present.

Care should be taken with existing resources as the behaviour that
relies of subnets ignoring route table and NSG associations will no
longer work.
@carinadigital
Copy link
Contributor Author

@stack72 Can someone review this / advise on next steps please? It's been hanging around for a while.

@carinadigital
Copy link
Contributor Author

carinadigital commented Oct 27, 2016

I think it will need another look due to the recent merge of #9646
They cover some similar code..

@carinadigital
Copy link
Contributor Author

I'm going to close this pull request given that some of the functionality in resourceArmSubnetRead() was fixed in #9646 . I have opened another PR #9648 that's more specific to the issue of route table association and network security group in the subnet

@ghost
Copy link

ghost commented Apr 21, 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 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azurerm_subnet does not track route_table_id association.
2 participants