agentleFS
zalando-incubatorzalando-incubator/agentic-identity-broker/infra/AGENTS.md

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.…

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
  1. Distinctive:

    All paths in this file are relative to the repository root.

    line 3
  2. Very specific:

    Before you change infrastructure, read infra/cdk/stack.go and the relevant sources in this table.

    line 5
  3. Very specific:

    Use the current encryption.aws_kms contract, not the historical encryption.key proposal.

    line 24
  4. Very specific:

    Use the single NewEncryptionStack() function to provision:

    line 39
  5. Very specific:

    Use test, sandbox, or prod as environment values.

    line 51
  6. Distinctive:

    Do not substitute that field for IRSA.

    line 73
  7. Distinctive:

    Before deployment, compare the chart's service-account annotation with the target cluster's identity integration.

    line 74
  8. Distinctive:

    Use federated web identity trust through an IAM OIDC provider in all environments.

    line 78
  9. Very specific:

    Keep sts:AssumeRoleWithWebIdentity, the federated provider, and the exact subject condition in the synthesized trust policy.

    line 84
  10. Distinctive:

    Do not retain the temporary account-root principal from the role constructor.

    line 85
  11. Distinctive:

    Do not embed deployment-system placeholders in the source.

    line 86
  12. Very specific:

    Keep CreateGrant in a separate statement with kms:GrantIsForAWSResource=true.

    line 92
  13. Very specific:

    Run repository recipes from the repository root.

    line 98
  14. Very specific:

    All synth, diff, deploy, and destroy commands require serviceAccountSubject, oidcProviderArn, and oidcSubjectKey.

    line 111
  15. Very specific:

    Read adrs/030-vendor-neutral-oidc-trust.md for this contract.

    line 112
  16. Very specific:

    Use manual CDK commands for diff, deploy, and destroy.

    line 114
  17. Distinctive:

    Start these manual commands from the repository root with the CDK CLI available:

    line 119
  18. Very specific:

    Use the application, component, and environment tags for taggable resources.

    line 145
  19. Very specific:

    Keep the environment tag equal to the normalized stack environment.

    line 146
  20. Very specific:

    Keep docs/operations/deployment-checklist.md, docs/deployment/kubernetes-irsa.md, and ADR 010 current.

    line 148
  21. Very specific:

    Use assertions.Template_FromStack() and createTestStack() in infra/cdk/stack_test.go to examine synthesized CloudFormation.

    line 152

≈ “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.

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

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.

SourcePurpose
ARCHITECTURE.md, .specify/memory/constitution.mdInfrastructure boundary, security requirements, and workload configuration rules
adrs/010-cdk-encryption-infrastructure.mdAccepted CDK resource design
adrs/030-vendor-neutral-oidc-trust.mdAccepted trust inputs for every environment
adrs/009-envelope-encryption-design.mdAccepted envelope encryption design
specs/012-aws-encryption-vault/spec.md, specs/012-aws-encryption-vault/plan.md, specs/012-aws-encryption-vault/tasks.mdEncryption requirements and implementation history
internal/ports/config.go, internal/adapters/encryption/aws/config.goCurrent application configuration and AWS credential selection
docs/configuration.mdCurrent configuration reference
docs/operations/deployment-checklist.md, docs/deployment/kubernetes-irsa.mdDeployment procedures and trust inputs
charts/agentic-identity-broker/templates/serviceaccount.yamlHelm 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

PathPurpose
infra/cdk/main.goContext inputs, environment validation, AWS account and region, and stack creation
infra/cdk/stack.goResources, trust policy, permissions, outputs, and tags
infra/cdk/stack_test.goSynthesized CloudFormation assertions and test helpers
infra/cdk/go.modSeparate Go toolchain and dependency versions
infra/cdk/cdk.jsonCDK application command and default context
justfileSupported repository commands

EncryptionStack Resources

Use the single NewEncryptionStack() function to provision:

ResourceTypePurpose
KMS CMKAWS::KMS::KeySymmetric KEK for hierarchical keyring. Annual rotation enabled. Alias: alias/agentic-identity-broker/{env}/token-vault-kek
DynamoDB TableAWS::DynamoDB::TableBranch-key cache with branch-key-id and type keys
IAM RoleAWS::IAM::RoleLeast-privilege KMS + DynamoDB access via IRSA. Name: AgenticIdentityBrokerEncryptionRole-{env}
CloudWatch AlarmsAWS::CloudWatch::AlarmKMS throttle + error detection
CloudWatch DashboardAWS::CloudWatch::DashboardKMS 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.

AspectProductionNon-Production
KMS and DynamoDB RemovalPolicyRETAINDESTROY
KMS PendingDeletion30 days7 days
DynamoDB PITREnabledDisabled
DynamoDB DeletionProtectionOnOff
IRSA parametersRequiredRequired

Stack Outputs and Application Configuration

Stack OutputConsumer
EncryptionKeyARNIDENTITY_BROKER_ENCRYPTION_AWS_KMS_KEY_ARN
BranchKeyTableNameIDENTITY_BROKER_ENCRYPTION_AWS_KMS_DYNAMODB_TABLE_NAME
EncryptionRoleARNHelm 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 ARN
  • OIDCSubjectKey — 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 CloudFormation

All 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 stack

Alignment 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) and type (S).
  • Use the application, component, and environment tags for taggable resources. Use EncryptionStackProps.Tags for overrides or additions.
  • Keep the environment tag equal to the normalized stack environment.
  • Preserve the template metadata header (StackName and Tags) 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.

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.