FIX #2356: Normalize Permission Expansion #2401
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Test Log for Issue #2356 Fix - Admin Custom Role Permission Normalization
Test Environment
Issue Summary
Issue #2356: "Okta Workflows custom roles experiencing persistent state drift"
Root Cause: When creating custom roles with workflow permissions (
okta.workflows.invokeandokta.workflows.read), the Okta API automatically returns both the original permissions AND expanded versions (okta.workflows.flows.invokeandokta.workflows.flows.read). This caused Terraform to see different permissions on each refresh, leading to continuous state drift.Fix Implementation: Added permission normalization logic in
flattenPermissions()function that preserves user's original intent by mapping expanded permissions back to the configured permissions.Fix Implementation Details
Key Changes in
resource_okta_admin_role_custom.go:Modified
flattenPermissions()function (lines 194-212):normalizePermissions()to handle API expansionAdded
normalizePermissions()function (lines 234-289):okta.workflows.read→okta.workflows.flows.readexpansionokta.workflows.invoke→okta.workflows.flows.invokeexpansionLogic:
Correct Typos in code:
Test Results
Test 1: Initial Custom Role Creation
Purpose: Create custom role with workflow permissions and verify no initial state drift
Result: ✅ SUCCESS
cr0t5snz72wYzw11V697okta.workflows.read,okta.workflows.invokeTest 2: State Drift Testing - Multiple Plan Operations
Purpose: Verify no state changes are detected across multiple plan operations
Result: ✅ SUCCESS
Test 3: State Drift Testing - Multiple Apply Operations
Purpose: Verify no state changes occur during apply operations (where the original issue manifested)
Result: ✅ SUCCESS
["okta.workflows.invoke", "okta.workflows.read"]Test 4: Role Update with Additional Permissions
Purpose: Test normalization works correctly during role updates
Configuration Change:
Result: ✅ SUCCESS
Test 5: API Permission Expansion Verification
Purpose: Confirm Okta API actually returns expanded permissions
API Call:
GET /api/v1/iam/roles/{roleId}/permissionsAPI Response Showed:
okta.users.readokta.workflows.flows.invoke(expanded version)okta.workflows.flows.read(expanded version)okta.workflows.invoke(original permission)okta.workflows.read(original permission)Analysis: ✅ CONFIRMED
okta.workflows.*have permanent drift due to undocumented permission changes #2356Test 6: Unit Test Validation
Purpose: Verify normalization logic works correctly in isolation
go test -v ./okta/services/idaas -run TestWorkflowPermissionNormalizationResult: ✅ SUCCESS
workflow_read_permission_expansionworkflow_invoke_permission_expansionboth_workflow_permissions_expansiononly_expanded_workflow_permissionsno_workflow_permissionsSummary of Findings
✅ What's Fixed:
🔧 How the Fix Works:
okta.workflows.read+okta.workflows.flows.read, causing Terraform to see changing stateokta.workflows.readconfiguration✅ Issue #2356 Status: RESOLVED
The persistent state drift issue with Okta Workflows custom roles is completely resolved. Users can now:
okta.workflows.readandokta.workflows.invokepermissionsProvider Build Information
go build -o terraform-provider-okta~/.terraform.d/plugins/local/okta/okta/5.1.0/darwin_arm64/This comprehensive test validates that issue #2356 is fully resolved with proper permission normalization while maintaining complete backward compatibility.