refactor(iam): extract per-service IAM strategies from compileIamRole#711
Merged
zirkelc merged 1 commit intoserverless-operations:masterfrom Mar 27, 2026
Merged
Conversation
commit: |
Collaborator
|
Thanks! Could you fix the merge conflicts? |
Replaces the 130-line switch statement in compileIamRole.js with a
registry-based Strategy pattern. Each AWS service now lives in its
own module under iamStrategies/, making it straightforward to add,
modify, or test individual service permissions in isolation.
- iamStrategies/utils.js — shared helpers (ARN builders, parameter
extraction, SQS URL parser)
- iamStrategies/index.js — registry (Map<arn, handler>) + dispatch
- iamStrategies/{service} — sqs, sns, dynamodb, redshiftData, batch,
glue, ecs, lambda, stepFunctions,
codebuild, sagemaker, bedrock,
eventbridge, http, s3, ses
compileIamRole.js drops from 1025 to ~155 lines. Tests split from
the 4,863-line monolith into 16 co-located strategy test files, each
testing its strategy function directly. compileIamRole.test.js trimmed
to ~30 orchestration tests. Total: 483 tests, all passing.
Closes serverless-operations#707
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ca862e0 to
ca39a42
Compare
Collaborator
Author
|
Rebased onto master to resolve the conflict with #712 (JSONata EventBridge Scheduler support). The fix from that commit has been applied to |
Collaborator
|
Thanks! I have to wait a bit as my user that I'm using for the release got rate-limited by GitHub. |
This was referenced Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Replaces the 130-line switch statement in
compileIamRole.jswith a registry-based Strategy pattern. Each AWS service now lives in its own module underiamStrategies/, making it straightforward to add, modify, or test individual service permissions in isolation.iamStrategies/utils.js— shared helpers (ARN builders, parameter extraction, SQS URL parser)iamStrategies/index.js— registry (Map<arn, handler>) + dispatchiamStrategies/{service}.js— sqs, sns, dynamodb, redshiftData, batch, glue, ecs, lambda, stepFunctions, codebuild, sagemaker, bedrock, eventbridge, http, s3, sescompileIamRole.jsdrops from 1,025 to ~155 lines.Tests
The monolithic 4,863-line
compileIamRole.test.jsis split into 16 co-located strategy test files, each testing its strategy function directly (no Serverless instance, no CloudFormation pipeline — justgetPermissions(state)→ check the permissions array).compileIamRole.test.jsis trimmed to ~30 orchestration tests covering role creation, state traversal, Map/Distributed Map, permissionsBoundary, iam.role.path, loggingConfig, tracingConfig, and encryptionConfig.483 tests, all passing. No behaviour change.
Closes #707
🤖 Generated with Claude Code