refactor(iam): split long IAM ops in roles, account, and oidc#324
Merged
vieiralucas merged 1 commit intomainfrom Apr 13, 2026
Merged
refactor(iam): split long IAM ops in roles, account, and oidc#324vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
Five long IAM functions had clear logical phases buried in their bodies. - delete_role: extract ensure_role_can_be_deleted (instance profile, managed policy, inline policy guards), mirroring the same pattern delete_user uses. delete_role drops to a 4-line operation. - create_service_linked_role: the 30-line role-name derivation match (with hard-coded casing for autoscaling/elasticbeanstalk/etc and the '<prefix>.<service>' fan-out) becomes derive_service_linked_role_name. Pure function, easy to test, easy to extend with new principals. - get_account_authorization_details: the 222-line operation was four parallel XML builders for users, roles, groups, and policies. Move each into build_user_details_xml / build_role_details_xml / build_group_details_xml / build_policy_details_xml. The operation body is now 'snapshot state, build the four sections, format the envelope.' - update_account_password_policy: separate validate_password_policy_inputs (collects every constraint violation into a single multi-error ValidationError) from apply_password_policy_updates (applies provided fields onto the stored AccountPasswordPolicy). - create_oidc_provider: the URL/thumbprint/client-id validation block is now validate_oidc_provider_input — a pure function that lets the operation body focus on parsing inputs, building the ARN, and inserting the provider. No behavior change. Same lock semantics, same error wording, same XML output. The OIDC validator switches from a manual loop+break to .iter().any() which is what cargo fmt prefers.
vieiralucas
added a commit
that referenced
this pull request
Apr 13, 2026
…Input The two longest functions in the SSM sub-modules were create_patch_baseline (~150 lines) and create_association_inner (~162 lines). Both were dominated by body parsing, field validation, and field extraction — with the actual state mutation only in the last 30-40 lines. This extracts dedicated *Input structs with from_body() constructors, leaving each function focused on idempotency, ID generation, and struct assembly. Same pattern as PRs #324/#328/#338/#355/#356.
2 tasks
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
Five long IAM functions had clear logical phases buried in their bodies.
No behavior change. Same lock semantics, same error wording, same XML output. The OIDC validator switches from a manual `loop+break` to `.iter().any()` which is the more idiomatic form.
Test plan
Summary by cubic
Refactored IAM operations in
fakecloud-iamby extracting focused helpers to simplify complex functions and improve testability. No behavior changes; same locks, error messages, and XML outputs.Written for commit 96fe87a. Summary will update on new commits.