From fdda85db88c6b27f92de01fe0bb1873e45defb33 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Thu, 30 May 2024 20:38:09 +0100 Subject: [PATCH] bugfix: allow disabling review settings for `azuread_access_package_assignment_policy` --- .../access_package_assignment_policy_resource_test.go | 7 +++++++ .../services/identitygovernance/identitygovernance.go | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/internal/services/identitygovernance/access_package_assignment_policy_resource_test.go b/internal/services/identitygovernance/access_package_assignment_policy_resource_test.go index 8e1ea7c69a..0215150035 100644 --- a/internal/services/identitygovernance/access_package_assignment_policy_resource_test.go +++ b/internal/services/identitygovernance/access_package_assignment_policy_resource_test.go @@ -76,6 +76,13 @@ func TestAccAccessPackageAssignmentPolicy_update(t *testing.T) { ), }, data.ImportStep(), + { + Config: r.simple(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), { Config: r.complete(data), Check: acceptance.ComposeTestCheckFunc( diff --git a/internal/services/identitygovernance/identitygovernance.go b/internal/services/identitygovernance/identitygovernance.go index bd77c36c0b..8142de5a6c 100644 --- a/internal/services/identitygovernance/identitygovernance.go +++ b/internal/services/identitygovernance/identitygovernance.go @@ -131,6 +131,17 @@ func expandAssignmentReviewSettings(input []interface{}) (*msgraph.AssignmentRev result.Reviewers = expandUserSets(in["reviewer"].([]interface{})) + if result.AccessReviewTimeoutBehavior == "" && + (result.DurationInDays == nil || *result.DurationInDays == 0) && + (result.IsAccessRecommendationEnabled == nil || !*result.IsAccessRecommendationEnabled) && + (result.IsApprovalJustificationRequired == nil || !*result.IsApprovalJustificationRequired) && + (result.IsEnabled == nil || !*result.IsEnabled) && + result.RecurrenceType == "" && + result.ReviewerType == "" && + (result.Reviewers == nil || len(*result.Reviewers) == 0) { + return nil, nil + } + return &result, nil }