or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

compute.mdcore.mddatabase.mddeveloper-tools.mdindex.mdintegration.mdmonitoring.mdnetworking.mdsecurity.mdstorage.mdtesting.md
tile.json

core.mddocs/

Core Framework

The CDK core framework provides the fundamental constructs and utilities that form the foundation of all CDK applications. These include the application structure, resource management, and CloudFormation integration.

Capabilities

Application Structure

Core constructs for organizing CDK applications into hierarchical structures.

/**
 * A CDK app represents the root of the construct tree
 */
class App extends Construct {
  constructor(props?: AppProps);
  
  /**
   * Synthesize the app into CloudFormation templates
   */
  synth(): CloudAssembly;
  
  readonly outdir: string;
  readonly node: Node;
}

/**
 * A unit of deployment that gets rendered as a CloudFormation stack
 */
class Stack extends Construct {
  constructor(scope: Construct, id: string, props?: StackProps);
  
  /**
   * Add a dependency between this stack and another stack
   */
  addDependency(target: Stack, reason?: string): void;
  
  /**
   * Add a transform to this stack
   */
  addTransform(transform: string): void;
  
  /**
   * Export a value from this stack
   */
  exportValue(exportedValue: any, options?: ExportValueOptions): string;
  
  readonly account: string;
  readonly region: string;
  readonly stackName: string;
  readonly stackId: string;
  readonly availabilityZones: string[];
  readonly dependencies: Stack[];
  readonly environment: string;
  readonly nested: boolean;
  readonly nestedStackParent?: Stack;
  readonly nestedStackResource?: CfnNestedStack;
  readonly notificationArns: string[];
  readonly partition: string;
  readonly stackTraces: boolean;
  readonly synthesizer: IStackSynthesizer;
  readonly tags: TagManager;
  readonly templateFile: string;
  readonly templateOptions: ITemplateOptions;
  readonly terminationProtection: boolean;
  readonly urlSuffix: string;
}

/**
 * An ordered collection of stacks that will be deployed as a unit
 */
class Stage extends Construct {
  constructor(scope: Construct, id: string, props?: StageProps);
  
  /**
   * Add a dependency between this stage and another stage
   */
  addDependency(target: Stage): void;
  
  /**
   * Synthesize this stage into CloudFormation templates
   */
  synth(): CloudAssembly;
  
  readonly account: string;
  readonly region: string;
  readonly stageName: string;
  readonly outdir: string;
}

Usage Examples:

import { App, Stack, Stage } from "aws-cdk-lib";
import { Construct } from "constructs";

// Create a CDK app
const app = new App();

// Create a simple stack
class MyStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);
    // Add resources here
  }
}

// Create a stage with multiple stacks
class MyStage extends Stage {
  constructor(scope: Construct, id: string, props?: StageProps) {
    super(scope, id, props);
    
    new MyStack(this, "Frontend");
    new MyStack(this, "Backend");
  }
}

// Instantiate
new MyStage(app, "Production", {
  env: { account: "123456789012", region: "us-east-1" }
});

// Synthesize the app
app.synth();

Resource Management

Base classes and interfaces for all AWS resources in CDK.

/**
 * Base class for all AWS resources
 */
abstract class Resource extends Construct implements IResource {
  constructor(scope: Construct, id: string, props?: ResourceProps);
  
  /**
   * Apply the given removal policy to this resource
   */
  applyRemovalPolicy(policy: RemovalPolicy): void;
  
  readonly env: ResourceEnvironment;
  readonly stack: Stack;
  readonly node: Node;
}

/**
 * Interface that all resources must implement
 */
interface IResource extends IConstruct {
  readonly env: ResourceEnvironment;
  readonly stack: Stack;
  applyRemovalPolicy(policy: RemovalPolicy): void;
}

/**
 * Base class for CloudFormation resources
 */
class CfnResource extends CfnElement {
  constructor(scope: Construct, id: string, props: CfnResourceProps);
  
