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

[Bug fix] - azurerm_pim_active_role_assignment and azurerm_pim_eligible_role_assignment - Filter role assignment on scope #24077

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"regexp"
"strconv"
"strings"
"time"

// nolint: staticcheck
Expand Down Expand Up @@ -180,7 +181,8 @@ func (r PimActiveRoleAssignmentResource) Create() sdk.ResourceFunc {
return fmt.Errorf("listing role assignments on scope %s: %+v", id, err)
}
for _, item := range items.Items {
if *item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect {
if *item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, id.Scope) {
return metadata.ResourceRequiresImport(r.ResourceType(), id)
}
}
Expand Down Expand Up @@ -262,8 +264,10 @@ func (r PimActiveRoleAssignmentResource) Read() sdk.ResourceFunc {
}
var instance *roleassignmentscheduleinstances.RoleAssignmentScheduleInstance
for _, item := range items.Items {
if *item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect {
if *item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, id.Scope) {
instance = &item
break
}
}
if instance == nil {
Expand Down Expand Up @@ -629,9 +633,11 @@ func waitForActiveRoleAssignment(ctx context.Context, client *roleassignmentsche

for _, item := range items.Items {
if *item.Properties.RoleDefinitionId == roleDefinitionId &&
*item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect {
*item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, scope) {
state = "Found"
result = item
break
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"regexp"
"strconv"
"strings"
"time"

// nolint: staticcheck
Expand Down Expand Up @@ -180,7 +181,8 @@ func (r PimEligibleRoleAssignmentResource) Create() sdk.ResourceFunc {
return fmt.Errorf("listing role assignments on scope %s: %+v", id, err)
}
for _, item := range items.Items {
if *item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect {
if *item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, id.Scope) {
return metadata.ResourceRequiresImport(r.ResourceType(), id)
}
}
Expand Down Expand Up @@ -262,8 +264,10 @@ func (r PimEligibleRoleAssignmentResource) Read() sdk.ResourceFunc {
}
var instance *roleeligibilityscheduleinstances.RoleEligibilityScheduleInstance
for _, item := range items.Items {
if *item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect {
if *item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, id.Scope) {
instance = &item
break
}
}
if instance == nil {
Expand Down Expand Up @@ -629,9 +633,11 @@ func waitForEligibleRoleAssignmentSchedule(ctx context.Context, client *roleelig

for _, item := range items.Items {
if *item.Properties.RoleDefinitionId == roleDefinitionId &&
*item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect {
*item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, scope) {
state = "Found"
result = item
break
}
}

Expand Down
Loading