Skip to content

mantle.config.ts Reference

Project configuration for Mantle, declared via defineConfig() from @mantleframework/core.

typescript
// mantle.config.ts
import { defineConfig } from '@mantleframework/core'

export default defineConfig({
  name: 'my-api',
})

The CLI reads this file at build and deploy time. It does not affect Lambda runtime behavior.


Top-Level Options

OptionTypeRequiredDescription
namestringyesProject name. Used as prefix for Terraform resource naming.
databaseobjectDatabase provider config.
authobjectAuth provider config.
featuresobjectFeature flags for observability and resilience.
backendobjectRemote Terraform state backend (S3).
customVariablesarrayAdditional Terraform variables appended to variables.tf.
storagearrayS3 storage buckets to provision.
eventbridgeobjectEventBridge custom bus configuration.
corsobjectCORS policy for API Gateway responses.
queuesarraySQS queues to provision.
dynamodbarrayDynamoDB tables to provision.
websocketobjectWebSocket API Gateway configuration.
observabilityobjectADOT and metrics configuration.
secretsobjectSOPS-encrypted secrets configuration.
snsobjectSNS topics and platform applications.
cloudfrontobjectCloudFront distribution fronting API Gateway.
authorizerobjectAPI Gateway custom authorizer cache settings.
layersarrayCustom Lambda layers.
containerRegistryobjectECR container registry configuration.

Database

typescript
database: { provider: 'aurora-dsql' }
OptionTypeDescription
provider'aurora-dsql' | 'aurora-serverless-v2' | 'neon'Database provider.

Backend (Terraform State)

typescript
backend: {
  s3: {
    bucket: 'my-tfstate',
    key: 'infra.tfstate',
    region: 'us-east-1',
  }
}
OptionTypeDescription
s3.bucketstringS3 bucket name.
s3.keystringState file key.
s3.regionstringBucket region.
s3.encryptbooleanEnable server-side encryption.
s3.dynamodbTablestringDynamoDB table name for state locking.
s3.workspaceKeyPrefixstringKey prefix for Terraform workspaces.

EventBridge

typescript
eventbridge: {
  bus: 'MyBus',
  sqsTargets: [
    {
      detailType: 'OrderCreated',
      queue: 'OrderQueue',
    }
  ]
}
OptionTypeDescription
busstringCustom event bus name.
sqsTargetsarrayEventBridge rules that route events to SQS queues.
sqsTargets[].detailTypestringEventBridge detail-type to match.
sqsTargets[].queuestringQueue name (must match an entry in queues).
sqsTargets[].inputTransformerobjectReshape event before delivery. Has inputPaths and inputTemplate.

Storage (S3)

typescript
storage: [
  { name: 'assets', cloudfront: true, intelligentTiering: true }
]
OptionTypeDefaultDescription
namestringBucket logical name.
bucketNameOverridestringFull bucket name as Terraform expression, bypasses name prefix.
cloudfrontbooleanfalseProvision a CloudFront distribution.
cloudfrontPriceClassstringCloudFront price class.
corsOriginsstring[]CORS allowed origins for the bucket.
corsMethodsstring[]CORS allowed methods.
intelligentTieringbooleanfalseEnable S3 Intelligent-Tiering.
versioningbooleanfalseEnable object versioning.
assetsstring[]Static asset keys to upload. Source path: static/{key} at project root.

Queues (SQS)

typescript
queues: [
  { name: 'OrderQueue', visibilityTimeoutSeconds: 300 }
]
OptionTypeDefaultDescription
namestringQueue name. Must match the queue option in defineSqsHandler.
delaySecondsnumber0Delivery delay in seconds.
maxMessageSizenumber262144Max message size in bytes.
retentionSecondsnumber345600Message retention in seconds (4 days).
visibilityTimeoutSecondsnumber30Visibility timeout in seconds.
enableDlqAlarmbooleantrueEnable CloudWatch alarm for DLQ message depth.

DynamoDB

typescript
dynamodb: [
  {
    name: 'idempotency',
    hashKey: 'id',
    attributes: [{ name: 'id', type: 'S' }],
    ttlAttribute: 'expiration',
  }
]
OptionTypeDefaultDescription
namestringTable logical name.
tableNameOverridestringFull table name as Terraform expression.
hashKeystringPartition key attribute name.
rangeKeystringSort key attribute name.
attributesarrayAttribute definitions. Each has name and type (S, N, B).
billingModestringPAY_PER_REQUESTPAY_PER_REQUEST or PROVISIONED.
ttlAttributestringAttribute name for TTL-based expiry.
pointInTimeRecoverybooleanfalseEnable PITR.
globalSecondaryIndexesarrayGSI definitions. Each has name, hashKey, rangeKey?, projectionType?.

