Infrastructure Intents
Infrastructure intents let you declare what resources your application needs without specifying provider-specific details. VentureKit translates intents into AWS resources (RDS, S3, SQS, ElastiCache, etc.) at deploy time.
Why Intents?
Section titled “Why Intents?”Traditional IaC (Infrastructure as Code) requires you to know AWS service names, instance types, and configuration parameters. Intents abstract this:
- CDK updates only require updating
@venturekit/infra— consumer code stays the same - Stable API for consuming projects — intents don’t change when CDK does
- Simplified configuration — no need to know AWS instance types
Declaring Intents
Section titled “Declaring Intents”Add an infrastructure object to your vk.config.ts:
import { defineVenture } from '@venturekit/infra';
export default defineVenture({ base, security, envs: { dev, prod }, routesDir: 'src/routes', infrastructure: { databases: [ { id: 'main', type: 'postgres', size: 'small', name: 'mydb' } ], storage: [ { id: 'uploads', purpose: 'uploads', cdn: true } ], auth: [ { id: 'users', signInWith: ['email'], allowSignUp: true } ], queues: [ { id: 'jobs', type: 'standard', deadLetterQueue: true } ], caches: [ { id: 'sessions', type: 'redis', size: 'small' } ], schedules: [ { id: 'cleanup', handler: 'src/jobs/cleanup.handler', schedule: { rate: '1 day' } } ], },});Intent Types
Section titled “Intent Types”Database Intent
Section titled “Database Intent”{ id: 'main-db', type: 'postgres', // 'postgres' | 'mysql' size: 'small', // 'small' | 'medium' | 'large' | 'xlarge' name: 'app_main', highAvailability: true, // Multi-AZ backups: true, backupRetentionDays: 7, encrypted: true, performanceInsights: true,}Storage Intent
Section titled “Storage Intent”{ id: 'uploads', purpose: 'uploads', // 'uploads' | 'assets' | 'backups' | 'logs' cdn: true, // Enable CloudFront cdnDomain: 'cdn.example.com', versioned: true, corsOrigins: ['https://app.example.com'],}Auth Intent
Section titled “Auth Intent”{ id: 'user-pool', signInWith: ['email', 'phone'], allowSignUp: true, mfa: 'optional', // 'off' | 'optional' | 'required' passwordStrength: 'strong', // 'standard' | 'strong' scopes: [{ name: 'read', description: 'Read access' }], clients: [{ name: 'web-app', scopes: ['read', 'write'] }],}Queue Intent
Section titled “Queue Intent”{ id: 'email-queue', type: 'standard', // 'standard' | 'fifo' deadLetterQueue: true, retentionDays: 7, visibilityTimeoutSeconds: 60,}Cache Intent
Section titled “Cache Intent”{ id: 'session-cache', type: 'redis', // 'redis' | 'memcached' size: 'small', // 'small' | 'medium' | 'large' | 'xlarge' clustered: false,}Schedule Intent
Section titled “Schedule Intent”// Rate-based{ id: 'cleanup-job', handler: 'src/jobs/cleanup.handler', schedule: { rate: '1 hour' }, // "5 minutes", "1 hour", "1 day" enabled: true,}
// Cron-based{ id: 'daily-report', handler: 'src/jobs/report.handler', schedule: { cron: '0 8 * * ? *' }, // 8:00 AM UTC daily enabled: true,}Resource Sizes
Section titled “Resource Sizes”| Size | DB Instance | Cache Node |
|---|---|---|
small | db.t3.small | cache.t3.small |
medium | db.r6g.large | cache.r6g.large |
large | db.r6g.xlarge | cache.r6g.xlarge |
xlarge | db.r6g.2xlarge | cache.r6g.2xlarge |
Accessing Intent Outputs
Section titled “Accessing Intent Outputs”After infrastructure is provisioned, outputs are available in route handlers via ctx.intentOutputs:
import { handler } from '@venturekit/runtime';import type { IntentOutputs } from '@venturekit/core';
export const main = handler(async (_body, ctx, logger) => { const outputs = ctx.intentOutputs as IntentOutputs;
// Database const dbEndpoint = outputs.databases['main-db'].endpoint; const dbPort = outputs.databases['main-db'].port; const dbSecretArn = outputs.databases['main-db'].secretArn;
// Storage const bucketName = outputs.storage['uploads'].bucketName; const cdnUrl = outputs.storage['uploads'].cdnUrl;
// Queue const queueUrl = outputs.queues['email-queue'].queueUrl;
// Cache const cacheEndpoint = outputs.caches['session-cache'].endpoint;
// Auth const userPoolId = outputs.auth['user-pool'].userPoolId;
return { dbEndpoint, bucketName, queueUrl };});Intent outputs are serialized into the VENTURE_INTENT_OUTPUTS Lambda environment variable and hydrated automatically into ctx.intentOutputs at runtime.