CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-projen

CDK for software projects - synthesizes configuration files from well-typed JavaScript/TypeScript definitions.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

awscdk-projects.mddocs/

AWS CDK Projects

AWS CDK applications and construct libraries for cloud infrastructure. Provides comprehensive setup for AWS CDK projects across multiple programming languages with infrastructure-as-code best practices.

Capabilities

AwsCdkTypeScriptApp Class

AWS CDK application in TypeScript with comprehensive cloud development setup.

/**
 * AWS CDK application in TypeScript
 * Provides infrastructure-as-code development with AWS CDK
 */
class AwsCdkTypeScriptApp extends TypeScriptProject {
  constructor(options: AwsCdkTypeScriptAppOptions);
  
  /** CDK version being used */
  readonly cdkVersion: string;
  /** AWS constructs library version */
  readonly constructsVersion: string;
  /** CDK CLI integration */
  readonly cdkTask: Task;
  /** App entry point */
  readonly appEntrypoint: string;
}

interface AwsCdkTypeScriptAppOptions extends TypeScriptProjectOptions {
  /** AWS CDK version (default: "2.x") */
  cdkVersion?: string;
  /** CDK CLI version */
  cdkCliVersion?: string;
  /** Constructs version */
  constructsVersion?: string;
  /** CDK application entry point (default: "src/main.ts") */
  appEntrypoint?: string;
  /** Additional CDK dependencies */
  cdkDependencies?: string[];
  /** Enable CDK integration tests */
  integrationTests?: boolean;
  /** CDK context configuration */
  context?: Record<string, any>;
  /** Lambda bundling options */
  lambdaBundling?: boolean;
}

TypeScript CDK App Example:

import { AwsCdkTypeScriptApp } from "projen";

const app = new AwsCdkTypeScriptApp({
  name: "my-cdk-app",
  defaultReleaseBranch: "main",
  
  // CDK configuration
  cdkVersion: "2.100.0",
  appEntrypoint: "src/main.ts",
  
  // CDK dependencies
  cdkDependencies: [
    "@aws-cdk/aws-lambda",
    "@aws-cdk/aws-apigateway",
    "@aws-cdk/aws-dynamodb",
    "@aws-cdk/aws-s3",
  ],
  
  // TypeScript configuration
  srcdir: "src",
  testdir: "test",
  
  // Dependencies
  deps: [
    "aws-lambda",
    "@types/aws-lambda",
  ],
  devDeps: [
    "@aws-cdk/assert",
  ],
  
  // Enable integration tests
  integrationTests: true,
  
  // CDK context
  context: {
    "@aws-cdk/core:enableStackNameDuplicates": "true",
    "aws-cdk:enableDiffNoFail": "true",
  },
  
  // Lambda bundling
  lambdaBundling: true,
});

// Add CDK-specific tasks
app.addTask("deploy", {
  description: "Deploy the CDK app",
  exec: "cdk deploy",
});

app.addTask("diff", {
  description: "Show deployment diff",
  exec: "cdk diff",
});

app.addTask("destroy", {
  description: "Destroy the CDK app",
  exec: "cdk destroy",
});

AwsCdkPythonApp Class

AWS CDK application in Python with Python-specific CDK tooling.

/**
 * AWS CDK application in Python
 * Python-based infrastructure-as-code with AWS CDK
 */
class AwsCdkPythonApp extends PythonProject {
  constructor(options: AwsCdkPythonAppOptions);
  
  /** CDK version being used */
  readonly cdkVersion: string;
  /** CDK CLI integration */
  readonly cdkTask: Task;
  /** App entry point */
  readonly appEntrypoint: string;
}

interface AwsCdkPythonAppOptions extends PythonProjectOptions {
  /** AWS CDK version */
  cdkVersion?: string;
  /** CDK CLI version */
  cdkCliVersion?: string;
  /** CDK application entry point (default: "app.py") */
  appEntrypoint?: string;
  /** Additional CDK dependencies */
  cdkDependencies?: string[];
  /** CDK context configuration */
  context?: Record<string, any>;
}

Python CDK App Example:

import { AwsCdkPythonApp } from "projen";

const app = new AwsCdkPythonApp({
  name: "my-python-cdk-app",
  moduleName: "my_python_cdk_app",
  defaultReleaseBranch: "main",
  
  // CDK configuration
  cdkVersion: "2.100.0",
  appEntrypoint: "app.py",
  
  // Python version
  pythonVersion: ">=3.8",
  
  // CDK dependencies
  deps: [
    "aws-cdk-lib>=2.100.0",
    "constructs>=10.0.0",
  ],
  devDeps: [
    "pytest>=7.0.0",
    "aws-cdk.assertions>=2.100.0",
  ],
  
  // Use Poetry
  poetry: true,
});

AwsCdkJavaApp Class

AWS CDK application in Java with Maven build system.