  /**
   * Add a dependency on another resource
   */
  addDependency(target: CfnResource): void;
  
  /**
   * Add an override to the synthesized CloudFormation resource
   */
  addOverride(path: string, value: any): void;
  
  /**
   * Add a property override
   */
  addPropertyOverride(propertyPath: string, value: any): void;
  
  /**
   * Get an attribute from the CloudFormation resource
   */
  getAtt(attributeName: string): Reference;
  
  readonly cfnResourceType: string;
  readonly cfnProperties: { [key: string]: any };
  readonly cfnOptions: ICfnResourceOptions;
  readonly ref: string;
  readonly stack: Stack;
}

CloudFormation Elements

Low-level CloudFormation constructs for parameters, outputs, conditions, and mappings.

/**
 * Base class for all CloudFormation elements
 */
abstract class CfnElement extends Construct {
  readonly creationStack: string[];
  readonly logicalId: string;
  readonly stack: Stack;
  
  /**
   * Overrides the auto-generated logical ID
   */
  overrideLogicalId(newLogicalId: string): void;
}

/**
 * CloudFormation parameter
 */
class CfnParameter extends CfnElement {
  constructor(scope: Construct, id: string, props?: CfnParameterProps);
  
  /**
   * The parameter value as a Token
   */
  readonly value: IResolvable;
  
  /**
   * The parameter value as a string
   */
  readonly valueAsString: string;
  
  /**
   * The parameter value as a number
   */
  readonly valueAsNumber: number;
  
  /**
   * The parameter value as a list
   */
  readonly valueAsList: string[];
}

/**
 * CloudFormation output
 */
class CfnOutput extends CfnElement {
  constructor(scope: Construct, id: string, props: CfnOutputProps);
  
  /**
   * Import an exported value from another stack
   */
  static importValue(exportName: string): string;
  
  readonly value: string;
  readonly description?: string;
  readonly exportName?: string;
  readonly condition?: CfnCondition;
}

/**
 * CloudFormation condition
 */
class CfnCondition extends CfnElement {
  constructor(scope: Construct, id: string, props: CfnConditionProps);
  
  readonly expression: ICfnConditionExpression;
}

/**
 * CloudFormation mapping
 */
class CfnMapping extends CfnElement {
  constructor(scope: Construct, id: string, props: CfnMappingProps);
  
  /**
   * Retrieves a value from the mapping
   */
  findInMap(key1: string, key2: string): string;
  
  /**
   * Sets a value in the mapping
   */
  setValue(key1: string, key2: string, value: any): void;
}

Utility Classes

Essential utility classes for working with CloudFormation values, ARNs, durations, and sizes.

/**
 * Represents a CloudFormation token
 */
class Token {
  /**
   * Returns true if obj represents an unresolved value
   */
  static isUnresolved(obj: any): boolean;
  
  /**
   * Return a string that represents the given value
   */
  static asString(value: any, options?: EncodingOptions): string;
  
  /**
   * Return a number that represents the given value
   */
  static asNumber(value: any): number;
  
  /**
   * Return a list that represents the given value
   */
  static asList(value: any, options?: EncodingOptions): string[];
  
  /**
   * Return an object that represents the given value
   */
  static asAny(value: any): IResolvable;
}

/**
 * CloudFormation intrinsic functions
 */
class Fn {
  /**
   * Returns the value of a parameter
   */
  static ref(logicalName: string): string;
  
  /**
   * Returns the value of an attribute from a resource
   */
  static getAtt(logicalNameOfResource: string, attributeName: string): Reference;
  
  /**
   * Joins a list of values with a delimiter
   */
  static join(delimiter: string, listOfValues: string[]): string;
  
  /**
   * Splits a string into a list of strings
   */
  static split(delimiter: string, source: string): string[];
  
  /**
   * Returns a subset of a string
   */
  static select(index: number, listOfObjects: string[]): string;
  
  /**
   * Appends a set of values to an existing array
   */
  static sub(template: string, variables?: { [key: string]: string }): string;
  
