Agent skill
af-provision-infrastructure
Provision AWS infrastructure and manage cloud credentials for projects. Use when working with Route53, CloudFront, S3 buckets, DNS/domains, or Doppler secrets management.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/af-provision-infrastructure
SKILL.md
Environment & Infrastructure
Directive knowledge for AWS infrastructure, credentials, DNS, and Doppler operations across GainInsight projects.
When to Use This Skill
Load this skill when you need to:
- Access AWS credentials or assume roles
- Create/modify DNS records or subdomains
- Set up CloudFront distributions or S3 buckets
- Configure Doppler secrets
- Work with Route53 hosted zones
- Understand cross-account credential patterns
Quick Reference
Domain Admin Credentials
| Item | Location |
|---|---|
| Doppler project/config | gi / prd |
| Access key variable | DOMAIN_ADMIN_AWS_ACCESS_KEY_ID |
| Secret key variable | DOMAIN_ADMIN_AWS_SECRET_ACCESS_KEY |
| Parent zone (gaininsight.global) | Z08261483JJZ016GFVDDQ |
Usage pattern:
doppler run --project gi --config prd -- bash -c '
AWS_ACCESS_KEY_ID=$DOMAIN_ADMIN_AWS_ACCESS_KEY_ID \
AWS_SECRET_ACCESS_KEY=$DOMAIN_ADMIN_AWS_SECRET_ACCESS_KEY \
AWS_DEFAULT_REGION=eu-west-2 \
aws route53 <command>'
Project Registry
| Item | Location |
|---|---|
| Registry | project-registry CLI |
| Query command | project-registry <project> [field] |
| Update command | project-registry set <project> <field> <value> |
project-registry juncan aws # Show AWS accounts
project-registry list # All project keys
project-registry find-by-team JKN # Find project by Linear team key
Doppler Config Mapping
| Environment | Doppler Config | Typical Use |
|---|---|---|
| Development | dev |
Local development, sandboxes |
| Staging/Test | stg |
Test environment, CI/CD |
| Production | prd |
Production environment |
Rules
Credential Rules (MUST)
-
MUST use Doppler for all secrets. No
.envfiles, no hardcoded credentials. -
MUST use domain admin credentials for Route53 changes. Project-level IAM users typically lack Route53 permissions.
-
MUST assume OrganizationAccountAccessRole for cross-account admin operations when project IAM user lacks permissions:
bashCREDS=$(doppler run --project gi --config prd -- aws sts assume-role \ --role-arn arn:aws:iam::{account-id}:role/OrganizationAccountAccessRole \ --role-session-name admin-operation --output json) -
MUST store new credentials in Doppler immediately after creation. Never leave credentials in terminal history or temp files.
DNS Rules (MUST)
-
MUST create subdomain hosted zones for new projects, not records in parent zone.
-
MUST add NS delegation records from parent zone to subdomain zone after creation.
-
MUST use ACM certificates in us-east-1 for CloudFront custom domains (CloudFront requirement).
Infrastructure Rules (SHOULD)
-
SHOULD check project registry before creating new resources - the account/config mapping may already exist.
-
SHOULD use CloudFront for public S3 content with custom domains (not S3 website URLs).
-
SHOULD prefer S3 website endpoint as custom origin over OAC when bucket is already public (simpler, no policy changes needed).
Workflows
Workflow: Add Custom Subdomain with CloudFront
When: You need something.project.gaininsight.global pointing to an S3 bucket or other origin.
Steps:
-
Request ACM certificate in us-east-1:
bashdoppler run --project {project} --config stg -- aws acm request-certificate \ --domain-name {subdomain}.{project}.gaininsight.global \ --validation-method DNS \ --region us-east-1 -
Get validation CNAME from certificate:
bashdoppler run --project {project} --config stg -- aws acm describe-certificate \ --certificate-arn {arn} --region us-east-1 \ --query "Certificate.DomainValidationOptions[0].ResourceRecord" -
Add validation record using domain admin credentials:
bashdoppler run --project gi --config prd -- bash -c ' AWS_ACCESS_KEY_ID=$DOMAIN_ADMIN_AWS_ACCESS_KEY_ID \ AWS_SECRET_ACCESS_KEY=$DOMAIN_ADMIN_AWS_SECRET_ACCESS_KEY \ aws route53 change-resource-record-sets \ --hosted-zone-id {project-zone-id} \ --change-batch '"'"'{"Changes":[{"Action":"CREATE","ResourceRecordSet":{...}}]}'"'"'' -
Wait for certificate validation (2-5 minutes)
-
Create CloudFront distribution with certificate and custom domain alias
-
Add CNAME record pointing subdomain to CloudFront domain
Workflow: Create New Project Subdomain Zone
When: Setting up a new project that needs *.project.gaininsight.global
Steps:
-
Create hosted zone:
bashdoppler run --project gi --config prd -- bash -c ' AWS_ACCESS_KEY_ID=$DOMAIN_ADMIN_AWS_ACCESS_KEY_ID \ AWS_SECRET_ACCESS_KEY=$DOMAIN_ADMIN_AWS_SECRET_ACCESS_KEY \ aws route53 create-hosted-zone \ --name {project}.gaininsight.global \ --caller-reference "{project}-$(date +%s)"' -
Note the 4 nameservers from the response
-
Add NS delegation to parent zone (Z08261483JJZ016GFVDDQ):
bash# Add NS record with the 4 nameservers -
Store zone ID in project documentation (CLAUDE.md)
Workflow: Access Another Account's Resources
When: You need admin access that the project IAM user doesn't have.
Steps:
-
Assume OrganizationAccountAccessRole:
bashCREDS=$(doppler run --project gi --config prd -- aws sts assume-role \ --role-arn arn:aws:iam::{account-id}:role/OrganizationAccountAccessRole \ --role-session-name {operation-name} --output json) export AWS_ACCESS_KEY_ID=$(echo $CREDS | jq -r '.Credentials.AccessKeyId') export AWS_SECRET_ACCESS_KEY=$(echo $CREDS | jq -r '.Credentials.SecretAccessKey') export AWS_SESSION_TOKEN=$(echo $CREDS | jq -r '.Credentials.SessionToken') -
Run commands with elevated permissions
-
Unset credentials when done:
bashunset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
Common Pitfalls
| Problem | Cause | Solution |
|---|---|---|
| "AccessDenied" on Route53 | Using project IAM user | Use domain admin credentials |
| "AccessDenied" on bucket policy | Project user lacks s3:PutBucketPolicy | Assume OrganizationAccountAccessRole |
| ACM cert stuck pending | Validation record not added | Add CNAME to correct hosted zone |
| CloudFront 403 errors | S3 bucket policy missing | Add CloudFront service principal or use website endpoint |
| "Certificate not in us-east-1" | ACM cert in wrong region | Request new cert in us-east-1 |
Essential Reading
Procedural Guides
| Guide | Purpose |
|---|---|
| Layer 1: Infrastructure | Complete AWS setup walkthrough |
| GiDev Server Docs | Server-specific operations |
Key Files
| File | Contains |
|---|---|
project-registry CLI |
All project AWS accounts, Doppler configs |
/srv/docs/CREDENTIALS.md |
Credential management patterns |
/srv/docs/ADMIN.md |
Server administration including Cloudflare |
Remember:
- Domain admin creds are in
gi/prdDoppler - ACM certs for CloudFront must be in us-east-1
- Check project registry before creating resources
- Use OrganizationAccountAccessRole for admin operations
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?