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

Updating Apim operation policy leads to no changes #3202

Open
vdboots opened this issue Apr 5, 2024 · 5 comments
Open

Updating Apim operation policy leads to no changes #3202

vdboots opened this issue Apr 5, 2024 · 5 comments
Labels
kind/bug Some behavior is incorrect or out of spec needs-repro Needs repro steps before it can be triaged or fixed

Comments

@vdboots
Copy link

vdboots commented Apr 5, 2024

What happened?

when updating an api operation policy with plumi and the policy does not exist this runs well. but when It already exists the policy won't be updated.

Example


    var xml = @"
<policies>
    <inbound>
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>";
 var policy = new ApiOperationPolicy($"policy", new ApiOperationPolicyArgs
    {
        ResourceGroupName = resourceGroupName,
        ServiceName = apiManagementServiceName,
        ApiId = api.Name,
        OperationId = apiOperation.Name,
        Value = xml,
        Format = "xml",
        
        
    }, new CustomResourceOptions() { ReplaceOnChanges = { "*" }, DeleteBeforeReplace = true});

Output of plumi after deploying making a change in the xml and deploying again:

Resources:
    4 unchanged

Duration: 2s

Output of pulumi about

NAME VERSION
Pulumi 3.60.0
Pulumi.AzureNative 2.35.0

Additional context

When this is deployed and you make a change to the XML and deploy it again. The change won't be committed

@vdboots vdboots added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Apr 5, 2024
@danielrbradley
Copy link
Member

danielrbradley commented Apr 9, 2024

@vdboots I've just re-created and run your example given above, filling in the missing resources:

using Pulumi;
using Pulumi.AzureNative.Resources;
using System.Collections.Generic;
using Pulumi.AzureNative.ApiManagement;
using Pulumi.AzureNative.ApiManagement.Inputs;

return await Pulumi.Deployment.RunAsync(() =>
    {
        var resourceGroup = new ResourceGroup("resourceGroup", new ResourceGroupArgs
        {
            Location = "EastUS"
        });

        var ams = new ApiManagementService("apim", new ApiManagementServiceArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Location = resourceGroup.Location,
            PublisherEmail = "test@pulumi.com",
            PublisherName = "Pulumi",
            Sku = new ApiManagementServiceSkuPropertiesArgs
            {
                Capacity = 0,
                Name = "Consumption",
            },
        });

        var api = new Api("api", new ApiArgs
        {
            ResourceGroupName = resourceGroup.Name,
            ServiceName = ams.Name,
            DisplayName = "My API",
            Path = "myapi",
            SubscriptionRequired = true,
            Protocols = new List<Union<string, Protocol>> { Protocol.Https },
        });

        var apiOperation = new ApiOperation("operation", new ApiOperationArgs
        {
            ResourceGroupName = resourceGroup.Name,
            ServiceName = ams.Name,
            ApiId = api.Name,
            DisplayName = "My Operation",
            Method = "GET",
            UrlTemplate = "operation",
        });

        var xml = @"
<policies>
    <inbound>
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>";

        var policy = new ApiOperationPolicy($"policy", new ApiOperationPolicyArgs
        {
            ResourceGroupName = resourceGroup.Name,
            ServiceName = ams.Name,
            ApiId = api.Name,
            OperationId = apiOperation.Name,
            Value = xml,
            Format = "xml",


        }, new CustomResourceOptions() { ReplaceOnChanges = { "*" }, DeleteBeforeReplace = true });
    });

The initial deployment completes correctly, and making a minor change to the XML (e.g. replace <base /> with <base></base>) results in a replacement as specified by your resource options:

     Type                                              Name     Status            Info
     pulumi:pulumi:Stack                               sdf-dev                    
 +-  └─ azure-native:apimanagement:ApiOperationPolicy  policy   replaced (1s)     [diff: ~value]

Resources:
    +-1 replaced
    5 unchanged

Duration: 8s

Removing the additional resource options and updating the XML also works for me without error:

     Type                                              Name     Status           Info
     pulumi:pulumi:Stack                               sdf-dev                   
 ~   └─ azure-native:apimanagement:ApiOperationPolicy  policy   updated (2s)     [diff: ~value]

Resources:
    ~ 1 updated
    5 unchanged

Please elaborate on how to recreate the error you're seeing.

@danielrbradley danielrbradley added needs-repro Needs repro steps before it can be triaged or fixed and removed needs-triage Needs attention from the triage team labels Apr 9, 2024
@vdboots
Copy link
Author

vdboots commented Apr 10, 2024

will try it out tommorew it told me the same. But the policy didn't update on azure itself.

@mikhailshilkov
Copy link
Member

@danielrbradley Have you checked if the change was applied on Azure, given the last comment from @vdboots ?

@mikhailshilkov mikhailshilkov added the needs-triage Needs attention from the triage team label Apr 17, 2024
@danielrbradley
Copy link
Member

@mikhailshilkov Yes, my change was applied in the Azure portal ... I added the following rules to the <inbound> section:

        <base />
        <find-and-replace from="xyz" to="abc" />

image

What's the change you're actually applying to the policy value @vdboots ?

@danielrbradley danielrbradley removed the needs-triage Needs attention from the triage team label Apr 17, 2024
@NielsLakeman
Copy link

@danielrbradley On a different machine I tried the same as @vdboots

NAME VERSION
Pulumi 3.61.0
Pulumi.AzureNative 2.37.0

Initial deployment went well.
After making a minor change to and running the deployment again I see the following message:

Resources:
7 unchanged

This is exact the same behaviour as vdboots mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec needs-repro Needs repro steps before it can be triaged or fixed
Projects
None yet
Development

No branches or pull requests

4 participants