This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
AWS Account Operator is a Kubernetes operator that manages AWS accounts for OpenShift Dedicated clusters. It creates and maintains pools of AWS accounts, assigns them to AccountClaims, and handles AWS resource configuration including IAM, networking, and federation.
make test-all- Runs all test suites (includes lint, unit tests, and integration tests)make test- Run unit tests onlymake test-apis- Run API tests onlymake test-integration- Run integration testsmake lint- Run lintingmake build- Build the operator binarygo test ./...- Run unit tests from any directory
make test-account-creation- Test account creation flowsmake test-ccs- Test Customer Cloud Subscription (BYOC) flowsmake test-reuse- Test account reuse functionality
make predeploy- Deploy prerequisites (CRDs, namespaces, credentials)make deploy-local- Run operator locally withFORCE_DEV_MODE=localmake deploy-cluster- Deploy to cluster with development imagemake clean-operator- Clean up operator resources
Initial Setup:
- Authenticate to your assigned account:
rh-aws-saml-login <your-profile-name> - Create AccessRole in your assigned account:
./hack/scripts/aws/setup_access_role.sh -a <ACCOUNT_ID> -p <your-profile-name>
Set these environment variables for testing (in .envrc):
FORCE_DEV_MODE=local- Enable local development modeOSD_STAGING_2_AWS_ACCOUNT_ID- Your assigned osd-staging-2 account ID (not osd-staging-1)OSD_STAGING_1_OU_ROOT_IDandOSD_STAGING_1_OU_BASE_ID- Organizational Unit IDsSTS_JUMP_ROLE=arn:aws:iam::<SHARED_ACCOUNT_ID>:role/JumpRole- Shared jump role (centrally managed)STS_JUMP_ARN=arn:aws:iam::<SHARED_ACCOUNT_ID>:role/JumpRole- Same as aboveSTS_ROLE_ARN=arn:aws:iam::<YOUR_ACCOUNT_ID>:role/AccessRole- Your AccessRole ARN
Note: Credentials are now managed via temporary STS tokens using rh-aws-saml-login, stored in ~/.aws/credentials. No long-lived IAM user keys are used. Credentials expire after a few hours and need refreshing via update_aws_credentials.sh.
Controllers (in controllers/ directory):
account/- Manages AWS Account CR lifecycle, handles account setup, IAM roles, networkingaccountclaim/- Processes AccountClaim CRs, assigns accounts from poolsaccountpool/- Maintains pools of ready-to-use AWS accountsawsfederatedrole/- Manages federated IAM roles for cross-account accessawsfederatedaccountaccess/- Handles temporary access grants to federated accountsvalidation/- Validates account and pool configurations
Custom Resources (in api/v1alpha1/):
Account- Represents a single AWS account with configuration stateAccountClaim- Request for an AWS account (regular, CCS/BYOC, STS, or fake)AccountPool- Defines pools of accounts to maintainAWSFederatedRole- Cross-account IAM role definitionsAWSFederatedAccountAccess- Temporary access grants
AWS Integration (in pkg/awsclient/):
client.go- Main AWS SDK wrapper with organization operationsiam.go- IAM roles, policies, and user managementtags.go- AWS resource tagging operationssts/- STS assume role functionality
- Standard Accounts: Created and managed entirely by the operator
- CCS/BYOC (Customer Cloud Subscription): Customer-provided AWS accounts with operator setup
- STS Accounts: Use AWS STS for temporary role-based access
- Fake Accounts: For testing without real AWS resources
Account Lifecycle: AccountClaim → Account assignment from pool → AWS setup (IAM, networking, etc.) → Ready state
Reuse Logic: Accounts can be reused when claims are deleted, returning to the pool after cleanup
Dev Mode Detection: Environment variable FORCE_DEV_MODE controls testing behavior (skips support cases, etc.)
- Namespace: All resources operate in
aws-account-operatornamespace - ConfigMaps: Default configuration in
aws-account-operator-configmap - Secrets: AWS credentials stored in operator namespace
- CRDs: Located in
deploy/crds/directory
- The operator uses controller-runtime framework with reconciliation patterns
- Local development requires OpenShift cluster (CRC/Minishift supported)
- Integration tests require real AWS environment with proper IAM setup
- FIPS mode supported via build tags and configuration
- Metrics exposed on port 8080 in local mode, within cluster otherwise