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_api_management - support for virtual network integration #5769

Merged

Conversation

francescopersico
Copy link
Contributor

@francescopersico francescopersico commented Feb 15, 2020

The PR adds API Management virtual network integration both internal and external.

Fixes #3667

@nsmeef
Copy link

nsmeef commented Mar 6, 2020

Whats the status of this? Would love to get this in soon :)

@dansali
Copy link

dansali commented Mar 6, 2020

This will be incredibly helpful for me, looking forward to seeing this put in :)

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 PR @francescopersico, overall this looks great and i've left a few comments inline that should be addressed. Looks like you forgot to add private_ip_addresses to the schema

Type: schema.TypeString,
Required: true,
ForceNew: true,
},
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 validate this is a proper id with azure.ValidateResourceID

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


func testAccAzureRMApiManagement_virtualNetworkInternal(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we'll need a provider block here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


resource "azurerm_virtual_network" "test" {
name = "acctestVNET-%d"
location = "${azurerm_resource_group.test.location}"
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 switch the test to .12 syntax?

@@ -674,6 +713,8 @@ func resourceArmApiManagementServiceRead(d *schema.ResourceData, meta interface{
d.Set("management_api_url", props.ManagementAPIURL)
d.Set("scm_url", props.ScmURL)
d.Set("public_ip_addresses", props.PublicIPAddresses)
d.Set("private_ip_addresses", props.PrivateIPAddresses)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This property doesn't exist?

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 add it to the schema

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

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.

Hey @francescopersico,

thank you for this PR. In addition to the comments i've left and the missing schema for private IP addresses i am noticing the following failure:

FAIL: TestAccAzureRMApiManagement_virtualNetworkInternal (1994.83s)
    testing.go:701: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during apply: Error deleting Subnet "acctestSNET-200309190719588572" (Virtual Network "acctestVNET-200309190719588572" / Resource Group "acctestRG-200309190719588572"): network.SubnetsClient#Delete: Failure sending request: StatusCode=400 -- Original Error: Code="InUseSubnetCannotBeDeleted" Message="Subnet acctestSNET-200309190719588572 is in use by /subscriptions/1a6092a6-137e-4025-9a7c-ef77f76f2c02/providers/Microsoft.ApiManagement/service?vnetResourceGuid=f0075bd1-4258-45c9-b336-1ebc09e42a70&subnet=acctestSNET-200309190719588572&api-version=2016-07-07 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet." Details=[]

@@ -674,6 +713,8 @@ func resourceArmApiManagementServiceRead(d *schema.ResourceData, meta interface{
d.Set("management_api_url", props.ManagementAPIURL)
d.Set("scm_url", props.ScmURL)
d.Set("public_ip_addresses", props.PublicIPAddresses)
d.Set("private_ip_addresses", props.PrivateIPAddresses)
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 add it to the schema

@tombuildsstuff
Copy link
Contributor

tombuildsstuff commented Mar 10, 2020

@francescopersico unfortunately there's an issue in this version of the API which is fixed in the latest release (but not the intermediate 2019-01-01) release - this is available in the new version of the SDK and as such I'm going to mark this as waiting on that for the moment. Once the SDK been updated we should be able to switch over to this new API version, update the code to match the changes in that version and then update this PR

@tombuildsstuff tombuildsstuff added sdk/requires-newer-api-version This requires upgrading the version of the API being used sdk/requires-upgrade This is dependent upon upgrading an SDK labels Mar 10, 2020
@tombuildsstuff tombuildsstuff modified the milestones: v2.1.0, v2.2.0 Mar 10, 2020
@francescopersico
Copy link
Contributor Author

@katbyte @tombuildsstuff i have tested and yes there is a problem deleting the resource, the subnet can't be deleted because the APIM deletion process is really long and in background.

@ghost ghost removed the waiting-response label Mar 18, 2020
@katbyte katbyte modified the milestones: v2.2.0, v2.3.0 Mar 18, 2020
katbyte pushed a commit that referenced this pull request Mar 19, 2020
This PR supersedes #6049 as nested go modules and merge conflicts do not spark joy - but fundamentally this:

- updates github.com/Azure/azure-sdk-for-go to v40.3.0
- updates github.com/Azure/go-autorest to our fork containing Azure/go-autorest#512
- updates github.com/terraform-providers/terraform-provider-azuread to v0.8.0
- code changes needed for v40.3.0 of the Azure SDK - including opting into the old count 429's as requests which should be retried without adding to the total failure count

Enables #5769
Enables #5696
@cs-marek-ruszczyk
Copy link

cs-marek-ruszczyk commented Mar 24, 2020

Hi and thanks for your work, I'd like to ask if you're going to release this in next version with resource deletion problem or more likely you would like to way for improvements on Azure side?

@katbyte
Copy link
Collaborator

katbyte commented Mar 24, 2020

@francescopersico & @cs-marek-ruszczyk,

We have updated the SDK so we should be able to update the API version used now

@tombuildsstuff tombuildsstuff modified the milestones: v2.3.0, v2.5.0 Mar 25, 2020
@francescopersico
Copy link
Contributor Author

@katbyte as @tombuildsstuff said the fix is not included in the API v2019-01-01. So i think we must wait for the update of the sdk to v40.6.0 which includes v2019-12-01.
Am i wrong?

katbyte added a commit that referenced this pull request Apr 22, 2020
@katbyte
Copy link
Collaborator

katbyte commented Apr 22, 2020

@francescopersico - API update has been merged!

@jonatasbaldin
Copy link

Excited to see this coming! Just did a PowerShell script inside Terraform to enable vNet in APIM today heheh thanks for allllll the hard work :)

@francescopersico
Copy link
Contributor Author

@francescopersico - API update has been merged!

Going to update the PR. Thanks.

@francescopersico francescopersico force-pushed the add-api-management-vnet-integration branch from c96a325 to 06db1d3 Compare April 23, 2020 11:09
@ghost ghost added size/L and removed size/M labels Apr 23, 2020
@francescopersico
Copy link
Contributor Author

@katbyte rebase and change requests done.

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 @francescopersico! LGTM and running tests now 🚀

@@ -64,6 +64,14 @@ func resourceArmApiManagementService() *schema.Resource {
},
},

"private_ip_addresses": {
Copy link
Collaborator

@katbyte katbyte Apr 23, 2020

Choose a reason for hiding this comment

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

We typically group computed properties at the bottom of the schema, ie required -> optional -> computes

@katbyte
Copy link
Collaborator

katbyte commented Apr 23, 2020

@francescopersico - i had to add a default to get the tests to pass, but pushed the changes and will merge as soon as travis finishes 🙂

@katbyte katbyte changed the title Add API Management vnet integration azurerm_api_management - support for virtual network integration Apr 23, 2020
@katbyte katbyte merged commit 8b8adca into hashicorp:master Apr 23, 2020
katbyte added a commit that referenced this pull request Apr 23, 2020
@ghost
Copy link

ghost commented Apr 23, 2020

This has been released in version 2.7.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.7.0"
}
# ... other configuration ...

@dansali
Copy link

dansali commented Apr 25, 2020

Thank you guys!!!

@dansali
Copy link

dansali commented Apr 25, 2020

@katbyte

This change also includes a new resource variable "private_ip_addresses" which was missed in the documentation. I think it should also be added in? :)

website/docs/r/api_management.html.markdown

  • private_ip_addresses - Private Internal IP addresses of the API Management service in the virtual network. Available only for Basic, Standard and Premium SKU after VNet integration.

neil-yechenwei pushed a commit to neil-yechenwei/terraform-provider-azurerm that referenced this pull request Apr 26, 2020
@ghost
Copy link

ghost commented May 24, 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 May 24, 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.

Feature Request: API Management with virtual networks
7 participants