  /**
   * Converts the specified stack to Base64
   */
  static base64(data: string): string;
  
  /**
   * Returns a list of availability zones for the region
   */
  static getAzs(region?: string): string[];
  
  /**
   * Conditionally creates stack resources
   */
  static conditionIf(conditionId: string, valueIfTrue: any, valueIfFalse: any): any;
  
  /**
   * Returns true if all conditions are true
   */
  static conditionAnd(...conditions: ICfnConditionExpression[]): ICfnConditionExpression;
  
  /**
   * Returns true if any condition is true
   */
  static conditionOr(...conditions: ICfnConditionExpression[]): ICfnConditionExpression;
  
  /**
   * Returns the opposite of a condition
   */
  static conditionNot(condition: ICfnConditionExpression): ICfnConditionExpression;
  
  /**
   * Compares if two values are equal
   */
  static conditionEquals(lhs: any, rhs: any): ICfnConditionExpression;
}

/**
 * ARN manipulation utilities
 */
class Arn {
  /**
   * Creates an ARN from components
   */
  static format(components: ArnComponents, stack: Stack): string;
  
  /**
   * Splits an ARN into its components
   */
  static split(arn: string, arnFormat: ArnFormat): ArnComponents;
  
  /**
   * Extract the resource name from an ARN
   */
  static extractResourceName(arn: string, resourceType: string): string;
}

/**
 * Represents a time duration
 */
class Duration {
  /**
   * Create a Duration representing an amount of milliseconds
   */
  static millis(amount: number): Duration;
  
  /**
   * Create a Duration representing an amount of seconds
   */
  static seconds(amount: number): Duration;
  
  /**
   * Create a Duration representing an amount of minutes
   */
  static minutes(amount: number): Duration;
  
  /**
   * Create a Duration representing an amount of hours
   */
  static hours(amount: number): Duration;
  
  /**
   * Create a Duration representing an amount of days
   */
  static days(amount: number): Duration;
  
  /**
   * Return the total number of milliseconds in this Duration
   */
  toMilliseconds(): number;
  
  /**
   * Return the total number of seconds in this Duration
   */
  toSeconds(): number;
  
  /**
   * Return the total number of minutes in this Duration
   */
  toMinutes(): number;
  
  /**
   * Return the total number of hours in this Duration
   */
  toHours(): number;
  
  /**
   * Return the total number of days in this Duration
   */
  toDays(): number;
  
  /**
   * Return an ISO 8601 representation of this period
   */
  toIsoString(): string;
  
  /**
   * Return a human-readable representation of this period
   */
  toHumanString(): string;
}

/**
 * Represents a data size
 */
class Size {
  /**
   * Create a size in bytes
   */
  static bytes(amount: number): Size;
  
  /**
   * Create a size in kibibytes
   */
  static kibibytes(amount: number): Size;
  
  /**
   * Create a size in mebibytes
   */
  static mebibytes(amount: number): Size;
  
  /**
   * Create a size in gibibytes
   */
  static gibibytes(amount: number): Size;
  
  /**
   * Create a size in tebibytes
   */
  static tebibytes(amount: number): Size;
  
  /**
   * Create a size in pebibytes
   */
  static pebibytes(amount: number): Size;
  
  /**
   * Return the size in bytes
   */
  toBytes(): number;
  
  /**
   * Return the size in kibibytes
   */
  toKibibytes(): number;
  
  /**
   * Return the size in mebibytes
   */
  toMebibytes(): number;
  
  /**
   * Return the size in gibibytes
   */
  toGibibytes(): number;
  
  /**
   * Return the size in tebibytes
   */
  toTebibytes(): number;
  
  /**
   * Return the size in pebibytes
   */
  toPebibytes(): number;
}

Tagging

Resource tagging utilities for organizing and managing AWS resources.

/**
 * Manages tags for resources
 */
class Tags {
  /**
   * Add tags to all constructs in the given scope
   */
  static of(scope: IConstruct): Tags;
  
