AWS Integration Guide
Technology: aws · Category: hosting · Last reviewed: 2026-10-20
Source: https://tech-stack.codeamanilabs.org/guide/aws
Insight:
AWS is the Enterprise-tier host. It's reserved for $50K+ client builds (including the HIPAA healthcare platform) where Neon/R2/Resend/Vercel can't meet a client's compliance, residency, or scale requirement. It complements the house defaults and never replaces them. Reach AWS with no static keys: Vercel OIDC or GitHub OIDC → STS for workloads, and
aws login/ IAM Identity Center for humans. For Kenya-resident data,af-south-1(Cape Town) is an opt-in Region that costs about 20–35% more than us-east-1.
█████╗ ██╗ ██╗███████╗
██╔══██╗██║ ██║██╔════╝
███████║██║ █╗ ██║███████╗
██╔══██║██║███╗██║╚════██║
██║ ██║╚███╔███╔╝███████║
╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝
AWS Integration Guide
Focus: When and how codeAmani uses Amazon Web Services for Enterprise-tier client builds. Covers keyless auth (Vercel/GitHub OIDC, IAM Identity Center,
aws login), S3 and presigned URLs, RDS and Aurora Serverless v2, Lambda (Event and Web Functions), API Gateway, ECS Fargate, CloudFront, SES, IaC with the AWS CDK in TypeScript, a HIPAA baseline for the Florida healthcare niche, andaf-south-1for Kenya-targeted data residency.
Overview
motionstackstudios.com lists AWS as infrastructure, and it hosts the agency's Enterprise segment: $50K+ engagements, including a HIPAA-compliant healthcare platform for an APD/AHCA/DCF-licensed provider. Of the house hosting guides (vercel, netlify, cloudflare, render, google-cloud), it's the heavyweight option. It complements them and doesn't replace them.
The house defaults stay the same for almost everything: Neon for Postgres, Cloudflare R2 for object storage, Resend for email, Vercel for app hosting. AWS earns a place only when an enterprise client's contract demands something a default can't give: a signed BAA, data residency in a specific Region, a private VPC, VPC-peered databases, or scale/SLA guarantees.
flowchart TD
A["New enterprise build<br/>$50K+ engagement"] --> B{"Compliance / residency /<br/>scale requirement?"}
B -->|No| C["House defaults<br/>Neon · R2 · Resend · Vercel"]
B -->|Yes — e.g. HIPAA BAA,<br/>in-Africa residency| D["AWS account<br/>(per-client, isolated)"]
D --> E["Keyless auth<br/>OIDC roles · Identity Center"]
E --> F["S3 + RDS/Aurora<br/>Lambda · ECS · CloudFront · SES"]
F --> G["BAA via AWS Artifact<br/>HIPAA-eligible services only"]
G --> H["Provisioned via CDK / Terraform<br/>reviewed by [CA] Cloud Architect"]
Check first. Before adding any AWS service, query the
codeAmani-tech-stackMCP (search_guides/get_guide) and confirm a house default won't satisfy the requirement. AWS adds operational surface, cost, and compliance obligations. Prefer the default unless the client specifically requires AWS.
Current versions (verified 2026-10-20)
| Component | Version | Note |
|---|---|---|
| AWS SDK for JavaScript | v3: @aws-sdk/* 3.1153.0 |
Modular per-service clients; Node ≥ 20 (engines) |
@vercel/oidc-aws-credentials-provider |
3.3.13 | Vercel OIDC → STS credentials |
| AWS CDK | v2: aws-cdk-lib 2.273.0, CLI aws-cdk 2.1146.0, constructs 10.8.1 |
CLI and library version independently |
| AWS CLI | v2: 2.38.x | aws login needs ≥ 2.32.0 |
| boto3 (Python) | 1.43.115 | Python ≥ 3.10 |
aws-actions/configure-aws-credentials |
v6.3.0 | GitHub OIDC |
Official Documentation
| Resource | URL |
|---|---|
| AWS Documentation (root) | https://docs.aws.amazon.com |
| AWS SDK for JavaScript v3 | https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/ |
| AWS CDK v2 Developer Guide | https://docs.aws.amazon.com/cdk/v2/guide/home.html |
| AWS CLI v2 User Guide | https://docs.aws.amazon.com/cli/latest/userguide/ |
| Lambda runtimes | https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html |
| Vercel → AWS OIDC | https://vercel.com/docs/oidc/aws |
Official AWS MCP servers (awslabs/mcp) |
https://github.com/awslabs/mcp |
| HIPAA-Eligible Services Reference | https://aws.amazon.com/compliance/hipaa-eligible-services-reference/ |
| Architecting HIPAA on AWS (whitepaper) | https://docs.aws.amazon.com/whitepapers/latest/architecting-hipaa-security-and-compliance-on-aws/ |
AWS MCP servers. AWS ships the open-source
awslabs/mcpcollection and AWS-managed remote endpoints. One is the read-only AWS Knowledge MCP Server (https://knowledge-mcp.global.api.aws, no auth), which serves live docs, regional availability, and API references. Others can drive an account, such as the AWS API MCP Server. None is in the house.mcp.jsonby default. The Knowledge server is a safe read-only companion. Anything that mutates a client account still goes through the AWS CLI v2, the v3 SDK, and CDK under the[CA]Cloud Architect gate. If you enable a write-capable AWS-managed server, it injects theaws:ViaAWSMCPService/aws:CalledViaAWSMCPIAM context keys. That lets least-privilege policies tell agent-driven calls apart from human ones.
Accounts & auth: no static keys
Every enterprise client gets an isolated AWS account, ideally under an AWS Organizations management account, so blast radius, billing, and the HIPAA BAA stay scoped per engagement.
| Who is calling | How it authenticates | Static keys? |
|---|---|---|
| A human, org account | IAM Identity Center (aws configure sso → aws sso login) |
No |
| A human, solo/new account | aws login (CLI ≥ 2.32.0): console sign-in → short-lived, auto-rotated CLI/SDK creds |
No |
| Vercel function (Next.js) | Vercel OIDC → sts:AssumeRoleWithWebIdentity via @vercel/oidc-aws-credentials-provider |
No |
| GitHub Actions | GitHub OIDC via aws-actions/configure-aws-credentials@v6 |
No |
| Lambda / ECS / EC2 | Execution role / task role / instance profile | No |
| A host with no OIDC (rare) | Scoped IAM user key, one bucket/action, rotated | Last resort |
- No root access keys, ever. Give the root user MFA, then lock it away.
- Least privilege: start from deny and grant specific actions on specific ARNs. Never
"Action": "*"on"Resource": "*". - Trust policies: pin
audandsubexactly. Never wildcard the repo or project part ofsub. Copy-paste policies are inreference/iam-trust-policies.md.
Vercel → AWS with OIDC (the default for Vercel-hosted apps)
This replaces the old "scoped AWS_ACCESS_KEY_ID in Vercel env vars" pattern. Enable OIDC on the Vercel project (Team issuer mode). Add an IAM OIDC identity provider with URL https://oidc.vercel.com/<team-slug> and audience https://vercel.com/<team-slug>, plus sts.amazonaws.com if you pass that audience. Then create a role whose trust policy pins sub to owner:<team>:project:<project>:environment:production.
// lib/aws.ts (server-only)
import "server-only";
import { S3Client } from "@aws-sdk/client-s3";
import { awsCredentialsProvider } from "@vercel/oidc-aws-credentials-provider";
export const s3 = new S3Client({
region: process.env.AWS_REGION!, // PIN this in Vercel env vars (see below)
credentials: awsCredentialsProvider({
roleArn: process.env.AWS_ROLE_ARN!,
audience: "sts.amazonaws.com", // must match the provider + trust policy `aud`
}),
});
Gotcha:
AWS_REGIONon Vercel. Vercel setsAWS_REGIONto the function's execution Region. With multi-region routing or failover, that value changes and your SDK calls go to a Region where your bucket doesn't exist. Always setAWS_REGIONexplicitly in the Vercel project.
Secrets Manager
App secrets such as DB credentials and third-party API keys live in AWS Secrets Manager when the build runs on AWS end-to-end. It integrates with RDS rotation and IAM. Secrets Manager is the AWS-native analogue of the house infisical / Hazina setup. When the app is Vercel-hosted, Vercel env vars or Infisical stay the default, and AWS holds only infrastructure secrets. Pricing is $0.40 per secret per month plus $0.05 per 10,000 API calls, so cache reads:
// lib/aws/secrets.ts
import { SecretsManagerClient, GetSecretValueCommand } from "@aws-sdk/client-secrets-manager";
const client = new SecretsManagerClient({ region: process.env.AWS_REGION });
const cache = new Map<string, { value: unknown; expires: number }>();
export async function getSecret<T>(secretId: string, parse: (raw: unknown) => T): Promise<T> {
const hit = cache.get(secretId);
if (hit && hit.expires > Date.now()) return parse(hit.value);
const res = await client.send(new GetSecretValueCommand({ SecretId: secretId }));
if (!res.SecretString) throw new Error(`Secret ${secretId} has no string value`);
const value: unknown = JSON.parse(res.SecretString);
cache.set(secretId, { value, expires: Date.now() + 5 * 60_000 });
return parse(value); // validate the shape; don't cast
}
Full version with a typed parser: examples/secrets.ts.
S3 & presigned URLs
S3 is the AWS object store. Cloudflare R2 is the house default (zero egress fees, S3-compatible API), and most builds never leave R2. An enterprise or HIPAA client may still require S3 specifically: BAA coverage, Object Lock for WORM retention, SSE-KMS with a customer-managed key, or VPC-gated access. R2 speaks the S3 API, so the v3 @aws-sdk/client-s3 code below works against both. Only the endpoint and credentials change.
Client uploads use a presigned URL. The browser uploads directly to S3, the server never proxies the bytes, and the URL expires. For PHI, the bucket is private with SSE-KMS, and the presigned PUT carries the encryption header.
// lib/aws/s3-presign.ts
import { PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { s3 } from "@/lib/aws";
const BUCKET = process.env.S3_BUCKET!;
/** Presigned PUT for a direct browser upload (PHI: SSE-KMS enforced). */
export async function presignUpload(key: string, contentType: string): Promise<string> {
const cmd = new PutObjectCommand({
Bucket: BUCKET,
Key: key, // build the key server-side; never trust a client-supplied key
ContentType: contentType,
ServerSideEncryption: "aws:kms",
SSEKMSKeyId: process.env.S3_KMS_KEY_ID, // customer-managed key for healthcare
});
return getSignedUrl(s3, cmd, { expiresIn: 300 }); // 5 minutes
}
/** Presigned GET for a time-boxed download (e.g. an intake PDF). */
export async function presignDownload(key: string): Promise<string> {
return getSignedUrl(s3, new GetObjectCommand({ Bucket: BUCKET, Key: key }), { expiresIn: 60 });
}
Gotcha: a presigned PUT only succeeds if the request matches the signed parameters exactly. If you sign
ServerSideEncryption: "aws:kms", the browser'sPUTmust send thex-amz-server-side-encryption: aws:kmsheader, or S3 returns403 SignatureDoesNotMatch. Sign exactly the headers the client will send, no more. A runnable Next.js Route Handler is inexamples/vercel-oidc/. The boto3 version is inexamples/python/presign_boto3.py.
Price: S3 Standard is $0.023/GB-month in us-east-1 and $0.0274 in af-south-1 (first 50 TB).
Databases: RDS & Aurora Serverless v2
Neon is the house default Postgres. It's serverless, branches per PR, and is already wired into the neon guide and the app's Drizzle setup. Stay on Neon unless an enterprise client needs something Neon can't offer: a signed BAA, a private VPC with no public endpoint, VPC peering to other AWS resources, or a specific data-residency Region.
When AWS is required, prefer Aurora Serverless v2 (PostgreSQL-compatible) over plain RDS for most workloads. It autoscales ACUs with load and can scale down to 0 ACUs when idle, which mirrors Neon's serverless economics while living inside the client's VPC. Compute costs $0.12/ACU-hour in us-east-1 (Aurora Standard; $0.156 on I/O-Optimized) and $0.16/ACU-hour in af-south-1. Reach for provisioned RDS only when a steady instance class is cheaper or a feature requires it.
| Concern | House default (Neon) | AWS (Aurora Serverless v2 / RDS) |
|---|---|---|
| Provisioning | Instant, in-console/MCP | CDK/Terraform into a VPC |
| Scaling | Serverless autoscale | Aurora SLv2 ACUs / RDS instance class |
| Branching | Per-PR DB branches | Snapshots/clones (heavier) |
| Connection | Pooled HTTP/WebSocket driver | Standard pg over VPC; RDS Proxy for Lambda; IAM auth tokens via @aws-sdk/rds-signer |
| HIPAA BAA | Via Neon's terms | Covered under the AWS BAA (Aurora/RDS are HIPAA-eligible) |
| Encryption | TLS + at-rest | TLS + KMS at-rest (required for PHI) |
Drizzle still drives it. Point the connection string at the Aurora writer endpoint, sourced from Secrets Manager, or use short-lived IAM auth tokens from @aws-sdk/rds-signer, which also works from Vercel via OIDC. For Lambda, put RDS Proxy in front so cold-start storms don't exhaust connections.
Compute: Lambda, API Gateway & ECS Fargate
- Lambda Event Functions (the docs' new name for classic Lambda functions) + API Gateway handle event-driven and bursty work: webhook receivers, scheduled jobs, S3-triggered processing, a thin API. Pair with RDS Proxy for database access. Cheapest at low or spiky volume: $0.20 per 1M requests plus $0.0000166667/GB-s on x86 in us-east-1, with a monthly free tier of 1M requests and 400,000 GB-s.
- Lambda Web Functions (new, launched October 2026) run an HTTP server (Express, Hono, Fastify, Next.js standalone) directly, with no adapter. One warm environment serves many concurrent requests, and billing covers active CPU plus memory, not idle CPU. Only
nodejs24.xis supported, in select Regions, and CloudFront can front it with OAC. It's worth evaluating for VPC-resident Node APIs. Confirm HIPAA eligibility and Region availability before using it for PHI. - ECS on Fargate runs long-running or containerized services that don't fit Lambda's limits (15-minute max, payload caps). This is where the
dockerguide pays off: the image you build for local dev runs on Fargate. Use it for steady traffic, WebSocket servers, or a healthcare platform that must run inside a VPC alongside Aurora.
Runtimes (Event Functions):
nodejs24.xis the target (deprecation 2028-04-30) and is what CDK'sRuntime.NODEJS_LATESTresolves to inaws-cdk-lib2.273.0.nodejs22.xis supported until 2027-04-30.nodejs20.xwas deprecated on 2026-04-30; migrate any function still on it.nodejs26.xis in public preview: no SLA, not for production, and no CDK constant yet. Amazon Linux 2 reached end of life on 2026-06-30. On Fargate, pin the base image to Node.js 24 LTS.
Every compute shape runs with a scoped task/execution role (no embedded keys) and reads secrets from Secrets Manager at start. A typical healthcare platform: CloudFront → ALB → Fargate service (private subnets) → Aurora Serverless v2 (isolated subnets) → S3 for documents.
CloudFront & SES
- CloudFront is the CDN/edge layer in front of S3, the ALB, and Lambda Web Functions. It handles TLS termination and caching, and it's where WAF attaches. For PHI, keep the bucket private and serve through CloudFront with Origin Access Control (OAC) so objects are never publicly reachable. CloudFront has African edge locations in Nairobi, Lagos, Cairo, Johannesburg, and Cape Town. For Vercel-hosted marketing sites, Vercel's own edge stays the default.
- SES is the AWS-native transactional email service. Resend is the house default and stays so for nearly everything. Use SES only when an enterprise client needs email to originate inside their AWS account, very high volume at AWS pricing, or BAA-covered email. Pricing changed: from 2026-07-21, new SES accounts (and account-Region pairs with no metered use since 2025-06-01) start on the Essentials plan at $0.16 per 1,000 emails (Pro $0.22, Enterprise $0.23, first 10M/month). Older accounts keep the à la carte $0.10 per 1,000. To launch, verify the domain (DKIM/SPF/DMARC), then request production access to leave the SES sandbox.
Regions: us-east-1 by default, af-south-1 for Kenya-resident data
codeAmani is US-first, so client accounts default to us-east-1. For a Kenya-targeted project whose contract or KDPA 2019 analysis calls for in-Africa data residency, use af-south-1 (Cape Town), the closest AWS Region to Nairobi:
- It's an opt-in Region. Enable it on the account first (
aws account enable-region --region-name af-south-1, or Account → AWS Regions). IAM roles only propagate to enabled Regions. - Available there (AWS regional-availability API, 2026-10-20): S3, Lambda, Fargate, Aurora, SES, Secrets Manager, IAM Identity Center, Bedrock. Bedrock model availability is narrower than in us-east-1, so check each model ID.
- It costs about 20–35% more than us-east-1: S3 +19%, Lambda compute +33%, Aurora SLv2 +33%.
- For Kenyan users on 2G/3G, put CloudFront (Nairobi edge) in front. Payments stay on M-Pesa for Kenya-targeted projects and Stripe otherwise. AWS doesn't change the payments rule.
Full price comparison: reference/cheatsheet.md.
Infrastructure as Code (AWS CDK in TypeScript)
All AWS infrastructure is defined as code and reviewed by the [CA] Cloud Architect agent before apply. No click-ops in the console for anything that touches client data. The house preference is AWS CDK v2 in TypeScript: same language as the app, with type-safe constructs. Terraform is the alternative when a client standardizes on it or needs multi-cloud.
npm install aws-cdk-lib@2.273.0 constructs@10.8.1
npm install -D aws-cdk@2.1146.0 # project-local CLI; run via npx cdk
npx cdk bootstrap aws://ACCOUNT_ID/us-east-1
A minimal HIPAA-leaning stack: a private, encrypted, versioned bucket and a scoped secret.
// lib/intake-stack.ts
import { Stack, type StackProps, Duration, RemovalPolicy } from "aws-cdk-lib";
import type { Construct } from "constructs";
import { Bucket, BucketEncryption, BlockPublicAccess } from "aws-cdk-lib/aws-s3";
import { Key } from "aws-cdk-lib/aws-kms";
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
export class IntakeStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
// Customer-managed KMS key with rotation (required posture for PHI).
const key = new Key(this, "IntakeKey", {
enableKeyRotation: true,
removalPolicy: RemovalPolicy.RETAIN,
});
// Private, encrypted, versioned bucket — no public access.
new Bucket(this, "IntakeBucket", {
bucketName: "acme-health-intake",
encryption: BucketEncryption.KMS,
encryptionKey: key,
bucketKeyEnabled: true, // fewer KMS requests → lower cost
enforceSSL: true,
versioned: true,
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
lifecycleRules: [{ expiration: Duration.days(2555) }], // ~7yr retention
removalPolicy: RemovalPolicy.RETAIN,
});
// DB credentials in Secrets Manager (consumed by Aurora + the app).
new Secret(this, "DbCredentials", {
secretName: "acme/aurora/credentials",
encryptionKey: key,
generateSecretString: {
secretStringTemplate: JSON.stringify({ username: "app" }),
generateStringKey: "password",
excludePunctuation: true,
},
});
}
}
The full app, with a Node.js 24 Lambda on upload and least-privilege grants, is in examples/cdk/. Note that NodejsFunction's logRetention prop is deprecated; pass a logGroup instead.
npx cdk synth # emit the CloudFormation template (review this in the [CA] gate)
npx cdk diff # show the delta against the deployed stack
npx cdk deploy # apply (only after Cloud Architect review)
HIPAA on AWS (Florida healthcare niche)
This is the reason AWS exists in the stack. Any build handling PHI for an APD/AHCA/DCF provider has a non-negotiable baseline:
- Sign the BAA. Accept the AWS Business Associate Addendum via AWS Artifact (Console → Artifact → Agreements) before any PHI lands in the account. No BAA, no PHI. Designating an account as HIPAA also upgrades a Free-plan account to a paid plan.
- HIPAA-eligible services only. PHI may only flow through services on the HIPAA-eligible services reference. S3, RDS/Aurora, Lambda, ECS/Fargate, API Gateway, CloudFront, SES, Secrets Manager, and KMS are eligible. Check each service anyway, and especially new features like Lambda Web Functions, before use.
- Encryption at rest: KMS on S3 (SSE-KMS), Aurora/RDS storage encryption, EBS volumes. Customer-managed keys with rotation give the strongest posture.
- Encryption in transit: TLS everywhere, with
enforceSSLon buckets,rds.force_ssl, and HTTPS-only CloudFront. See theencryptionguide. - Audit + access: CloudTrail on (immutable log bucket), least-privilege IAM, no public endpoints for PHI stores, VPC isolation for databases. Keep PHI out of CloudWatch logs.
- Retention: lifecycle rules or Object Lock to meet record-retention rules. Florida healthcare retention can run about 7 years.
flowchart LR
A["Provider uploads PHI"] --> B["CloudFront + OAC<br/>HTTPS only"]
B --> C["Private S3 bucket<br/>SSE-KMS · versioned"]
A --> D["Fargate service<br/>(private subnet)"]
D --> E[("Aurora Serverless v2<br/>KMS at-rest · TLS")]
D --> F["Secrets Manager<br/>DB creds via IAM role"]
G["AWS Artifact BAA"] -.signed before any PHI.-> C
H["CloudTrail"] -.audit log.-> C
Compliance gate: PHI work involves the
[COMPLIANCE]and[PRIVACY]agents. The BAA, the encryption posture, and the HIPAA-eligible-services check are human approval gates. Surface them; don't assume them.
Environment Variables
Non-secret settings. Set them as plain env vars; they don't belong in a secrets vault:
| Variable | Example | Notes |
|---|---|---|
AWS_REGION |
us-east-1 / af-south-1 |
Required by every v3 client. Pin it on Vercel. |
AWS_ROLE_ARN |
arn:aws:iam::123456789012:role/vercel-s3-intake |
Vercel OIDC role to assume |
AWS_PROFILE |
acme-enterprise |
Local dev/CLI only (aws login or SSO profile) |
S3_BUCKET |
acme-health-intake |
|
S3_KMS_KEY_ID |
arn:aws:kms:us-east-1:123456789012:key/... |
Key ARN, not secret material |
Static credentials are a last resort, used only on a host that can't do OIDC and can't attach a role. Scope them to one bucket and action, and rotate them:
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=... # server-side only — NEVER ship to the client bundle
Add these to
ENV_MASTER.mdand each project's.env.example. In production, prefer OIDC (Vercel, GitHub), IAM roles (Lambda/ECS/EC2), and Secrets Manager over static keys. Never expose credentials to the browser; presign on the server.
CLI Integration (AWS CLI v2)
Install the AWS CLI v2 (2.38.x). Authenticate with aws login or an IAM Identity Center profile, and never paste root keys.
# Humans: short-lived creds from console sign-in (CLI >= 2.32.0) …
aws login --profile acme-enterprise
# … or IAM Identity Center for org accounts
aws configure sso
aws sso login --profile acme-enterprise
# Verify which identity you're operating as before anything destructive
aws sts get-caller-identity --profile acme-enterprise
# Kenya-resident data: enable the opt-in Region once per account
aws account enable-region --region-name af-south-1 --profile acme-enterprise
# Read a secret (JSON) from Secrets Manager
aws secretsmanager get-secret-value --secret-id acme/aurora/credentials \
--query SecretString --output text --profile acme-enterprise
# Tail a Lambda's logs live
aws logs tail /aws/lambda/intake-handler --follow --profile acme-enterprise
Automation Workflows
Claude Code slash command: AWS resource audit
.claude/commands/aws-audit.md:
Audit the AWS account for the profile: $ARGUMENTS
1. Run `aws sts get-caller-identity --profile $ARGUMENTS` and confirm the account.
2. List S3 buckets and check each for: public-access block ON, default encryption,
and versioning (`aws s3api get-bucket-encryption|get-public-access-block|get-bucket-versioning`).
3. List IAM users and flag any with active access keys (OIDC/roles should replace them).
4. List IAM OIDC providers and review every role trusting them: `aud` pinned, no `repo:*` / project `*` in `sub`.
5. List Lambda functions on deprecated runtimes (`nodejs20.x` and older, any AL2 runtime).
6. Confirm CloudTrail is enabled in all regions.
7. Cross-check every service touching PHI against the HIPAA-eligible services list.
8. Output a findings table: resource, issue, severity, remediation. Flag anything
that breaks the HIPAA baseline for the [COMPLIANCE] / [PRIVACY] gate.
GitHub Actions: CDK deploy via OIDC (no static keys)
# .github/workflows/cdk-deploy.yml
name: CDK Deploy
on:
push:
branches: [main]
permissions:
id-token: write # required for OIDC role assumption
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with: { node-version: '24', cache: npm }
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::123456789012:role/github-cdk-deploy
aws-region: us-east-1
- run: npm ci
- run: npx cdk diff
- run: npx cdk deploy --all --require-approval never
GitHub OIDC assumes a deploy role, so CI holds no long-lived AWS keys. Scope the trust policy's
subto the repo plus a branch or environment. GitHub repos created or renamed on or after 2026-07-15 emit an immutablesubthat uses numeric IDs, so check the claim before you write the condition. Pin actions to commit SHAs per the supply-chain policy.
Common Use Cases
| Use Case | Approach |
|---|---|
| Default object storage | Cloudflare R2 (house default); use S3 only if a client requires it |
| Default Postgres | Neon (house default); use Aurora Serverless v2 only for VPC/BAA/residency needs |
| Default transactional email | Resend (house default); use SES only for in-account, high-volume, or BAA email |
| Default app hosting | Vercel (house default); use ECS Fargate or Lambda for VPC-resident services |
| Vercel app → S3/RDS | Vercel OIDC role via @vercel/oidc-aws-credentials-provider (no keys) |
| CI deploys | GitHub OIDC + configure-aws-credentials@v6 |
| Direct browser upload | S3 presigned PUT (@aws-sdk/s3-request-presigner), 5-min expiry |
| Python service → S3 | boto3 generate_presigned_url with SigV4 |
| Infrastructure provisioning | AWS CDK v2 (TypeScript), reviewed by [CA] |
| App/infra secrets | AWS Secrets Manager + IAM role, cached (ties to infisical/encryption) |
| HIPAA PHI store | Private S3 + SSE-KMS + Aurora-in-VPC, BAA via AWS Artifact |
| Kenya-resident data | af-south-1 (opt-in) + CloudFront Nairobi edge |
| Bursty / event-driven compute | Lambda Event Functions + API Gateway (+ RDS Proxy for DB) |
| HTTP Node API, VPC-resident | Lambda Web Functions (evaluate) or ECS Fargate |
| Long-running / containerized | ECS Fargate (ties to docker guide) |
Troubleshooting
| Issue | Fix |
|---|---|
SignatureDoesNotMatch on presigned PUT |
The client must send exactly the signed headers (e.g. x-amz-server-side-encryption); sign only what the client will send |
403 AccessDenied on S3 GET |
Check that the IAM policy ARN matches the bucket and that the bucket policy / OAC isn't blocking; confirm AWS_REGION is correct |
Vercel: Not authorized to perform sts:AssumeRoleWithWebIdentity |
The trust policy's aud/sub doesn't match the token. Check the team slug, project name, and environment, and that the audience is registered on the IAM OIDC provider |
Vercel: calls hit the wrong Region / NoSuchBucket |
AWS_REGION was auto-set to the function's Region; set it explicitly in project env vars |
| GitHub: OIDC assume-role denied on a new repo | New or renamed repos (since 2026-07-15) emit an immutable numeric sub; update the condition |
ExpiredToken from the SDK |
Session expired; re-run aws login / aws sso login --profile ... |
| CLI uses the wrong account | Pass --profile (or set AWS_PROFILE); verify with aws sts get-caller-identity |
af-south-1 calls fail with auth errors |
The Region isn't enabled on the account; run aws account enable-region --region-name af-south-1 |
| Lambda DB connection exhaustion | Front the database with RDS Proxy; don't open a raw pool per invocation |
Lambda on nodejs20.x |
Deprecated 2026-04-30; move to nodejs24.x (Runtime.NODEJS_24_X) |
cdk deploy fails on bootstrap |
Run cdk bootstrap aws://ACCOUNT/REGION once per account+Region (af-south-1 too) |
| SES emails go to spam / stuck in sandbox | Verify domain DKIM/SPF/DMARC and request production access |
| PHI on a non-eligible service | Stop. Move PHI only onto services on the HIPAA-eligible list, and confirm the BAA is signed in AWS Artifact |
KMS AccessDeniedException |
The IAM role needs kms:GenerateDataKey/kms:Decrypt on the key, and the key policy must allow the role |
codeAmani notes
- Enterprise tier only. AWS is for $50K+ builds with a compliance, residency, VPC, or scale requirement that the house defaults (Neon, R2, Resend, Vercel) can't meet. Check the tech-stack MCP first.
- Secrets stay server-side. No AWS credential ever reaches a client bundle. Prefer OIDC and roles over keys everywhere, and run gitleaks before every push.
- AI routing is unchanged. Claude stays primary through the Anthropic API. Bedrock is an option only when a client contract requires model calls to stay inside their AWS account (and BAA). Follow the
anthropicguide's model IDs and verify Bedrock model availability per Region, especially inaf-south-1. - Payments are unchanged. Stripe is the default and M-Pesa is used only for Kenya-targeted projects. Hosting on AWS doesn't change the payment rail. M-Pesa callbacks still need public HTTPS (API Gateway or a Lambda Web Function URL behind CloudFront both work).
- African market. Use
af-south-1for in-Africa residency, CloudFront's Nairobi edge for latency, and budget about 20–35% more than us-east-1. - HIPAA is a human gate. BAA first, eligible services only, KMS plus TLS, CloudTrail on.
See PATTERNS.md, RESOURCES.md, NOTES.md, examples/, and reference/.
Official docs:
- https://docs.aws.amazon.com
- https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/
- https://docs.aws.amazon.com/cdk/v2/guide/home.html
- https://docs.aws.amazon.com/cli/latest/userguide/
- https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
- https://vercel.com/docs/oidc/aws
- https://aws.amazon.com/compliance/hipaa-eligible-services-reference/
- https://docs.aws.amazon.com/whitepapers/latest/architecting-hipaa-security-and-compliance-on-aws/