pulumi / pulumi-gcp

A Google Cloud Platform (GCP) Pulumi resource package, providing multi-language access to GCP
Apache License 2.0
178 stars 52 forks source link

IngoreChanges for annotations #485

Open q42jaap opened 3 years ago

q42jaap commented 3 years ago

I'm trying to create a gcp.cloudrun.Service object. I'm specifying 1 annotation. However, the defaults in GCP seem to set additional annotations. I want to add these annotations to ignoreChanges.

    const webhookService = new gcp.cloudrun.Service("webhook-service", {
        name: `webhook-service-${clusterName}`,
        location: webhookLocation,
        template: {
            metadata: {
                annotations: {
                    "run.googleapis.com/vpc-access-connector": "vpc-connector",
                }
            },
            spec: {
                ...
            },
        },
    }

The diff when I update the stack:

      ~ template: {
          ~ metadata: {
              ~ annotations: {
                  - autoscaling.knative.dev/maxScale    : "1000"
                  - run.googleapis.com/vpc-access-egress: "private-ranges-only"
                }
            }
        }

I want to ignore these defaults.

I tried several things, like:

    {
        ignoreChanges: [
            `template.metadata.annotations["autoscaling.knative.dev/maxScale"]`,    
            "template.metadata.annotations.autoscalingKnativeDev.maxScale", 
            "template.metadata.annotations.autoscalingKnativeDev/maxScale", 
            "template.metadata.annotations.autoscalingKnativeDevMaxScale",  
        ]
    }

I couldn't get it to work.

The docs at https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges say

The property names passed to ignoreChanges should always be the “camelCase” version of the property name as used in the core Pulumi resource model.

This comment doesn't help me, how is the bag of annotations camelCased? For me as a pulumi user, the term the core Pulumi resource model doesn't explain how I should format ignoreChanges in complex cases.

I found some PR's in pulumi/pulumi which didn't help me, because of the plugin architecture of the pulumi codebase. Where are ignoreChanges even applied, and what escaping was used on the PropertyKey.

More guidance and examples in the docs would help.

ForbesLindesay commented 3 years ago

I have the same problem. Google adds lots of annotations automatically, but some annotations are important. In my case the relevant annotations are at metadata.annotations["..."] rather than template.metadata.annotations["..."] but otherwise it's the same.

sudermanjr commented 2 years ago

I just hit this as well. Is there any workaround available?

VladAmos commented 1 year ago

Throwing my hat in this issue as well, a lot of the annotations are managed by GCP, but a few, like the SQL ones, are valid configuration. It'd be great to be able to ignore annotations specifically.