  /**
   * Add a tag with the given key and value
   */
  add(key: string, value: string, props?: TagProps): void;
  
  /**
   * Remove a tag with the given key
   */
  remove(key: string, props?: TagProps): void;
  
  /**
   * Render tags for CloudFormation
   */
  renderTags(): any;
}

/**
 * Manages tag aspects for applying tags across constructs
 */
class TagManager {
  constructor(tagType: TagType, resourceTypeName: string, initialTags?: any, options?: TagManagerOptions);
  
  /**
   * Adds the specified tag to the array of tags
   */
  setTag(key: string, value: string, priority?: number, applyToLaunchedInstances?: boolean): void;
  
  /**
   * Removes the specified tag from the array of tags
   */
  removeTag(key: string, priority: number): void;
  
  /**
   * Renders tags into the proper format based on TagType
   */
  renderTags(): any;
  
  /**
   * Render the tags in a readable format
   */
  tagValues(): { [key: string]: string };
}

Types

interface AppProps {
  readonly analyticsReporting?: boolean;
  readonly autoSynth?: boolean;
  readonly context?: { [key: string]: any };
  readonly outdir?: string;
  readonly stackTraces?: boolean;
  readonly treeMetadata?: boolean;
}

interface StackProps {
  readonly analyticsReporting?: boolean;
  readonly crossRegionReferences?: boolean;
  readonly description?: string;
  readonly env?: Environment;
  readonly stackName?: string;
  readonly synthesizer?: IStackSynthesizer;
  readonly tags?: { [key: string]: string };
  readonly terminationProtection?: boolean;
}

interface StageProps {
  readonly env?: Environment;
  readonly outdir?: string;
  readonly permissionsBoundary?: PermissionsBoundary;
  readonly policyValidationBeta1?: IPolicyValidationPluginBeta1[];
  readonly stageName?: string;
}

interface ResourceProps {
  readonly account?: string;
  readonly environmentFromArn?: string;
  readonly physicalName?: string;
  readonly region?: string;
}

interface Environment {
  readonly account?: string;
  readonly region?: string;
}

interface ArnComponents {
  readonly partition?: string;
  readonly service?: string;
  readonly region?: string;
  readonly account?: string;
  readonly resource: string;
  readonly resourceName?: string;
  readonly arnFormat?: ArnFormat;
}

enum ArnFormat {
  NO_RESOURCE_NAME = 0,
  SLASH_RESOURCE_NAME = 1,
  COLON_RESOURCE_NAME = 2,
  SLASH_RESOURCE_SLASH_RESOURCE_NAME = 3
}

enum RemovalPolicy {
  DESTROY = "destroy",
  RETAIN = "retain",
  SNAPSHOT = "snapshot"
}

interface CfnResourceProps {
  readonly type: string;
  readonly properties?: { [key: string]: any };
}

interface CfnParameterProps {
  readonly type?: string;
  readonly default?: any;
  readonly allowedPattern?: string;
  readonly allowedValues?: string[];
  readonly constraintDescription?: string;
  readonly description?: string;
  readonly maxLength?: number;
  readonly maxValue?: number;
  readonly minLength?: number;
  readonly minValue?: number;
  readonly noEcho?: boolean;
}

interface CfnOutputProps {
  readonly value: string;
  readonly condition?: CfnCondition;
  readonly description?: string;
  readonly exportName?: string;
}

interface CfnConditionProps {
  readonly expression: ICfnConditionExpression;
}

interface CfnMappingProps {
  readonly mapping: { [k1: string]: { [k2: string]: any } };
}

interface TagProps {
  readonly applyToLaunchedInstances?: boolean;
  readonly excludeResourceTypes?: string[];
  readonly includeResourceTypes?: string[];
  readonly priority?: number;
}

enum TagType {
  STANDARD = "StandardTags",
  AUTOSCALING_GROUP = "AutoScalingGroupTags",
  MAP = "StringToStringMap",
  KEY_VALUE = "KeyValue",
  NOT_TAGGABLE = "NotTaggable"
}