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

Fix product api not reassigned on manual delete #5054

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions azurerm/resource_arm_api_management_product_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ func resourceArmApiManagementProductApiRead(d *schema.ResourceData, meta interfa
return fmt.Errorf("Error retrieving API %q / Product %q (API Management Service %q / Resource Group %q): %+v", apiName, productId, serviceName, resourceGroup, err)
}

// This can be removed once updated to apimanagement API to 2019-01-01
// https://github.com/Azure/azure-sdk-for-go/blob/master/services/apimanagement/mgmt/2019-01-01/apimanagement/productapi.go#L134
if utils.ResponseWasNotFound(resp) {
log.Printf("[DEBUG] API %q was not found in Product %q (API Management Service %q / Resource Group %q) was not found - removing from state!", apiName, productId, serviceName, resourceGroup)
d.SetId("")
return nil
}

d.Set("api_name", apiName)
d.Set("product_id", productId)
d.Set("resource_group_name", resourceGroup)
Expand Down