Skip to content

Conversation

@wuxu92
Copy link
Contributor

@wuxu92 wuxu92 commented Sep 29, 2025

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

Some resources support update/delete user identity by setting the value of the id to null, This PR is to add this ability by introduce a global variable for null value.

this is required by hashicorp/terraform-provider-azurerm#30293 and other resources.

Now to remove an user-assigned-identity, we can set like below:

		expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity)
		if err != nil {
			return fmt.Errorf("expanding `identity`: %+v", err)
		}
		if currentIdentity := exists.Model.Identity; currentIdentity != nil {
			// mark identity should be delete as null
			for id := range currentIdentity.IdentityIds {
				if _, ok := expandedIdentity.IdentityIds[id]; !ok {
					expandedIdentity.IdentityIds[id] = identity.NullUserAssignedIdentityDetails
				}
			}
		}

test:

--- PASS: TestUserAssignedIdentityDetails_MarshalJSON (0.00s)
    --- PASS: TestUserAssignedIdentityDetails_MarshalJSON/empty_identity (0.00s)
    --- PASS: TestUserAssignedIdentityDetails_MarshalJSON/nil_identity (0.00s)
    --- PASS: TestUserAssignedIdentityDetails_MarshalJSON/other_value_identity (0.00s)
    --- PASS: TestUserAssignedIdentityDetails_MarshalJSON/other_empty_identity (0.00s)
PASS

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • added null value support for user assigned identity

This is a (please select all that apply):

  • Bug Fix
  • New Feature
  • Enhancement
  • Breaking Change

Related Issue(s)

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the provider.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

@wuxu92 wuxu92 requested a review from a team as a code owner September 29, 2025 06:01
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.

1 participant