/**
 * AWS CDK application in Java
 * Java-based infrastructure-as-code with AWS CDK and Maven
 */
class AwsCdkJavaApp extends JavaProject {
  constructor(options: AwsCdkJavaAppOptions);
  
  /** CDK version being used */
  readonly cdkVersion: string;
  /** CDK CLI integration */
  readonly cdkTask: Task;
  /** App entry point class */
  readonly mainClass: string;
}

interface AwsCdkJavaAppOptions extends JavaProjectOptions {
  /** AWS CDK version */
  cdkVersion?: string;
  /** CDK CLI version */
  cdkCliVersion?: string;
  /** Main application class */
  mainClass?: string;
  /** Additional CDK dependencies */
  cdkDependencies?: string[];
}

AwsCdkConstructLibrary Class

AWS CDK construct library for publishing reusable infrastructure components.

/**
 * AWS CDK construct library project
 * For creating and publishing reusable CDK constructs
 */
class AwsCdkConstructLibrary extends ConstructLibrary {
  constructor(options: AwsCdkConstructLibraryOptions);
  
  /** CDK version being used */
  readonly cdkVersion: string;
  /** Construct library configuration */
  readonly constructsVersion: string;
}

interface AwsCdkConstructLibraryOptions extends ConstructLibraryOptions {
  /** AWS CDK version */
  cdkVersion?: string;
  /** Constructs version */
  constructsVersion?: string;
  /** CDK dependencies for the library */
  cdkDependencies?: string[];
  /** Enable CDK assertions for testing */
  cdkAssert?: boolean;
  /** Integration test configuration */
  integrationTests?: boolean;
}

CDK Construct Library Example:

import { AwsCdkConstructLibrary } from "projen";

const lib = new AwsCdkConstructLibrary({
  name: "my-cdk-constructs",
  defaultReleaseBranch: "main",
  
  // Library metadata
  author: "CDK Developer",
  authorEmail: "cdk@example.com",
  description: "Reusable CDK constructs for common patterns",
  
  // CDK configuration
  cdkVersion: "2.100.0",
  constructsVersion: "10.0.0",
  
  // CDK dependencies
  cdkDependencies: [
    "@aws-cdk/aws-lambda",
    "@aws-cdk/aws-apigateway",
    "@aws-cdk/aws-dynamodb",
  ],
  
  // Publishing configuration
  publishToPypi: {
    distName: "my-cdk-constructs",
    module: "my_cdk_constructs",
  },
  publishToMaven: {
    javaPackage: "com.example.cdk.constructs",
    mavenGroupId: "com.example",
    mavenArtifactId: "cdk-constructs",
  },
  publishToNuget: {
    dotNetNamespace: "Example.Cdk.Constructs",
    packageId: "Example.Cdk.Constructs",
  },
  
  // Enable testing
  cdkAssert: true,
  integrationTests: true,
});

Lambda Function Integration

Integrated Lambda function development within CDK projects.

/**
 * Lambda function construct for CDK projects
 * Provides integrated Lambda development and deployment
 */
class LambdaFunction extends Component {
  constructor(project: AwsCdkTypeScriptApp, options: LambdaFunctionOptions);
  
  /** Function entry point */
  readonly entrypoint: string;
  /** Function handler */
  readonly handler: string;
  /** Runtime environment */
  readonly runtime: string;
}

interface LambdaFunctionOptions {
  /** Function name */
  name: string;
  /** Entry point file */
  entrypoint: string;
  /** Handler function */
  handler?: string;
  /** Runtime environment */
  runtime?: string;
  /** Environment variables */
  environment?: Record<string, string>;
  /** Memory allocation */
  memorySize?: number;
  /** Timeout in seconds */
  timeout?: number;
  /** Enable bundling */
  bundling?: boolean;
}

CDK Integration Tests

Integration testing framework for CDK applications.

/**
 * CDK integration testing framework
 * Provides end-to-end testing for CDK applications
 */
class IntegrationTest extends Component {
  constructor(project: AwsCdkTypeScriptApp, options?: IntegrationTestOptions);
  
  /** Integration test task */
  readonly testTask: Task;
  /** Test discovery patterns */
  readonly testPaths: string[];
}

interface IntegrationTestOptions {
  /** Test file patterns */
  testPaths?: string[];
  /** Test timeout */
  timeout?: number;
  /** Test environment */
  testEnvironment?: Record<string, string>;
  /** Stack naming pattern */
  stackNamingScheme?: string;
}

AutoDiscover Feature

Automatic discovery of CDK constructs and stacks.

/**
 * Automatic discovery of CDK constructs and stacks
 * Automatically generates CDK code based on file structure
 */
class AutoDiscover extends Component {
  constructor(project: AwsCdkTypeScriptApp, options?: AutoDiscoverOptions);
}

interface AutoDiscoverOptions {
  /** Source directories to discover */
  srcdir?: string;
  /** Test directories to discover */
  testdir?: string;
  /** Lambda function directories */
  lambdadir?: string;
  /** Integration test directories */
  integdir?: string;
}

