CDK Infrastructure
Purpose
The CDK stack (AllDocsStack) defines and deploys all AWS infrastructure for the documentation site. It's a single stack that manages the static website hosting, both Lambda functions, API Gateway, and all necessary permissions and integrations.
How It Works
The stack creates and wires together all infrastructure components:
- Static Website - Uses the
StaticWebsiteconstruct from@pit-shared/cdkto create S3 bucket, CloudFront distribution, SSL certificate, and Okta authentication - Webhook Handler Lambda - Node.js function that receives GitHub webhooks via API Gateway
- Docs Rebuilder Lambda - Docker container Lambda that runs the full rebuild pipeline
- API Gateway - Exposes webhook endpoint for GitHub to call
- Permissions - Grants Lambdas access to Secrets Manager, S3, CloudFront, and each other
Key Resources
StaticWebsite (from @pit-shared/cdk)
- S3 Bucket - Hosts static site files
- CloudFront Distribution - CDN with Okta authentication
- Route53 Record - DNS alias for
docs.stage.sso.statista.com - Certificate - SSL/TLS certificate for HTTPS
Webhook Infrastructure
- API Gateway - REST API with
/webhookPOST endpoint - Webhook Handler Lambda - Validates signatures, filters events, triggers rebuilder
- DataDog Integration - APM instrumentation for the webhook handler
Rebuilder Infrastructure
- Docker Lambda Function - Packages Node.js, Python, Git, aggregator, and MkDocs
- IAM Permissions - Access to S3 (read/write), CloudFront (invalidation), Secrets Manager
- Environment Variables - Bucket name, distribution ID, secret name
Shared Resources
- Secrets Manager Reference - Points to
docs-builder/github-appsecret (GitHub App credentials, webhook secret, DataDog API key)
Stack Outputs
The stack exports useful values:
WebsiteURL- The documentation site URLDistributionId- CloudFront distribution ID (for manual cache invalidation)WebhookURL- GitHub webhook endpoint URLDocsRebuilderFunctionName- Lambda function name (for manual invocation)
Region
All resources are deployed to us-east-1 (required by the StaticWebsite construct for CloudFront edge lambdas).
Deployment
pnpm deploy:infra
This builds all TypeScript components, builds the Docker image, and deploys the complete stack.