Kiro steering for AWS-native apps with CDK: supported Lambda runtimes, NodejsFunction bundling, least-privilege grants, DynamoDB access patterns and safe Lambda handlers.
.kiro/steering/kiro-aws-full-stack-development.md. Downloaded files need to be placed in that repository path.---
inclusion: fileMatch
fileMatchPattern: "**/*"
---
Apply these rules when building AWS-native applications with the AWS CDK (TypeScript).
## Architecture
- Define all infrastructure with CDK (`aws-cdk-lib` v2); no console-created resources for anything the app depends on.
- Prefer managed serverless services (Lambda, API Gateway, DynamoDB, SQS, EventBridge) and Step Functions for multi-step workflows with retries.
- Grant least privilege through CDK grant methods (`table.grantReadData(fn)` for read-only functions; `grantReadWriteData` only when the function writes). Never use `*` actions or resources in hand-written policies without a documented reason.
- Use a Lambda runtime that is still supported. Check the AWS Lambda runtimes page: `nodejs20.x` reached deprecation on April 30, 2026; use `nodejs22.x` or `nodejs24.x`.
## CDK patterns
```ts
import * as cdk from 'aws-cdk-lib';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
import type { Construct } from 'constructs';
export class UsersStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const table = new dynamodb.TableV2(this, 'Table', {
partitionKey: { name: 'pk', type: dynamodb.AttributeType.STRING },
sortKey: { name: 'sk', type: dynamodb.AttributeType.STRING },
billing: dynamodb.Billing.onDemand(),
removalPolicy: cdk.RemovalPolicy.RETAIN,
});
const getUser = new NodejsFunction(this, 'GetUser', {
entry: 'lambda/get-user.ts',
runtime: lambda.Runtime.NODEJS_22_X, // set explicitly; the construct's default depends on a feature flag
environment: { TABLE_NAME: table.tableName },
});
table.grantReadData(getUser);
}
}
```
- `NodejsFunction` bundles TypeScript with esbuild. Always set `runtime` explicitly.
- Retain stateful resources (tables, buckets) on stack deletion in production and enable point-in-time recovery for tables that hold user data (check the property name in your aws-cdk-lib version's TableV2 docs).
## Lambda handler
```ts
import type { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocumentClient, GetCommand } from '@aws-sdk/lib-dynamodb';
const doc = DynamoDBDocumentClient.from(new DynamoDBClient({})); // reused across invocations
const TABLE_NAME = process.env.TABLE_NAME;
const json = (statusCode: number, body: unknown): APIGatewayProxyResult => ({
statusCode,
headers: { 'content-type': 'application/json' },
body: JSON.stringify(body),
});
export async function handler(event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> {
const id = event.pathParameters?.id;
if (!id) return json(400, { error: 'id is required' });
try {
const result = await doc.send(
new GetCommand({ TableName: TABLE_NAME, Key: { pk: `USER#${id}`, sk: 'PROFILE' } })
);
if (!result.Item) return json(404, { error: 'Not found' });
return json(200, result.Item);
} catch (error) {
console.error('get-user failed', { id, error });
return json(500, { error: 'Internal error' });
}
}
```
- Create SDK clients outside the handler so they are reused; use AWS SDK v3 modular clients.
- Validate path, query and body input before using it; do not return internal error details.
- Use structured logging (Powertools for AWS Lambda) and set alarms on errors and throttles.
## Testing and deployment
- Unit-test handlers with the SDK client mocked (for example `aws-sdk-client-mock`), and assert synthesized templates with `aws-cdk-lib/assertions`.
- Run `cdk diff` before every deploy and deploy through CI with short-lived credentials (OIDC), not long-lived access keys.
Cursor rules for Next.js 14+ App Router projects updated for Next.js 16 with async params, validated Route Handlers, generateMetadata and proxy.ts in place of middleware.
CLAUDE.md rules for the Next.js 16 App Router with async params, streaming via Suspense, secured Server Actions, metadata conventions and explicit caching choices.
Copilot instructions for Next.js App Router code with awaited params, authenticated Server Actions, typed Route Handlers and explicit caching.
Kiro
fullstack
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A Kiro workspace's CDK stack uses lambda.Function with Runtime.NODEJS_20_X and grantReadWriteData for a read-only endpoint; the handler non-null-asserts pathParameters.
Update infra/users-stack.ts and lambda/get-user.ts following the AWS full-stack steering file.
The stack uses NodejsFunction with an explicit NODEJS_22_X (or 24) runtime, grantReadData instead of read-write, a retained table with point-in-time recovery; the handler validates pathParameters.id, uses DynamoDBDocumentClient + GetCommand created outside the handler, returns JSON with content-type, and the answer lists cdk diff and the assertion tests to run.
Kiro, built and operated by AWS, uses steering files: Markdown documents in .kiro/steering/ that give the agent persistent project knowledge. Front matter controls when each file is included: always, when matching files are in context, manually by #name, or automatically by description. Kiro also includes AGENTS.md files.
.kiro/steering/kiro-aws-full-stack-development.mdStarting point, not a tested configuration for your repository. Included when files matching fileMatchPattern are in context. Review the instructions, adapt the file paths and run your project's existing checks.
---
inclusion: fileMatch
fileMatchPattern: "**/*"
---
Apply these rules when building AWS-native applications with the AWS CDK (TypeScript).
## Architecture
- Define all infrastructure with CDK (`aws-cdk-lib` v2); no console-created resources for anything the app depends on.
- Prefer managed serverless services (Lambda, API Gateway, DynamoDB, SQS, EventBridge) and Step Functions for multi-step workflows with retries.
- Grant least privilege through CDK grant methods (`table.grantReadData(fn)` for read-only functions; `grantReadWriteData` only when the function writes). Never use `*` actions or resources in hand-written policies without a documented reason.
- Use a Lambda runtime that is still supported. Check the AWS Lambda runtimes page: `nodejs20.x` reached deprecation on April 30, 2026; use `nodejs22.x` or `nodejs24.x`.
## CDK patterns
```ts
import * as cdk from 'aws-cdk-lib';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
import type { Construct } from 'constructs';
export class UsersStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const table = new dynamodb.TableV2(this, 'Table', {
partitionKey: { name: 'pk', type: dynamodb.AttributeType.STRING },
sortKey: { name: 'sk', type: dynamodb.AttributeType.STRING },
billing: dynamodb.Billing.onDemand(),
removalPolicy: cdk.RemovalPolicy.RETAIN,
});
const getUser = new NodejsFunction(this, 'GetUser', {
entry: 'lambda/get-user.ts',
runtime: lambda.Runtime.NODEJS_22_X, // set explicitly; the construct's default depends on a feature flag
environment: { TABLE_NAME: table.tableName },
});
table.grantReadData(getUser);
}
}
```
- `NodejsFunction` bundles TypeScript with esbuild. Always set `runtime` explicitly.
- Retain stateful resources (tables, buckets) on stack deletion in production and enable point-in-time recovery for tables that hold user data (check the property name in your aws-cdk-lib version's TableV2 docs).
## Lambda handler
```ts
import type { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocumentClient, GetCommand } from '@aws-sdk/lib-dynamodb';
const doc = DynamoDBDocumentClient.from(new DynamoDBClient({})); // reused across invocations
const TABLE_NAME = process.env.TABLE_NAME;
const json = (statusCode: number, body: unknown): APIGatewayProxyResult => ({
statusCode,
headers: { 'content-type': 'application/json' },
body: JSON.stringify(body),
});
export async function handler(event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> {
const id = event.pathParameters?.id;
if (!id) return json(400, { error: 'id is required' });
try {
const result = await doc.send(
new GetCommand({ TableName: TABLE_NAME, Key: { pk: `USER#${id}`, sk: 'PROFILE' } })
);
if (!result.Item) return json(404, { error: 'Not found' });
return json(200, result.Item);
} catch (error) {
console.error('get-user failed', { id, error });
return json(500, { error: 'Internal error' });
}
}
```
- Create SDK clients outside the handler so they are reused; use AWS SDK v3 modular clients.
- Validate path, query and body input before using it; do not return internal error details.
- Use structured logging (Powertools for AWS Lambda) and set alarms on errors and throttles.
## Testing and deployment
- Unit-test handlers with the SDK client mocked (for example `aws-sdk-client-mock`), and assert synthesized templates with `aws-cdk-lib/assertions`.
- Run `cdk diff` before every deploy and deploy through CI with short-lived credentials (OIDC), not long-lived access keys.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Front matter must be at the very beginning of a steering file to be recognized. Kiro supports AGENTS.md. According to the steering docs, AGENTS.md files do not support inclusion modes and are always included, so keep scoped guidance in .kiro/steering/ files instead.
Documentation checked 2026-11-05: Kiro docs: SteeringKiro home page
Cursor rules for Next.js 14+ App Router projects updated for Next.js 16 with async params, validated Route Handlers, generateMetadata and proxy.ts in place of middleware.
CLAUDE.md rules for the Next.js 16 App Router with async params, streaming via Suspense, secured Server Actions, metadata conventions and explicit caching choices.
Copilot instructions for Next.js App Router code with awaited params, authenticated Server Actions, typed Route Handlers and explicit caching.