Complete CDK Application Example:

import { AwsCdkTypeScriptApp } from "projen";

const app = new AwsCdkTypeScriptApp({
  name: "comprehensive-cdk-app",
  defaultReleaseBranch: "main",
  
  // Project metadata
  author: "Cloud Engineer",
  authorEmail: "cloud@example.com",
  description: "Comprehensive AWS CDK application",
  
  // CDK configuration
  cdkVersion: "2.100.0",
  appEntrypoint: "src/main.ts",
  
  // CDK dependencies for various AWS services
  cdkDependencies: [
    "@aws-cdk/aws-lambda",
    "@aws-cdk/aws-apigateway",
    "@aws-cdk/aws-dynamodb", 
    "@aws-cdk/aws-s3",
    "@aws-cdk/aws-cloudfront",
    "@aws-cdk/aws-route53",
    "@aws-cdk/aws-certificatemanager",
    "@aws-cdk/aws-iam",
    "@aws-cdk/aws-logs",
    "@aws-cdk/aws-sns",
    "@aws-cdk/aws-sqs",
  ],
  
  // Application dependencies
  deps: [
    "aws-lambda",
    "@types/aws-lambda",
    "aws-sdk",
    "@aws-sdk/client-dynamodb",
    "@aws-sdk/client-s3",
  ],
  devDeps: [
    "@aws-cdk/assertions",
    "aws-cdk-local",
  ],
  
  // TypeScript configuration
  srcdir: "src",
  testdir: "test",
  libdir: "lib",
  
  // CDK context for environment-specific settings
  context: {
    "@aws-cdk/core:enableStackNameDuplicates": "true",
    "aws-cdk:enableDiffNoFail": "true",
    "@aws-cdk/core:stackRelativeExports": "true",
  },
  
  // Enable features
  integrationTests: true,
  lambdaBundling: true,
});

// Add Lambda functions
new LambdaFunction(app, {
  name: "api-handler",
  entrypoint: "src/lambda/api-handler.ts",
  handler: "handler",
  runtime: "nodejs18.x",
  environment: {
    TABLE_NAME: "MyTable",
  },
});

new LambdaFunction(app, {
  name: "data-processor",
  entrypoint: "src/lambda/data-processor.ts",
  handler: "processData",
  runtime: "nodejs18.x",
  memorySize: 512,
  timeout: 300,
});

// Add CDK tasks
app.addTask("deploy:dev", {
  description: "Deploy to development environment",
  exec: "cdk deploy --profile dev",
});

app.addTask("deploy:prod", {
  description: "Deploy to production environment",
  exec: "cdk deploy --profile prod --require-approval never",
});

app.addTask("synth", {
  description: "Synthesize CDK templates",
  exec: "cdk synth",
});

app.addTask("bootstrap", {
  description: "Bootstrap CDK environment",
  exec: "cdk bootstrap",
});

app.addTask("local", {
  description: "Run CDK locally",
  exec: "cdklocal deploy",
});

// Integration tests
app.addTask("test:integration", {
  description: "Run integration tests",
  exec: "jest --testPathPattern=test/integration",
});

// Custom package.json fields for CDK
app.package.addField("cdk", {
  version: "2.100.0",
  app: "npx ts-node src/main.ts",
  context: {
    "@aws-cdk/core:enableStackNameDuplicates": "true",
  },
});

Types

AWS CDK-Specific Types

interface CdkConfig {
  /** CDK application entry point */
  app?: string;
  /** CDK version */
  version?: string;
  /** CDK context */
  context?: Record<string, any>;
  /** Feature flags */
  featureFlags?: Record<string, boolean>;
  /** Toolkit stack name */
  toolkitStackName?: string;
  /** Require approval for deployments */
  requireApproval?: "never" | "any-change" | "broadening";
}

interface LambdaRuntime {
  NODEJS_18_X: "nodejs18.x";
  NODEJS_16_X: "nodejs16.x";
  PYTHON_3_9: "python3.9";
  PYTHON_3_8: "python3.8";
  JAVA_11: "java11";
  JAVA_8: "java8";
  DOTNET_6: "dotnet6";
  GO_1_X: "go1.x";
}

interface StackProps {
  /** Stack name */
  stackName?: string;
  /** Stack description */
  description?: string;
  /** Environment (account/region) */
  env?: {
    account?: string;
    region?: string;
  };
  /** Tags */
  tags?: Record<string, string>;
  /** Termination protection */
  terminationProtection?: boolean;
}

Install with Tessl CLI

npx tessl i tessl/npm-projen

docs

awscdk-projects.md

core-project.md

dependency-management.md

file-management.md

github-integration.md

index.md

java-projects.md

nodejs-projects.md

python-projects.md

task-management.md

typescript-projects.md

web-projects.md

tile.json