cdk-infrastructure-lambda

cdk-infrastructure-lambda is a cursor rule for Cursor from GoranErhartic/cursor-development-rules. It costs 17 tokens per session (1,657 once invoked), scanned A, original, MIT.

A reusable AWS CDK construct for configuring Node.js Lambda functions. It sets common runtime, architecture, memory, timeout, tracing, logging, environment, and bundling options.

In plain words
What is it for?
Creating standard Lambda functions with esbuild, choosing memory and timeout settings, attaching layers, enabling tracing, and supplying environment variables.
Why use it?
It keeps function configuration consistent across a project and reduces repeated setup code when adding new Lambda handlers.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { StandardLambda } from "../constructs/lambda-function";.

Good fit Creating standard Lambda functions with esbuild, choosing memory and timeout settings, attaching layers, enabling tracing, and supplying environment variables.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/GoranErhartic/cursor-development-rules
agentmods
npx agentmods add rules/goranerhartic/cursor-development-rules/cdk-infrastructure-lambda

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cdk-infrastructure-lambda

README.md
[![agentmods](https://agentmods.dev/badge/rules/goranerhartic/cursor-development-rules/cdk-infrastructure-lambda/github.svg)](https://agentmods.dev/rules/goranerhartic/cursor-development-rules/cdk-infrastructure-lambda)
Your own site
<a href="https://agentmods.dev/rules/goranerhartic/cursor-development-rules/cdk-infrastructure-lambda"><img src="https://agentmods.dev/badge/rules/goranerhartic/cursor-development-rules/cdk-infrastructure-lambda/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cdk-infrastructure-lambda

Your own site · 80×15
<a href="https://agentmods.dev/rules/goranerhartic/cursor-development-rules/cdk-infrastructure-lambda"><img src="https://agentmods.dev/badge/rules/goranerhartic/cursor-development-rules/cdk-infrastructure-lambda.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,657 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00017 $0.01657
Opus 5.5 $0.00007 $0.00663
Sonnet 5.5 $0.00003 $0.00331
Haiku 4.5 $0.00002 $0.00166

Measured 1mo ago against content hash 34ca530f78fc, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cdk-infrastructure-lambda scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/languages/aws-lambda/cdk-infrastructure-lambda.mdc · 237 lines

How it starts

The opening of the file, as written. The whole thing — 237 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Lambda Function Construct

Standard Lambda Configuration

// cdk/lib/constructs/lambda-function.ts

import { Construct } from "constructs";
import { Duration } from "aws-cdk-lib";
import {
  Runtime,
  Tracing,
  Architecture,
  Function as LambdaFunction,
  FunctionProps,
  LayerVersion,
} from "aws-cdk-lib/aws-lambda";
import { NodejsFunction, NodejsFunctionProps } from "aws-cdk-lib/aws-lambda-nodejs";
import { RetentionDays } from "aws-cdk-lib/aws-logs";

export interface StandardLambdaProps extends Omit<NodejsFunctionProps, "runtime" | "architecture"> {
  /**
   * Memory size in MB
   */
  memorySize?: number;
  
  /**
   * Timeout in seconds
   */
  timeoutSeconds?: number;
  
  /**
   * Reserved concurrency
   */
  reservedConcurrentExecutions?: number;
  
  /**
   * Enable X-Ray tracing
   */
  enableTracing?: boolean;
  
  /**
   * Layers to attach
   */
  layers?: LayerVersion[];
}

export class StandardLambda extends NodejsFunction {
  constructor(scope: Construct, id: string, props: StandardLambdaProps) {
    super(scope, id, {
      runtime: Runtime.NODEJS_22_X,
      architecture: Architecture.ARM_64, // Cost-effective
      memorySize: props.memorySize ?? 512,
      timeout: Duration.seconds(props.timeoutSeconds ?? 30),
      tracing: props.enableTracing !== false ? Tracing.ACTIVE : Tracing.DISABLED,
      logRetention: RetentionDays.TWO_WEEKS,
      reservedConcurrentExecutions: props.reservedConcurrentExecutions,
      bundling: {
        minify: true,
        sourceMap: true,
        sourcesContent: false,
        externalModules: [
          "@aws-sdk/*", // Use Lambda-provided SDK
        ],
        esbuildArgs: {
          "--tree-shaking": "true",
        },
        ...props.bundling,
      },
      environment: {
        NODE_OPTIONS: "--enable-source-maps",
        LOG_LEVEL: "info",
        ...props.environment,
      },
      ...props,
    });
  }
}

API Handler Lambda

// cdk/lib/stacks/api-stack.ts

import { Stack, StackProps, Duration } from "aws-cdk-lib";
import { Construct } from "constructs";
import { RestApi, LambdaIntegration, Cors } from "aws-cdk-lib/aws-apigateway";
import { StandardLambda } from "../constructs/lambda-function";
import { Table } from "aws-cdk-lib/aws-dynamodb";
import { Secret } from "aws-cdk-lib/aws-secretsmanager";

interface ApiStackProps extends StackProps {
  dataTable: Table;
  idempotencyTable: Table;
  databaseSecret: Secret;
  rdsProxyEndpoint: string;
}

export class ApiStack extends Stack {
  public readonly api: RestApi;

  constructor(scope: Construct, id: string, props: ApiStackProps) {
    super(scope, id, props);

    // Create API Gateway
    this.api = new RestApi(this, "RealEstateApi", {
      restApiName: "Real Estate API",
      defaultCorsPreflightOptions: {
        allowOrigins: Cors.ALL_ORIGINS,
        allowMethods: Cors.ALL_METHODS,
        allowHeaders: ["Content-Type", "Authorization", "X-Correlation-Id"],
      },
    });

    // Properties resource
    const properties = this.api.root.addResource("properties");
    const propertyById = properties.addResource("{propertyId}");

    // Create Property Handler
    const createPropertyHandler = new StandardLambda(this, "CreateProperty", {
      entry: "src/functions/create-property/handler.ts",
      handler: "handler",
      memorySize: 512,
      timeoutSeconds: 30,
      environment: {
        DYNAMODB_TABLE_NAME: props.dataTable.tableName,
        IDEMPOTENCY_TABLE_NAME: props.idempotencyTable.tableName,
        DATABASE_URL: `postgresql://user:password@${props.rdsProxyEndpoint}:5432/realestate?connection_limit=1`,
      },
    });

    props.dataTable.grantReadWriteData(createPropertyHandler);
    props.idempotencyTable.grantReadWriteData(createPropertyHandler);
    props.databaseSecret.grantRead(createPropertyHandler);

    properties.addMethod("POST", new LambdaIntegration(createPropertyHandler));

    // Get Property Handler
    const getPropertyHandler = new StandardLambda(this, "GetProperty", {
      entry: "src/functions/get-property/handler.ts",
      handler: "handler",
      memorySize: 256,
      timeoutSeconds: 10,
      environment: {
        DYNAMODB_TABLE_NAME: props.dataTable.tableName,
      },
    });

    props.dataTable.grantReadData(getPropertyHandler);

    propertyById.addMethod("GET", new LambdaIntegration(getPropertyHandler));

    // Listings resource
    const listings = properties.addResource("listings");

    // Search Properties Handler
    const searchHandler = new StandardLambda(this, "SearchProperties", {
      entry: "src/functions/search-properties/handler.ts",
      handler: "handler",
      memorySize: 1024,
      timeoutSeconds: 30,
      environment: {
        OPENSEARCH_ENDPOINT: props.opensearchEndpoint,
        LISTINGS_INDEX: "listings",
      },
    });

    this.api.root.addResource("search").addMethod(
      "GET",
      new LambdaIntegration(searchHandler)
    );
  }
}

Read the full file on GitHub · 237 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 237 lines · 17 tokens per session scan A 34ca530f78fc

Subscribe to this mod's changes

cdk-infrastructure-lambda is a cursor rule published in the GitHub repository GoranErhartic/cursor-development-rules (19 stars, last pushed 7mo ago), licensed MIT. It adds 17 tokens to every session and 1,657 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.