Skip to content

feat: add IAM service with all 60 operations#14

Merged
tyrchen merged 3 commits intomasterfrom
feat/iam-service
Mar 20, 2026
Merged

feat: add IAM service with all 60 operations#14
tyrchen merged 3 commits intomasterfrom
feat/iam-service

Conversation

@tyrchen
Copy link
Owner

@tyrchen tyrchen commented Mar 20, 2026

Summary

  • Add AWS IAM (Identity and Access Management) support to RustStack with ~60 operations across 4 phases
  • Uses Smithy codegen for model types (awsQuery protocol, same as SNS)
  • Gateway routing via SigV4 credential scope (service=iam)
  • In-memory storage with 6 DashMap entity stores (users, roles, groups, policies, instance profiles, access keys)
  • IAM is a global service (no region in ARNs)

Phase 0 - Core CRUD (~25 operations)

  • User/Role/Policy CRUD (Create/Get/Delete/List/Update)
  • Policy attachment (Attach/Detach/ListAttached for users and roles)
  • Access key management (Create/Delete/List/Update/GetLastUsed)

Phase 1 - Groups + Instance Profiles (~17 operations)

  • Group CRUD and membership (AddUserToGroup, RemoveUserFromGroup, ListGroupsForUser)
  • Group policy attachment (AttachGroupPolicy, DetachGroupPolicy, ListAttachedGroupPolicies)
  • Instance profile management (Create/Get/Delete/List, AddRoleToInstanceProfile, RemoveRoleFromInstanceProfile)

Phase 2 - Policy Versions + Inline Policies (~17 operations)

  • Managed policy versioning (Create/Get/Delete/List/SetDefault PolicyVersion)
  • Inline policies for users, roles, and groups (Put/Get/Delete/List)

Phase 3 - Advanced (~12 operations)

  • Tag management (TagUser/UntagUser/ListUserTags, TagRole/UntagRole/ListRoleTags)
  • Service-linked roles (Create/Delete/GetDeletionStatus)
  • UpdateAssumeRolePolicy
  • SimulatePrincipalPolicy/SimulateCustomPolicy (stubs returning all allowed)
  • ListEntitiesForPolicy, GetAccountAuthorizationDetails

Architecture

  • 3 new crates: ruststack-iam-model (codegen), ruststack-iam-http (protocol), ruststack-iam-core (business logic)
  • Concurrency safe: Uses DashMap entry API for atomic create operations, careful lock ordering to prevent deadlocks
  • 56 unit tests + 15 integration tests + comprehensive CI workflow with AWS CLI smoke tests

Test plan

  • cargo build succeeds
  • cargo test -p ruststack-iam-model -p ruststack-iam-core -p ruststack-iam-http (56 tests pass)
  • cargo clippy --all-targets --all-features -- -D warnings (clean)
  • cargo +nightly fmt (clean)
  • CI workflow (iam-test.yml) runs all 4 phases with AWS CLI
  • Rust integration tests pass against running server

🤖 Generated with Claude Code

tyrchen and others added 3 commits March 20, 2026 00:15
Add AWS IAM (Identity and Access Management) support to RustStack with
~60 operations across 4 phases covering users, roles, groups, policies,
instance profiles, access keys, tagging, and service-linked roles.

Phase 0 - Core CRUD (~25 operations):
- User/Role/Policy CRUD (Create/Get/Delete/List/Update)
- Policy attachment (Attach/Detach/ListAttached for users and roles)
- Access key management (Create/Delete/List/Update/GetLastUsed)

Phase 1 - Groups + Instance Profiles (~17 operations):
- Group CRUD and membership (AddUserToGroup, RemoveUserFromGroup)
- Group policy attachment
- Instance profile CRUD (Create/Get/Delete/List)
- Role-to-instance-profile management

Phase 2 - Policy Versions + Inline Policies (~17 operations):
- Managed policy versioning (Create/Get/Delete/List/SetDefault)
- Inline policies for users, roles, and groups (Put/Get/Delete/List)

Phase 3 - Advanced (~12 operations):
- Tag management for users and roles
- Service-linked roles (Create/Delete/GetDeletionStatus)
- UpdateAssumeRolePolicy
- SimulatePrincipalPolicy/SimulateCustomPolicy (stubs)
- ListEntitiesForPolicy, GetAccountAuthorizationDetails

Architecture:
- Uses Smithy codegen for model types (ruststack-iam-model)
- awsQuery protocol (same as SNS) with XML responses
- Gateway routing via SigV4 credential scope (service=iam)
- In-memory storage with DashMap (6 entity stores)
- IAM is a global service (no region in ARNs)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix critical and high-severity issues found during code review:

- Use DashMap::entry() API for atomic check-and-insert in all create
  operations (create_user, create_role, create_policy, etc.) to prevent
  TOCTOU race conditions
- Fix potential deadlocks in attach/detach operations by dropping entity
  guards before acquiring policy locks
- Clone data out of DashMap guards before querying other maps in
  list_attached_*_policies, get_group, and list_groups_for_user
- Fix nested lock patterns in get_account_authorization_details by
  pre-fetching all needed data before XML generation
- Fix delete_user/delete_role to drop guards before checking other maps
- Fix tag_user/tag_role to validate tag limits BEFORE applying mutations
- Add pagination support to list_entities_for_policy
- Change write_instance_profile_xml to accept pre-fetched role data
  instead of acquiring nested DashMap locks
- Replace expect() with unwrap_or_else() in response builders

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add comprehensive CI workflow testing all 4 IAM phases with AWS CLI:
- Phase 0: User/Role/Policy CRUD, access keys, delete conflicts
- Phase 1: Groups, membership, instance profiles
- Phase 2: Inline policies, policy versions
- Phase 3: Tags, service-linked roles, UpdateAssumeRolePolicy
- Rust integration tests (aws-sdk-iam)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tyrchen tyrchen merged commit 754767b into master Mar 20, 2026
18 checks passed
@tyrchen tyrchen deleted the feat/iam-service branch March 20, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant