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

New Resource & Data Source: azurerm_app_service_virtual_network_connection_gateway #4458

Conversation

njuCZ
Copy link
Contributor

@njuCZ njuCZ commented Sep 30, 2019

Add new resource and data source for Gateway Required App Service Virtual Network Connection
(fix [#4333, #4332])

@njuCZ njuCZ force-pushed the app-service-gateway-required-virtual-network-connection branch from 87bfcc6 to 5259d19 Compare September 30, 2019 08:09
@njuCZ njuCZ force-pushed the app-service-gateway-required-virtual-network-connection branch from 2a91ccb to aac30f1 Compare October 8, 2019 03:03
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @njuCZ,

I started reviewing this and have left a bunch of comments inline. While going through the create function it appears we are calling a bunch of different APIs. Would this resource make more sense a a few individual ones that combine for the same affect? possible a virtual_network_gateway_connection and a virtual_network_gateway_connection_app_service_association resource?

@katbyte katbyte added this to the v1.37.0 milestone Nov 1, 2019
@njuCZ
Copy link
Contributor Author

njuCZ commented Nov 6, 2019

Hi @njuCZ,

I started reviewing this and have left a bunch of comments inline. While going through the create function it appears we are calling a bunch of different APIs. Would this resource make more sense a a few individual ones that combine for the same affect? possible a virtual_network_gateway_connection and a virtual_network_gateway_connection_app_service_association resource?

this resource is to intergrate an app service with a virtual network. It's one whole function in the azure portal, though it needs call two different api. there is no need to separate into two different resources

@ghost ghost removed the waiting-response label Nov 6, 2019
@njuCZ
Copy link
Contributor Author

njuCZ commented Nov 6, 2019

@katbyte I have modified my codes according to your suggestion, could you kindly review my codes once more?

@njuCZ njuCZ requested a review from katbyte November 6, 2019 06:28
@njuCZ njuCZ force-pushed the app-service-gateway-required-virtual-network-connection branch from f0adece to cbcb1bb Compare November 8, 2019 08:06
@katbyte katbyte changed the title Add new resource and data source for Gateway Required App Service Connection New Resource & Data Source: azurerm_app_service_virtual_network_connection Nov 15, 2019
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the revisions @njuCZ,

In addition to the comments i've left i'm wondering if it makes sense to export all those properties? are they available via the app service or vnet resource/data sources? because if they are it might make sense to leave them out with a comment stating as such and users can just instead use those, wdyt?

@katbyte
Copy link
Collaborator

katbyte commented Nov 15, 2019

Also we are getting test failures:

------- Stdout: -------
=== RUN   TestAccDataSourceAzureRMAppServiceVirtualNetworkConnection_basic
=== PAUSE TestAccDataSourceAzureRMAppServiceVirtualNetworkConnection_basic
=== CONT  TestAccDataSourceAzureRMAppServiceVirtualNetworkConnection_basic
--- FAIL: TestAccDataSourceAzureRMAppServiceVirtualNetworkConnection_basic (2946.44s)
    testing.go:569: Step 0 error: errors during apply:
        
        Error: error add certificate for gateway "example": error adding cerfiticate for gateway "example" (Resource Group "acctestRG-191114233037998613"): network.VirtualNetworkGatewaysClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="AnotherOperationInProgress" Message="Another operation on this or dependent resource is in progress. To retrieve status of the operation use uri: https://management.azure.com/subscriptions/1a6092a6-137e-4025-9a7c-ef77f76f2c02/providers/Microsoft.Network/locations/westeurope/operations/a672b118-fb92-4de0-911a-2bdd5a3c3050?api-version=2019-06-01." Details=[]

@njuCZ
Copy link
Contributor Author

njuCZ commented Nov 15, 2019

@katbyte thank you for your suggestion, I have fixed them

@njuCZ njuCZ force-pushed the app-service-gateway-required-virtual-network-connection branch from b0b358d to 36c8020 Compare November 18, 2019 06:32
@tombuildsstuff tombuildsstuff modified the milestones: v1.37.0, v1.38.0 Nov 21, 2019
@tombuildsstuff tombuildsstuff modified the milestones: v1.38.0, v1.39.0 Dec 3, 2019
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the updates @njuCZ, i've left some more comments inline that need to be addressed before merge.

@tombuildsstuff tombuildsstuff removed this from the v1.39.0 milestone Dec 12, 2019
@njuCZ njuCZ force-pushed the app-service-gateway-required-virtual-network-connection branch from 7c66d8f to ce14e3f Compare December 17, 2019 08:54
@ghost ghost removed the size/XXL label Dec 17, 2019
@njuCZ
Copy link
Contributor Author

njuCZ commented Dec 20, 2019

hi @katbyte I have refactored to azurerm_app_service_virtual_network_connection_gateway

@ghost ghost removed the waiting-response label Dec 20, 2019
@njuCZ njuCZ force-pushed the app-service-gateway-required-virtual-network-connection branch 2 times, most recently from ff6f8c9 to 4c97eac Compare December 23, 2019 10:58
@njuCZ njuCZ changed the title New Resource & Data Source: azurerm_app_service_virtual_network_connection New Resource & Data Source: azurerm_app_service_virtual_network_connection_gateway Dec 23, 2019
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @njuCZ,

I've given this another review and left my comments inline. I'd really like some additional detail in comments about the workflow of the create function and the steps its taking. Thanks!

return fmt.Errorf("this gateways %q under vnet %q (Resource Group %q) does not have a Point-to-site Address Range. Please specify one in CIDR notation, e.g. 10.0.0.0/8", gatewayName, vnetName, vnetResGroup)
}

isRelated, err := checkGatewayInVirtualNetwork(virtualNetworkGateway, vnetId)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get some comments explaining what the workflow is here and these function calls aredoing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left some comments in the codes for the steps. At first I want to find the virtual network gateway from the virtual network, now we have both parameters: virtual_network_id and virtual_network_gateway_id, so I first check whether they are related. (thus virtual network gateway should located in a gateway subnet in the virtual network)


lifecycle {
ignore_changes = [
vpn_client_configuration.0.root_certificate,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we ignoring lifecycle changes on this property? it might want to be computed if its being updated externally now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the steps are

  1. CreateOrUpdateVnetConnection
  2. result of step 1 contains cert infomation, we should set the cert to virtual network gateway (check duplicate)
  3. generate vpn package uri
  4. CreateOrUpdateVnetConnectionGateway using step 3's result

a gateway required virtual network integration needs these four steps. In this process, we need update certificate of the virtual network gateway.
I think there is no means to split this process.

I have added computed: true in the newest codes for virtual network gateway

Comment on lines 131 to 137
* `routes` - (Array) One or more `route` block defined below.

---

A `route` block supports the following:
* `name` - Resource Name.
* `route_type` - The type of route this is: DEFAULT - By default, every app has routes to the local address ranges specified by RFC1918 INHERITED - Routes inherited from the real Virtual Network routes STATIC - Static route set on the app only. Valid values are `DEFAULT`, `INHERITED`, `STATIC`
* `start_address` The starting address for the route.
* `end_address` - The ending address for the route.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are exported so could we word them as such?

@njuCZ njuCZ force-pushed the app-service-gateway-required-virtual-network-connection branch from e44f494 to 2f5a478 Compare March 10, 2020 14:34
@njuCZ njuCZ force-pushed the app-service-gateway-required-virtual-network-connection branch from 2f5a478 to 65716b0 Compare March 10, 2020 14:52
@ghost ghost added size/XL and removed size/XXL labels Mar 10, 2020
@njuCZ
Copy link
Contributor Author

njuCZ commented Mar 10, 2020

@katbyte sorry for late reply. I have refined my codes.
The logic is a little complex for this function, you can mainly refer to this script
https://gallery.technet.microsoft.com/scriptcenter/Connect-an-app-in-Azure-ab7527e3

Thanks again for your patience reviewing this PR!

@ghost ghost removed the waiting-response label Mar 10, 2020
@jackofallops
Copy link
Member

Hi @njuCZ
I've been working through this PR to see how we can get it progressed.

It feels like things are confused (and confusing) as there should be two resources (with data sources) here, azurerm_app_service_network_connection and azurerm_app_service_network_connection_gateway?

I think a redesign into 2 will simplify things, give better focus to each part, and help us get this through. WDYT?

@tombuildsstuff
Copy link
Contributor

Based on this comment there's some design questions which need to be addressed here - rather than leaving this open whilst that's happening I'm going to close this PR for the moment, but once those have been resolved we can circle back around and take another look here

@ghost
Copy link

ghost commented Jul 6, 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 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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Jul 6, 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.

4 participants