WebSocket

typescript
websocket: {
  routeSelectionExpression: '$request.body.action',
  stageName: 'live',
}
OptionTypeDefaultDescription
routeSelectionExpressionstring$request.body.actionRoute selection expression.
stageNamestringliveAPI Gateway stage name.
throttlingBurstLimitnumber100Burst limit.
throttlingRateLimitnumber50Rate limit (requests/second).

Observability

typescript
observability: {
  adot: true,
  metricsNamespace: 'MyApp',
}
OptionTypeDefaultDescription
adotbooleanfalseAttach AWS Distro for OpenTelemetry (ADOT) layer to all Lambdas.
metricsNamespacestringCloudWatch metrics namespace. Injected as METRICS_NAMESPACE env var.
commonEnvRecord<string, string>Additional env vars injected into all Lambdas via locals.tf.

CORS

typescript
cors: {
  origins: ['https://app.example.com'],
  methods: ['GET', 'POST'],
  maxAge: 86400,
}
OptionTypeDefaultDescription
originsstring[]Allowed origins. Empty = no CORS headers (secure default).
methodsstring[]['GET','POST','PUT','DELETE','PATCH','OPTIONS']Allowed HTTP methods.
headersstring[]['Content-Type','Authorization']Allowed request headers.
maxAgenumber86400Preflight cache max-age in seconds.

Secrets (SOPS)

typescript
secrets: {
  provider: 'sops',
  filePattern: 'secrets.{env}.enc.yaml',
}
OptionTypeDefaultDescription
provider'sops'Secrets provider. Only sops is supported.
filePatternstringsecrets.{env}.enc.yamlEncrypted file pattern. {env} is replaced with staging or prod.

Per-Lambda secrets are mapped in defineLambda({ secrets: { ENV_VAR: 'sops.key.path' } }).


SNS

typescript
sns: {
  topics: [{ name: 'notifications' }],
  platformApplications: [
    {
      name: 'my-app',
      platform: 'APNS_SANDBOX',
      credentialSecret: 'apns.privateKey',
      principalSecret: 'apns.certificate',
    }
  ],
}
OptionTypeDescription
topics[].namestringTopic name. Wired as env var.
platformApplications[].namestringApplication name.
platformApplications[].platform'APNS' | 'APNS_SANDBOX' | 'GCM'Push platform.
platformApplications[].credentialSecretstringSOPS key path for the platform credential.
platformApplications[].principalSecretstringSOPS key path for the platform principal.
platformApplications[].resourceNamestringOverride for the Terraform resource identifier.

CloudFront (API Distribution)

typescript
cloudfront: {
  apiDistribution: {
    geoRestriction: { type: 'whitelist', locations: ['US', 'CA'] },
    forwardedHeaders: ['Authorization', 'X-API-Key'],
    cacheTtl: { default: 0, min: 0, max: 0 },
  }
}
OptionTypeDescription
apiDistribution.geoRestrictionobjecttype: whitelist or blacklist. locations: ISO 3166-1 alpha-2 codes.
apiDistribution.forwardedHeadersstring[]Headers forwarded to the origin.
apiDistribution.cacheTtlobjectCache TTL settings: default, min, max in seconds.

Custom Lambda Layers

typescript
layers: [
  {
    name: 'ffmpeg',
    path: 'layers/ffmpeg',
    compatibleArchitectures: ['x86_64'],
    description: 'ffmpeg binary',
  }
]
OptionTypeDefaultDescription
namestringLayer name. Referenced in defineLambda({ layers: ['local.ffmpeg_layer_arn'] }).
pathstringPath to layer source directory, relative to project root.
compatibleArchitecturesstring[]['arm64']arm64 and/or x86_64.
compatibleRuntimesstring[]Compatible runtimes (e.g. ['nodejs24.x']). Omit for binary-only layers.
descriptionstringHuman-readable description.

Custom Terraform Variables

typescript
customVariables: [
  {
    name: 'api_quota_limit',
    type: 'number',
    description: 'Daily API quota',
    default: '10000',
  }
]
OptionTypeDescription
namestringVariable name.
typestringTerraform type expression: string, number, bool, list(string), etc.
descriptionstringVariable description.
defaultstringDefault value as Terraform expression string. Omit for required variables.
sensitivebooleanMark as sensitive (redacted in plan output).
validationobjectcondition: Terraform expression. errorMessage: shown on violation.

Authorizer

typescript
authorizer: { cacheTtl: 0 }
OptionTypeDefaultDescription
cacheTtlnumber300Token cache TTL in seconds. 0 disables caching and identity source validation.

Extended CLI Config

For CI, hooks, and conventions settings, use defineToolingConfig from @mantleframework/cli/config instead of defineConfig. See the CLI reference for details.