multi-environment

AWS CDK rules for deploying the same application to separate environments such as development, staging, and production, using different settings and resource names for each.

In plain words
What is it for?
Use it to configure stage-specific logging, concurrency, stack names, and conditional resources through CDK context and application settings.
Why use it?
It prevents environment-specific settings from being mixed together and allows resources or performance options to vary safely by stage.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

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

Made for: Cursor.

Per session 20 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 986 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00020 $0.00986
Opus 5 $0.00010 $0.00493
Sonnet 5 $0.00004 $0.00197
Haiku 4.5 $0.00002 $0.00099

Measured 2d ago against content hash 7e165203936f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

multi-environment 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 2d 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/multi-environment.mdc · 153 lines

How it starts

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

Multi-Environment CDK

Overview

Use CDK context and environment parameters to deploy the same app to dev, staging, and prod with stage-specific configuration. Use conditional resources (e.g. provisioned concurrency only in prod) and stage-aware stack names.

Context and cdk.json

// cdk.json
{
  "app": "npx ts-node bin/app.ts",
  "context": {
    "dev": {
      "stage": "dev",
      "logLevel": "DEBUG",
      "provisionedConcurrency": 0
    },
    "staging": {
      "stage": "staging",
      "logLevel": "INFO",
      "provisionedConcurrency": 1
    },
    "prod": {
      "stage": "prod",
      "logLevel": "WARN",
      "provisionedConcurrency": 5
    }
  }
}

Stage-Aware App Entry

// cdk/bin/app.ts

import "source-map-support/register";
import { App, Environment } from "aws-cdk-lib";
import { DataStack } from "../lib/stacks/data-stack";
import { ApiStack } from "../lib/stacks/api-stack";

const app = new App();

const stage = app.node.tryGetContext("stage") ?? "dev";
const context = app.node.tryGetContext(stage) ?? {};
const env: Environment = {
  account: process.env.CDK_DEFAULT_ACCOUNT,
  region: process.env.CDK_DEFAULT_REGION ?? "us-east-1",
};

const dataStack = new DataStack(app, `RealEstateData-${stage}`, {
  env,
  stage,
  ...context,
});

new ApiStack(app, `RealEstateApi-${stage}`, {
  env,
  stage,
  dataTable: dataStack.dataTable,
  idempotencyTable: dataStack.idempotencyTable,
  opensearchEndpoint: dataStack.opensearchEndpoint,
  ...context,
});

app.synth();

Conditional Resources

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

import { Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import { Alias } from "aws-cdk-lib/aws-lambda";
import { StandardLambda } from "../constructs/lambda-function";

interface ApiStackProps extends StackProps {
  stage: string;
  provisionedConcurrency?: number;
  dataTable: Table;
}

export class ApiStack extends Stack {
  constructor(scope: Construct, id: string, props: ApiStackProps) {
    super(scope, id, props);

    const criticalHandler = new StandardLambda(this, "CriticalHandler", {
      entry: "src/functions/critical/handler.ts",
      handler: "handler",
      memorySize: 512,
      timeoutSeconds: 30,
      environment: {
        STAGE: props.stage,
        LOG_LEVEL: props.logLevel ?? "INFO",
      },
    });

    if ((props.provisionedConcurrency ?? 0) > 0) {
      const version = criticalHandler.currentVersion;
      new Alias(this, "CriticalAlias", {
        aliasName: "live",
        version,
        provisionedConcurrentExecutions: props.provisionedConcurrency,
      });
    }
  }
}

Read the full file on GitHub · 153 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. 2d ago First seen · 153 lines · 20 tokens per session scan A 7e165203936f

Subscribe to this mod's changes

multi-environment is a cursor rule published in the GitHub repository GoranErhartic/cursor-development-rules (19 stars, last pushed 6mo ago), licensed MIT. It adds 20 tokens to every session and 986 once invoked, about $0.0001 per session on Opus 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.