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

Adding in DeleteBeforeReplace: True to IAM types #2650

Merged
merged 1 commit into from
Nov 18, 2024
Merged

Adding in DeleteBeforeReplace: True to IAM types #2650

merged 1 commit into from
Nov 18, 2024

Conversation

rshade
Copy link
Contributor

@rshade rshade commented Nov 18, 2024

This added in DeleteBeforeReplace for google_project_iam_policy, google_project_iam_member

Copy link

github-actions bot commented Nov 18, 2024

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Maintainer note: consult the runbook for dealing with any breaking changes.

Copy link
Contributor

@VenelinMartinov VenelinMartinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this. I am fairly certain that IAM Member resources do not work without DeleteBeforeReplace - all the upstream schema fields are ForceNew and the replacements works as described in #2463 (comment), which causes a silent deletion of the resource.

It'd be nice if we added a test for these resources but it might be non-trivial given that it involves permissions.

I am wondering if we can solve this more widely for GCP - there are a fair number of Iam_policy and iam_member resources and I suspect all of them work this way. Perhaps something to consider as a follow up - we could add a test which provisions each of these resources and verifies that a replacement ends with a resource still existing.

@rshade
Copy link
Contributor Author

rshade commented Nov 18, 2024

@VenelinMartinov I like it, we could use the gcloud technique you showed me last week to do a get and see if they still exist. Since I am new to the ForceNew concept, is this a place where DBR is almost always needed, and if so should we run a comparison of resources with DBR vs ForceNew, and make a diff list to patch?

@VenelinMartinov
Copy link
Contributor

VenelinMartinov commented Nov 18, 2024

A property with ForceNew: true in the TF schema means that any change to that property triggers a replacement of the resource.

Generally resources do not require DeleteBeforeReplace if they have an "identity" in the cloud itself (think compute instance, storage bucket etc.)

Unfortunately, a number of resources do not have their own "identity" in the cloud. These tend to be resources representing a link between two other resources. We call these "structural" resources, there is a big and old issue about supporting these better: pulumi/pulumi#918

In this case, IAM Member is a structural resource, and that manifests in issues like #2463

Structural resources do need DeleteBeforeReplace. Unfortunately, there is no programmatic way to find which these resources are. For GCP specifically, I believe a lot of the IAM-related resources are "structural" since they tend to link a user with permissions/groups etc.

@rshade rshade enabled auto-merge (squash) November 18, 2024 17:03
@rshade rshade merged commit 678ddd9 into master Nov 18, 2024
23 checks passed
@rshade rshade deleted the iam-dbr branch November 18, 2024 17:25
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v8.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants