agentic-identity-broker / infra
AGENTS.md68 starsChanged 10 days agoMITView on GitHub
All paths in this file are relative to the repository root. Before you change infrastructure, read infra/cdk/stack.go and the relevant sources in this table. AWS CDK (Go SDK) provisions Token Vault encryption resources. infra/cdk/ is a separate Go module. The feature documents mark their original single-field encryption configuration as superseded. Use the current encryption.aws_kms contract, not the historical encryption.key proposal. Use the single NewEncryptionStack() function to provision: Use test, sandbox, or prod as environment values. production is an input alias.…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,700 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- internal/AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- web/AGENTS.mdAGENTS.md
- infra/CLAUDE.mdCLAUDE.md
- internal/CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- web/CLAUDE.mdCLAUDE.md
- agents-md-housekeepingSkill
- aws-crypto-goSkill
- jwx-guide-v4Skill
- simple-englishSkill
- speckit-agent-context-updateSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-git-commitSkill
- speckit-git-featureSkill
- speckit-git-initializeSkill
- speckit-git-remoteSkill
- speckit-git-validateSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- speckit-taskstoissuesSkill
- speckit-agent-context-updateSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-git-commitSkill
- speckit-git-featureSkill
- speckit-git-initializeSkill
- speckit-git-remoteSkill
- speckit-git-validateSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- speckit-taskstoissuesSkill
- agentic-workflowsSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
21 rules. About 0 are common, 7 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 3
All paths in this file are relative to the repository root.
- Very specific: line 5
Before you change infrastructure, read infra/cdk/stack.go and the relevant sources in this table.
- Very specific: line 24
Use the current encryption.aws_kms contract, not the historical encryption.key proposal.
- Very specific: line 39
Use the single NewEncryptionStack() function to provision:
- Very specific: line 51
Use test, sandbox, or prod as environment values.
- Distinctive: line 73
Do not substitute that field for IRSA.
- Distinctive: line 74
Before deployment, compare the chart's service-account annotation with the target cluster's identity integration.
- Distinctive: line 78
Use federated web identity trust through an IAM OIDC provider in all environments.
- Very specific: line 84
Keep sts:AssumeRoleWithWebIdentity, the federated provider, and the exact subject condition in the synthesized trust policy.
- Distinctive: line 85
Do not retain the temporary account-root principal from the role constructor.
- Distinctive: line 86
Do not embed deployment-system placeholders in the source.
- Very specific: line 92
Keep CreateGrant in a separate statement with kms:GrantIsForAWSResource=true.
- Very specific: line 98
Run repository recipes from the repository root.
- Very specific: line 111
All synth, diff, deploy, and destroy commands require serviceAccountSubject, oidcProviderArn, and oidcSubjectKey.
- Very specific: line 112
Read adrs/030-vendor-neutral-oidc-trust.md for this contract.
- Very specific: line 114
Use manual CDK commands for diff, deploy, and destroy.
- Distinctive: line 119
Start these manual commands from the repository root with the CDK CLI available:
- Very specific: line 145
Use the application, component, and environment tags for taggable resources.
- Very specific: line 146
Keep the environment tag equal to the normalized stack environment.
- Very specific: line 148
Keep docs/operations/deployment-checklist.md, docs/deployment/kubernetes-irsa.md, and ADR 010 current.
- Very specific: line 152
Use assertions.Template_FromStack() and createTestStack() in infra/cdk/stack_test.go to examine synthesized CloudFormation.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.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.
Files
Infrastructure — AWS CDK (infra/)
All paths in this file are relative to the repository root.
Before you change infrastructure, read infra/cdk/stack.go and the relevant sources in this table.
Overview
AWS CDK (Go SDK) provisions Token Vault encryption resources. infra/cdk/ is a separate Go module.
| Source | Purpose |
ARCHITECTURE.md, .specify/memory/constitution.md | Infrastructure boundary, security requirements, and workload configuration rules |
adrs/010-cdk-encryption-infrastructure.md | Accepted CDK resource design |
adrs/030-vendor-neutral-oidc-trust.md | Accepted trust inputs for every environment |
adrs/009-envelope-encryption-design.md | Accepted envelope encryption design |
specs/012-aws-encryption-vault/spec.md, specs/012-aws-encryption-vault/plan.md, specs/012-aws-encryption-vault/tasks.md | Encryption requirements and implementation history |
internal/ports/config.go, internal/adapters/encryption/aws/config.go | Current application configuration and AWS credential selection |
docs/configuration.md | Current configuration reference |
docs/operations/deployment-checklist.md, docs/deployment/kubernetes-irsa.md | Deployment procedures and trust inputs |
charts/agentic-identity-broker/templates/serviceaccount.yaml | Helm service-account annotation |
The feature documents mark their original single-field encryption configuration as superseded.
Use the current encryption.aws_kms contract, not the historical encryption.key proposal.
Module Structure
| Path | Purpose |
infra/cdk/main.go | Context inputs, environment validation, AWS account and region, and stack creation |
infra/cdk/stack.go | Resources, trust policy, permissions, outputs, and tags |
infra/cdk/stack_test.go | Synthesized CloudFormation assertions and test helpers |
infra/cdk/go.mod | Separate Go toolchain and dependency versions |
infra/cdk/cdk.json | CDK application command and default context |
justfile | Supported repository commands |
EncryptionStack Resources
Use the single NewEncryptionStack() function to provision:
| Resource | Type | Purpose |
| KMS CMK | AWS::KMS::Key | Symmetric KEK for hierarchical keyring. Annual rotation enabled. Alias: alias/agentic-identity-broker/{env}/token-vault-kek |
| DynamoDB Table | AWS::DynamoDB::Table | Branch-key cache with branch-key-id and type keys |
| IAM Role | AWS::IAM::Role | Least-privilege KMS + DynamoDB access via IRSA. Name: AgenticIdentityBrokerEncryptionRole-{env} |
| CloudWatch Alarms | AWS::CloudWatch::Alarm | KMS throttle + error detection |
| CloudWatch Dashboard | AWS::CloudWatch::Dashboard | KMS API ops + DynamoDB cache metrics |
Environment Parameterization
Use test, sandbox, or prod as environment values. production is an input alias.
The CDK application changes it to prod before it names resources or chooses policies.
| Aspect | Production | Non-Production |
| KMS and DynamoDB RemovalPolicy | RETAIN | DESTROY |
| KMS PendingDeletion | 30 days | 7 days |
| DynamoDB PITR | Enabled | Disabled |
| DynamoDB DeletionProtection | On | Off |
| IRSA parameters | Required | Required |
Stack Outputs and Application Configuration
| Stack Output | Consumer |
EncryptionKeyARN | IDENTITY_BROKER_ENCRYPTION_AWS_KMS_KEY_ARN |
BranchKeyTableName | IDENTITY_BROKER_ENCRYPTION_AWS_KMS_DYNAMODB_TABLE_NAME |
EncryptionRoleARN | Helm serviceAccount.irsa.role for workload identity |
IDENTITY_BROKER_ENCRYPTION_IAM_ROLE_ARN is not a field in the current application configuration.
ADR 010 still lists this historical mapping.
The separate encryption.aws_kms.assume_role_arn field uses STS AssumeRole, not the stack's web-identity trust.
Do not substitute that field for IRSA.
Before deployment, compare the chart's service-account annotation with the target cluster's identity integration.
IRSA (IAM Roles for Service Accounts)
Use federated web identity trust through an IAM OIDC provider in all environments. Set these props:
ServiceAccountSubject— Kubernetes service account subject claim (system:serviceaccount:<namespace>:<sa-name>)OIDCProviderArn— full OIDC provider ARNOIDCSubjectKey— IAM condition key for the subject claim (<oidc-provider-host>:sub)
Keep sts:AssumeRoleWithWebIdentity, the federated provider, and the exact subject condition in the synthesized trust policy.
Do not retain the temporary account-root principal from the role constructor.
Do not embed deployment-system placeholders in the source.
IAM Permissions (Least Privilege)
KMS: Encrypt, Decrypt, GenerateDataKey, GenerateDataKeyWithoutPlaintext, ReEncryptFrom, ReEncryptTo, DescribeKey, CreateGrant.
Scope these permissions to the stack's KMS key.
Keep CreateGrant in a separate statement with kms:GrantIsForAWSResource=true.
DynamoDB: GetItem, PutItem, Query, UpdateItem, DeleteItem, and DescribeTable. Apply permissions only to the branch-key table.
Development Commands
Run repository recipes from the repository root.
just cdk-deps runs go mod tidy and go mod download in the separate module.
The Go CDK application also requires Node.js for jsii.
just cdk-deps # Install dependencies for the separate CDK module
just cdk-test # Run CDK unit tests
just cdk-synth test \
'-c serviceAccountSubject=...' \
'-c oidcProviderArn=...' \
'-c oidcSubjectKey=...' # Synthesize CloudFormationAll synth, diff, deploy, and destroy commands require serviceAccountSubject, oidcProviderArn, and oidcSubjectKey.
Read adrs/030-vendor-neutral-oidc-trust.md for this contract.
Use manual CDK commands for diff, deploy, and destroy. The justfile has no recipes for these operations.
Replace the example trust inputs with the target provider and service account.
Review the diff before deployment.
CAUTION: Delete only the intended stack. Non-production removal policies delete the branch-key table and schedule KMS key deletion.
Start these manual commands from the repository root with the CDK CLI available:
cd infra/cdk
cdk synth -c env=test \
-c serviceAccountSubject=system:serviceaccount:identity-broker:agentic-identity-broker \
-c oidcProviderArn=arn:aws:iam::ACCOUNT:oidc-provider/... \
-c oidcSubjectKey=oidc.eks.eu-central-1.amazonaws.com/id/EXAMPLE:sub
cdk diff -c env=test \
-c serviceAccountSubject=system:serviceaccount:identity-broker:agentic-identity-broker \
-c oidcProviderArn=arn:aws:iam::ACCOUNT:oidc-provider/... \
-c oidcSubjectKey=oidc.eks.eu-central-1.amazonaws.com/id/EXAMPLE:sub
cdk deploy -c env=prod \
-c serviceAccountSubject=system:serviceaccount:identity-broker:agentic-identity-broker \
-c oidcProviderArn=arn:aws:iam::ACCOUNT:oidc-provider/... \
-c oidcSubjectKey=oidc.eks.eu-central-1.amazonaws.com/id/EXAMPLE:sub
cdk destroy -c env=test \
-c serviceAccountSubject=system:serviceaccount:identity-broker:agentic-identity-broker \
-c oidcProviderArn=arn:aws:iam::ACCOUNT:oidc-provider/... \
-c oidcSubjectKey=oidc.eks.eu-central-1.amazonaws.com/id/EXAMPLE:sub # Tear down a non-production stackAlignment Rules
- Make stack resources match the
internal/adapters/encryption/aws/configuration and stack outputs. - Make the DynamoDB schema match the AWS Encryption SDK KeyStore:
branch-key-id(S) andtype(S). - Use the
application,component, andenvironmenttags for taggable resources. UseEncryptionStackProps.Tagsfor overrides or additions. - Keep the
environmenttag equal to the normalized stack environment. - Preserve the template metadata header (
StackNameandTags) that deployment tooling expects. - Keep
docs/operations/deployment-checklist.md,docs/deployment/kubernetes-irsa.md, and ADR 010 current.
Testing
Use assertions.Template_FromStack() and createTestStack() in infra/cdk/stack_test.go to examine synthesized CloudFormation.
Cover these areas:
- KMS key properties (symmetric, rotation, removal policy, pending window).
- DynamoDB schema, billing, PITR, and deletion protection.
- IAM role trust policy (IRSA conditions) and permission statements.
- Stack outputs, export names, and template metadata.
- Tag propagation.
- Environment behavior for test, sandbox, prod, and the production alias.
- Required IRSA configuration and rejection of missing trust inputs.
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
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.

