agentleFS
PostHogKnown publisherPostHog/terraform-aws-sso-elevator/CLAUDE.md

terraform-aws-sso-elevator

CLAUDE.md1 starsChanged 31 days agoApache-2.0View on GitHub

Always run these commands before committing changes: Terraform module that deploys AWS Lambda functions for just-in-time AWS SSO access management via Slack. Two access models exist: account access (temporary permission set assignment on AWS accounts) and group access (temporary SSO group membership). Config & Models: - config.py — Loads config from S3 (load_approval_config_from_s3), parses into Statement/GroupStatement via parse_statement/parse_group_statement. Config is a Pydantic BaseSettings singleton with frozenset fields for statements, accounts, groups, permission_sets. - statement.py — BaseStatement (has permission_set, required_group_membership, etc.)…

The file

We split this CLAUDE.md into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always run these commands before committing changes:

    line 5

≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Claude Code Instructions

Before Committing

Always run these commands before committing changes:

# Run type checking
cd src && uv run pyright .

# Run tests
cd src && uv run pytest -q

# Run all pre-commit hooks (linting, formatting, terraform docs, etc.)
uv run --directory src --extra dev pre-commit run --all-files

Running Tests

cd src && uv run pytest -q

Architecture Overview

Terraform module that deploys AWS Lambda functions for just-in-time AWS SSO access management via Slack. Two access models exist: account access (temporary permission set assignment on AWS accounts) and group access (temporary SSO group membership).

Terraform Layer

  • vars.tf — Module inputs. Two separate config variables: config (account access statements) and group_config (group access statements), both type = any.
  • s3.tf — Serializes both to a single S3 object as {"statements": var.config, "group_statements": var.group_config}.
  • locals.tf — Validation logic (group/attribute-sync overlap checks, extracting group names from group_config).
  • slack_handler_lambda.tf / perm_revoker_lambda.tf — Lambda function definitions. Both read config from the same S3 object.

Python Layer (src/)

Config & Models:

  • config.py — Loads config from S3 (load_approval_config_from_s3), parses into Statement/GroupStatement via parse_statement/parse_group_statement. Config is a Pydantic BaseSettings singleton with frozenset fields for statements, accounts, groups, permission_sets.
  • statement.py — BaseStatement (has permission_set, required_group_membership, etc.) → Statement (account access). GroupStatement is separate (does not inherit BaseStatement, lacks permission_set and required_group_membership). Eligibility filtering (get_eligible_statements_for_user) currently only applies to Statement, not GroupStatement.
  • events.py — RevokeEvent/GroupRevokeEvent and their Scheduled* wrappers. Tagged union via action field literal types.
  • entities/ — Pydantic models for AWS resources (Account, PermissionSet, SSOGroup) and Slack users.

Request Flow (Slack → Decision → Execution):

  • main.py — Slack bolt app. Handles account access shortcuts, modal interactions, button clicks. Registers handlers via app.shortcut(), app.view(), app.action(). The handle_button_click function falls through to group.handle_group_button_click on parse failure.
  • group.py — Parallel handlers for group access shortcuts, submission, and button clicks.
  • slack_helpers.py — View builders (RequestForAccessView, RequestForGroupAccessView), payload parsers (ButtonClickedPayload, ButtonGroupClickedPayload), message block builders. Modal uses dynamic view updates: accounts load first, then permission sets update on account selection via dispatch_action=True.
  • access_control.py — Decision logic (make_decision_on_access_request, make_decision_on_approve_request) is already unified for both Statement and GroupStatement. Execution is split: execute_decision (account) vs execute_decision_on_group_request (group).

Revocation & Scheduling:

  • schedule.py — schedule_revoke_event/schedule_group_revoke_event create EventBridge schedules that fire the revoker Lambda.
  • revoker.py — Handles scheduled revocations, early revocations, inconsistency checks, extend-grant button posting. Parallel functions for account and group flows.

SSO Operations:

  • sso.py — AWS SSO/Identity Store API calls. Account operations (create/delete assignment) and group operations (add/remove membership) are fundamentally different APIs. User lookup (get_user_principal_id_by_email) is shared.

Attribute Sync (separate feature):

  • attribute_syncer.py, attribute_mapper.py, sync_state.py, sync_config.py, sync_notifications.py — Automatic user-to-group sync based on Identity Store attributes. Runs on its own Lambda/schedule.

Key Design Patterns

  • Config uses two separate Terraform variables (config and group_config) that map directly to statements and group_statements in the S3 JSON. Python reads these as separate lists.
  • Pydantic models use frozen=True (ConfigDict(frozen=True) in entities/model.py). Extra fields are silently ignored (default Pydantic v2 behavior, no extra="forbid").
  • parse_group_statement manually extracts keys from the raw dict (doesn't pass the whole dict to Pydantic), so extra keys like ResourceType in the S3 JSON are harmlessly ignored.
  • Decision logic is unified in access_control.py — same make_decision_on_access_request handles both FrozenSet[Statement] and FrozenSet[GroupStatement].
  • Execution logic is deliberately split — account and group execution have different SSO API calls, audit fields, and scheduling.
  • Tests use Hypothesis (src/tests/strategies.py) for property-based testing of statement parsing alongside standard pytest.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.