Skip to content

azuread_directory_role_eligibility_schedule_request: handle purged requests - #1904

Open
kenchan0130 wants to merge 3 commits into
hashicorp:mainfrom
kenchan0130:fix-directory-role-eligibility-request-deletion
Open

azuread_directory_role_eligibility_schedule_request: handle purged requests#1904
kenchan0130 wants to merge 3 commits into
hashicorp:mainfrom
kenchan0130:fix-directory-role-eligibility-request-deletion

Conversation

@kenchan0130

@kenchan0130 kenchan0130 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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

Microsoft Graph typically purges unifiedRoleEligibilityScheduleRequest objects after 45 days while the corresponding eligible assignment remains.

After the request was purged, terraform apply failed with:

Error: Retrieving Role Management Directory Role Eligibility Schedule Request
(Unified Role Eligibility Schedule Request: "98d45129-9be7-4560-907a-5655192302c1")

unexpected status 404 (404 Not Found) with error:
RoleAssignmentRequestNotFound: The role assignment request is not found

The resource previously depended on retrieving the original request during deletion and assumed that request IDs and schedule IDs were identical.

This change:

  • finds the remaining assignment through roleEligibilityScheduleInstances;
  • matches the principal, role definition, scope, and Direct member type;
  • creates the adminRemove request from Terraform state;
  • waits until the eligible assignment is removed;
  • supports import using roleEligibilityScheduleId;
  • avoids an unnecessary replacement when the historical justification is unavailable after request purge.

The vendor changes contain the generated Microsoft Graph SDK client required for roleEligibilityScheduleInstances.

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them.
  • I have written new tests for my resource or datasource changes & updated any relevant documentation. No documentation changes were required because the resource schema is unchanged.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass.
go test ./internal/services/directoryroles/...
go vet ./internal/services/directoryroles/...
make fmtcheck

Change Log

  • azuread_directory_role_eligibility_schedule_request - fix refresh, import, and deletion after the original request is purged

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Follow-up to #1682. Supersedes #1757.

Rollback Plan

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

Changes to Security Controls

No changes.

Note

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

@kenchan0130 kenchan0130 changed the title azuread_directory_role_eligibility_schedule_request: fix deletion after request cleanup azuread_directory_role_eligibility_schedule_request: handle purged requests Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant