claude-platform-on-aws
Skill443 starsChanged 3 months agoMIT-0View on GitHub
Convert Anthropic 1P (direct API) code samples to Claude Platform on AWS (CPOA). Use when migrating from api.anthropic.com to aws-external-anthropic.{region}.api.aws, converting auth to IAM SigV4 or CPOA API key, adding workspace headers, adapting self-hosted sandbox workers for CPOA, or when someone asks about differences between Anthropic 1P and CPOA authentication/endpoints. Triggers on phrases like "convert to CPOA", "migrate to Claude Platform on AWS", "CPOA auth", "workspace header", "aws-external-anthropic", "SigV4 anthropic".
- Installs packages
In this repository3 other files it gives its agents.
- advanced-claude-code-patterns/CLAUDE.mdCLAUDE.md
- claude-apps-gateway/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is 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.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 61
Use the EnvironmentWorker SDK helper (from anthropic.lib.environments) or call GET /v1/environments/{id}/work/poll directly
- Distinctive: line 75
No long-lived secrets — IAM creds rotate hourly via STS
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill 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
Claude Platform on AWS — Migration Skill
Convert Anthropic 1P API code to Claude Platform on AWS (CPOA).
Key Differences: 1P vs CPOA
| Aspect | Anthropic 1P | CPOA |
| Base URL | https://api.anthropic.com | https://aws-external-anthropic.{region}.api.aws |
| Auth | API key (sk-ant-api03-...) in x-api-key header | IAM SigV4 OR CPOA API key (generated in AWS Console) |
| Required headers | x-api-key, anthropic-version | anthropic-workspace-id (handled by platform SDK clients) |
| SDK client | Anthropic | AnthropicAWS (Python) / AnthropicAws (TypeScript) |
| Billing | Anthropic billing | AWS Marketplace |
| Inference | Anthropic infra | Anthropic infra (same — CPOA only changes auth/billing layer) |
| Env keys (self-hosted workers) | sk-ant-oat01-... (from Claude Console) | NOT used — workers authenticate via IAM or CPOA API key |
| VPC access | Direct HTTPS to api.anthropic.com | PrivateLink available (VPC→AWS hop only; inference still on Anthropic) |
| Credential rotation | Manual API key management | Automatic via STS (IAM mode) |
Conversion Steps
1. Identify Auth Mode
CPOA supports two auth modes:
- IAM SigV4 (preferred for production): Uses execution role credentials via standard AWS provider chain. No secrets to manage.
- API key (dev/quick-start): Generated in AWS Console under Claude Platform on AWS → API keys. Short-term tokens generated from AWS credentials default to 12 hours (capped at the lesser of requested duration, AWS credentials' expiry, and 12 hours).
2. Install the Platform SDK
The platform-specific SDK client handles SigV4 signing, base URL construction, and the anthropic-workspace-id header automatically.
# Python
pip install -U "anthropic[aws]"
# TypeScript
npm install @anthropic-ai/aws-sdk3. Convert Client Initialization
See references/code-patterns.md for language-specific conversion patterns (Python, Node.js, curl).
The platform client reads AWS_REGION and ANTHROPIC_AWS_WORKSPACE_ID from environment variables. Set them:
export AWS_REGION='us-west-2'
export ANTHROPIC_AWS_WORKSPACE_ID='wrkspc_XXXXX'4. Update Self-Hosted Sandbox Workers
For self-hosted environments on CPOA:
- Environment keys from the Claude Console do not work on the CPOA endpoint
- Workers authenticate via IAM (attach
AnthropicSelfHostedEnvironmentAccesspolicy) or CPOA API key - Use the
EnvironmentWorkerSDK helper (fromanthropic.lib.environments) or callGET /v1/environments/{id}/work/polldirectly
5. IAM Permissions
Different policies for different use cases:
- Inference (
/v1/messages): AttachAnthropicInferenceAccessmanaged policy (includesCreateInference) - Self-hosted workers: Attach
AnthropicSelfHostedEnvironmentAccessmanaged policy (includesProcessEnvironmentWork,GetEnvironment,GetSession,UpdateSession,GetSkill,CallWithBearerToken— but NOTCreateInference)
A role with only AnthropicSelfHostedEnvironmentAccess will 403 on /v1/messages. Combine both policies if the worker also needs to make inference calls.
6. Security Comparison
CPOA advantages for sandboxed/multi-tenant environments:
- No long-lived secrets — IAM creds rotate hourly via STS
- IAM policy scoping — restrict to specific actions
- Condition keys —
aws:SourceVpc,aws:SourceAccount - CloudTrail audit — native AWS logging
- SCP enforcement at org level
Tradeoff: more operational complexity (IAM setup, workspace subscription, outbound web identity federation enablement).
Common Pitfalls
- Missing workspace header → 400 error. Use the platform SDK client (
AnthropicAWS/AnthropicAws) which adds it automatically, or setANTHROPIC_AWS_WORKSPACE_IDenv var. - Outbound web identity federation disabled → Every request fails with "Outbound web identity federation is disabled for your account". Run
aws iam enable-outbound-web-identity-federationonce per AWS account. - Using Claude Console environment keys on CPOA → Won't work. Workers on CPOA authenticate via IAM or CPOA API key instead.
- Confusing IAM policies →
AnthropicSelfHostedEnvironmentAccessdoes NOT grant inference. NeedAnthropicInferenceAccessfor/v1/messages. - Region not set → Unlike
AnthropicBedrock(which falls back tous-east-1), the platform client raises an error if no region is set. - Account not CPOA-subscribed → SigV4 will fail; ensure the AWS account has completed Claude Platform on AWS sign-up.
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.

