pulumi / pulumi-gcp

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

Consider changing the behaviour of imported labels #1959

Open VenelinMartinov opened 5 months ago

VenelinMartinov commented 5 months ago

What happened?

We can follow-up on https://github.com/pulumi/pulumi-gcp/issues/1916 and https://github.com/pulumi/pulumi-gcp/pull/1946.

Currently ~all resources in GCP, when imported will import the labels in effectiveLabels and not in labels. This means that the labels are not controlled in pulumi - GCP uses effectiveLabels as a way to not override non-managed labels.

We should reconsider this behaviour. It's a feature added in terraform in https://www.hashicorp.com/blog/terraform-google-provider-adds-updates-to-default-labels as a way to not manage all labels on resources. The import behaviour is not significant in terraform as they do not really support the same workflows of importing resources into already existing code.

We do support that and users seem to use the resources that way - we can change the import behaviour to assume, by default that all labels are managed. This is the model we have for almost all resource properties, so labels likely should not be different.

In terms of implementation, the most straightforward is a patch. Unfortunately this will affect ~all resources in GCP, so not sure we can do that.

We might be able to do something in the middle with TransformOutputs but that does not give us access to the provider defaultLabels so will not allow us to fix that in imports. This might be fine though.

Example

import a resource (not a bucket) with labels defined. Observe that the labels property is empty after import.

Output of pulumi about

.

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

iwahbe commented 5 months ago

If we were to enhance TransformOutputs with the providers meta "config" (as an any), would we be able to solve this the right way without an additional patch.