Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add entry for ApiManagement.Policy to default resources state (#3688)
Resolves #1729. There's only one global API Management Policy, which can be updated but not created. Tested locally with the following program, slightly modified from the user's example in #1729. - `pulumi up` without this change fails with `azure-native:apimanagement:Policy (policy): error: cannot create already existing subresource '/subscriptions/123/resourceGroups/rg-test-apim7a7ad090/providers/Microsoft.ApiManagement/service/apimtest122f07ff/policies/policy'` - `pulumi up` and `pulumi down` succeed with this change. Here's a program to create the parent apiManagementService then test creating and destroying a Policy. When creating the Policy, the provider will do a GET to check for existance first which can be used to see the initial state. ```csharp using Pulumi; using Resources = Pulumi.AzureNative.Resources; using ApiManagement = Pulumi.AzureNative.ApiManagement; return await Deployment.RunAsync(() => { // Create an Azure Resource Group var resourceGroup = new Resources.ResourceGroup("rg-test-apim"); // Create an API Management Service var apiManagementService = new ApiManagement.ApiManagementService( "apimtest", new ApiManagement.ApiManagementServiceArgs { Location = resourceGroup.Location, PublisherEmail = "[email protected]", PublisherName = "Publisher", ResourceGroupName = resourceGroup.Name, Sku = new ApiManagement.Inputs.ApiManagementServiceSkuPropertiesArgs { Capacity = 0, Name = "Consumption", }, }); // Update the contents of the global policy. var policy = new ApiManagement.Policy( "policy", new ApiManagement.PolicyArgs { Format = "xml", ResourceGroupName = resourceGroup.Name, ServiceName = apiManagementService.Name, Value = "<!-- Custom Test Policy -->\r\n<policies>\r\n <inbound>\r\n </inbound>\r\n <backend>\r\n <forward-request />\r\n </backend>\r\n <outbound />\r\n <on-error />\r\n</policies>", } ); }); ``` Note that [in the earliest preview API version, the property names are different](https://github.com/Azure/azure-rest-api-specs/blob/0410d404c68289cb1737d06bba92133bb84b515c/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2018-06-01-preview/definitions.json#L3097), hence two entries in the map.
- Loading branch information