Click on the link below and copy the text in a new tampermonkey script:
If you want to deploy the backend keep reading and update the endpoint in the script.
This CDK project converts the existing iRacing API integration from manually managed AWS resources to CDK-managed infrastructure while migrating from environment variables to Secrets Manager for credential storage.
The project consists of:
- 3 Lambda functions: ir_auth, ir_custid, ir_drivers
- 3 DynamoDB tables: ir_auth, ir_custid, ir_drivers
- 1 Secrets Manager secret: iRacing OAuth credentials
- 1 API Gateway: REST API with routes to Lambda functions
- Node.js 20.x
- AWS CLI configured with appropriate permissions
- AWS CDK CLI installed (
npm install -g aws-cdk)
├── lib/
│ ├── constructs/
│ │ ├── secrets-construct.ts # Secrets Manager setup
│ │ ├── database-construct.ts # DynamoDB tables
│ │ ├── lambda-construct.ts # Lambda functions
│ │ └── api-gateway-construct.ts # API Gateway setup
│ └── cdk-infrastructure-stack.ts # Main stack
├── lambda/
│ ├── ir_auth/ # Authentication Lambda
│ ├── ir_custid/ # Customer ID Lambda
│ └── ir_drivers/ # Driver profiles Lambda
└── test/ # CDK tests
-
Install dependencies:
npm install
-
Build the project:
npm run build
-
Bootstrap CDK (first time only):
cdk bootstrap
-
Deploy the stack:
# Development environment cdk deploy # Production environment cdk deploy --context environment=prod
The stack supports environment-specific configuration:
environment: Environment name (dev, staging, prod)tableNamePrefix: Prefix for DynamoDB table names
After deployment, you need to update the Secrets Manager secret with your iRacing OAuth credentials:
{
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"username": "your_email@example.com",
"password": "your_password"
}npm run build- Compile TypeScript to JavaScriptnpm run watch- Watch for changes and compilenpm run test- Perform Jest unit testscdk deploy- Deploy this stack to your default AWS account/regioncdk diff- Compare deployed stack with current statecdk synth- Emits the synthesized CloudFormation templatecdk destroy- Destroy the stack
Run the test suite:
npm test- Backup existing data: Export data from existing DynamoDB tables
- Deploy CDK stack: Deploy the new infrastructure
- Update secrets: Configure the Secrets Manager secret
- Import data: Import data to new DynamoDB tables
- Update DNS/routing: Point traffic to new API Gateway
- Clean up: Remove old infrastructure after validation
- All Lambda functions use least-privilege IAM roles
- Secrets are stored in AWS Secrets Manager with encryption
- API Gateway has throttling enabled
- DynamoDB tables have point-in-time recovery enabled
- All resources are tagged for better management