or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

change-sets.mdclient-configuration.mddrift-detection.mdgenerated-templates.mdindex.mdpagination-waiters.mdresource-type-registry.mdstack-information.mdstack-management.mdstack-refactoring.mdstack-sets.mdtemplate-operations.md
tile.json

tessl/npm-aws-sdk--client-cloudformation

AWS SDK for JavaScript CloudFormation Client for Node.js, Browser and React Native

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@aws-sdk/client-cloudformation@3.879.x

To install, run

npx @tessl/cli install tessl/npm-aws-sdk--client-cloudformation@3.879.0

index.mddocs/

AWS SDK CloudFormation Client

The AWS SDK for JavaScript CloudFormation Client provides a comprehensive TypeScript/JavaScript API for programmatically managing Amazon CloudFormation infrastructure deployments. It enables developers to create, manage, and monitor AWS resources through Infrastructure as Code practices, supporting all CloudFormation operations across Node.js, browser, and React Native environments.

Package Information

  • Package Name: @aws-sdk/client-cloudformation
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @aws-sdk/client-cloudformation

Core Imports

import { CloudFormationClient, CreateStackCommand } from "@aws-sdk/client-cloudformation";

For CommonJS:

const { CloudFormationClient, CreateStackCommand } = require("@aws-sdk/client-cloudformation");

Basic Usage

import { CloudFormationClient, CreateStackCommand } from "@aws-sdk/client-cloudformation";

// Create a client
const client = new CloudFormationClient({ region: "us-east-1" });

// Create a stack
const command = new CreateStackCommand({
  StackName: "my-stack",
  TemplateBody: JSON.stringify({
    AWSTemplateFormatVersion: "2010-09-09",
    Resources: {
      MyBucket: {
        Type: "AWS::S3::Bucket"
      }
    }
  })
});

const response = await client.send(command);
console.log("Stack creation initiated:", response.StackId);

Architecture

The CloudFormation client is built on AWS SDK v3 architecture with several key components:

  • Client Class: CloudFormationClient handles configuration, authentication, and request/response processing
  • Command Pattern: Each CloudFormation operation is implemented as a Command class (e.g., CreateStackCommand)
  • Type Safety: Comprehensive TypeScript definitions for all inputs, outputs, and configuration options
  • Middleware Stack: Extensible middleware for authentication, retry logic, and request processing
  • Multi-Platform Support: Works in Node.js, browsers, and React Native with environment-specific configurations

Capabilities

Client Configuration

Core client setup and configuration for CloudFormation operations with authentication, regions, and customization options.

class CloudFormationClient {
  constructor(configuration: CloudFormationClientConfig);
  send<InputType, OutputType>(
    command: Command<InputType, OutputType>
  ): Promise<OutputType>;
}

interface CloudFormationClientConfig {
  region?: string;
  credentials?: AwsCredentialIdentityProvider;
  endpoint?: string;
  maxAttempts?: number;
  logger?: Logger;
}

Client Configuration

Stack Management

Core CloudFormation stack operations for creating, updating, deleting, and monitoring infrastructure deployments.

class CreateStackCommand {
  constructor(input: CreateStackCommandInput);
}

interface CreateStackCommandInput {
  StackName: string;
  TemplateBody?: string;
  TemplateURL?: string;
  Parameters?: Parameter[];
  Tags?: Tag[];
}

class UpdateStackCommand {
  constructor(input: UpdateStackCommandInput);
}

class DeleteStackCommand {
  constructor(input: DeleteStackCommandInput);
}

Stack Management

Stack Information

Retrieve detailed information about stacks, their resources, events, and current state.

class DescribeStacksCommand {
  constructor(input: DescribeStacksCommandInput);
}

interface DescribeStacksCommandInput {
  StackName?: string;
  NextToken?: string;
}

class ListStacksCommand {
  constructor(input: ListStacksCommandInput);
}

class DescribeStackResourcesCommand {
  constructor(input: DescribeStackResourcesCommandInput);
}

Stack Information

Change Sets

CloudFormation change sets for previewing and controlling stack updates before execution.

class CreateChangeSetCommand {
  constructor(input: CreateChangeSetCommandInput);
}

interface CreateChangeSetCommandInput {
  StackName: string;
  ChangeSetName: string;
  TemplateBody?: string;
  TemplateURL?: string;
  Parameters?: Parameter[];
}

class ExecuteChangeSetCommand {
  constructor(input: ExecuteChangeSetCommandInput);
}

Change Sets

Template Operations

Validate, retrieve, and analyze CloudFormation templates before deployment.

class ValidateTemplateCommand {
  constructor(input: ValidateTemplateCommandInput);
}

interface ValidateTemplateCommandInput {
  TemplateBody?: string;
  TemplateURL?: string;
}

class GetTemplateCommand {
  constructor(input: GetTemplateCommandInput);
}

class EstimateTemplateCostCommand {
  constructor(input: EstimateTemplateCostCommandInput);
}

Template Operations

Stack Sets

Multi-account and multi-region stack management through CloudFormation StackSets.

class CreateStackSetCommand {
  constructor(input: CreateStackSetCommandInput);
}

interface CreateStackSetCommandInput {
  StackSetName: string;
  TemplateBody?: string;
  TemplateURL?: string;
  Parameters?: Parameter[];
  Capabilities?: Capability[];
  PermissionModel: PermissionModels;
}

class CreateStackInstancesCommand {
  constructor(input: CreateStackInstancesCommandInput);
}

Stack Sets

Drift Detection

Detect configuration drift between deployed resources and CloudFormation templates.

class DetectStackDriftCommand {
  constructor(input: DetectStackDriftCommandInput);
}

interface DetectStackDriftCommandInput {
  StackName: string;
  LogicalResourceIds?: string[];
}

class DescribeStackDriftDetectionStatusCommand {
  constructor(input: DescribeStackDriftDetectionStatusCommandInput);
}

Drift Detection

Resource Type Registry

Manage custom CloudFormation resource types and extensions.

class RegisterTypeCommand {
  constructor(input: RegisterTypeCommandInput);
}

interface RegisterTypeCommandInput {
  Type: RegistryType;
  TypeName: string;
  SchemaHandlerPackage: string;
  LoggingConfig?: LoggingConfig;
  ExecutionRoleArn?: string;
}

class DescribeTypeCommand {
  constructor(input: DescribeTypeCommandInput);
}

Resource Type Registry

Pagination and Waiters

Handle large result sets and asynchronous operations with built-in pagination and waiter utilities.

class ListStacksPaginator {
  constructor(client: CloudFormationClient, input: ListStacksCommandInput);
  async *[Symbol.asyncIterator](): AsyncIterator<ListStacksCommandOutput>;
}

function waitForStackCreateComplete(
  params: WaiterConfiguration<CloudFormationClient>,
  input: DescribeStacksCommandInput
): Promise<WaiterResult>;

Pagination and Waiters

Generated Templates

Generate CloudFormation templates from existing resources and infrastructure for reverse engineering and automation.

class CreateGeneratedTemplateCommand {
  constructor(input: CreateGeneratedTemplateCommandInput);
}

interface CreateGeneratedTemplateCommandInput {
  GeneratedTemplateName: string;
  Resources?: ResourceToImport[];
  StackName?: string;
  TemplateConfiguration?: TemplateConfiguration;
}

class GetGeneratedTemplateCommand {
  constructor(input: GetGeneratedTemplateCommandInput);
}

class UpdateGeneratedTemplateCommand {
  constructor(input: UpdateGeneratedTemplateCommandInput);
}

Generated Templates

Stack Refactoring

Advanced stack transformation and refactoring operations for reorganizing CloudFormation infrastructure.

class CreateStackRefactorCommand {
  constructor(input: CreateStackRefactorCommandInput);
}

interface CreateStackRefactorCommandInput {
  StackName: string;
  RefactorName: string;
  RefactorType: RefactorType;
  Resources?: string[];
}

class ExecuteStackRefactorCommand {
  constructor(input: ExecuteStackRefactorCommandInput);
}

Stack Refactoring

Core Types

interface Parameter {
  ParameterKey?: string;
  ParameterValue?: string;
  UsePreviousValue?: boolean;
  ResolvedValue?: string;
}

interface Tag {
  Key: string;
  Value: string;
}

interface Stack {
  StackId?: string;
  StackName: string;
  ChangeSetId?: string;
  Description?: string;
  Parameters?: Parameter[];
  CreationTime: Date;
  LastUpdatedTime?: Date;
  RollbackConfiguration?: RollbackConfiguration;
  StackStatus: StackStatus;
  StackStatusReason?: string;
  DisableRollback?: boolean;
  NotificationARNs?: string[];
  TimeoutInMinutes?: number;
  Capabilities?: Capability[];
  Outputs?: Output[];
  RoleARN?: string;
  Tags?: Tag[];
  EnableTerminationProtection?: boolean;
  ParentId?: string;
  RootId?: string;
  DriftInformation?: StackDriftInformation;
}

interface Output {
  OutputKey?: string;
  OutputValue?: string;
  Description?: string;
  ExportName?: string;
}

type StackStatus = 
  | "CREATE_IN_PROGRESS"
  | "CREATE_FAILED"
  | "CREATE_COMPLETE"
  | "ROLLBACK_IN_PROGRESS"
  | "ROLLBACK_FAILED"
  | "ROLLBACK_COMPLETE"
  | "DELETE_IN_PROGRESS"
  | "DELETE_FAILED"
  | "DELETE_COMPLETE"
  | "UPDATE_IN_PROGRESS"
  | "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS"
  | "UPDATE_COMPLETE"
  | "UPDATE_FAILED"
  | "UPDATE_ROLLBACK_IN_PROGRESS"
  | "UPDATE_ROLLBACK_FAILED"
  | "UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS"
  | "UPDATE_ROLLBACK_COMPLETE"
  | "REVIEW_IN_PROGRESS"
  | "IMPORT_IN_PROGRESS"
  | "IMPORT_COMPLETE"
  | "IMPORT_ROLLBACK_IN_PROGRESS"
  | "IMPORT_ROLLBACK_FAILED"
  | "IMPORT_ROLLBACK_COMPLETE";

type Capability = 
  | "CAPABILITY_IAM"
  | "CAPABILITY_NAMED_IAM"
  | "CAPABILITY_AUTO_EXPAND";

type ResourceStatus =
  | "CREATE_IN_PROGRESS"
  | "CREATE_FAILED"
  | "CREATE_COMPLETE"
  | "DELETE_IN_PROGRESS"
  | "DELETE_FAILED"
  | "DELETE_COMPLETE"
  | "DELETE_SKIPPED"
  | "UPDATE_IN_PROGRESS"
  | "UPDATE_FAILED"
  | "UPDATE_COMPLETE"
  | "IMPORT_IN_PROGRESS"
  | "IMPORT_FAILED"
  | "IMPORT_COMPLETE"
  | "IMPORT_ROLLBACK_IN_PROGRESS"
  | "IMPORT_ROLLBACK_FAILED"
  | "IMPORT_ROLLBACK_COMPLETE"
  | "EXPORT_IN_PROGRESS"
  | "EXPORT_FAILED"
  | "EXPORT_COMPLETE"
  | "ROLLBACK_IN_PROGRESS"
  | "ROLLBACK_FAILED"
  | "ROLLBACK_COMPLETE";

type ChangeSetStatus =
  | "CREATE_PENDING"
  | "CREATE_IN_PROGRESS"
  | "CREATE_COMPLETE"
  | "DELETE_PENDING"
  | "DELETE_IN_PROGRESS" 
  | "DELETE_COMPLETE"
  | "DELETE_FAILED"
  | "FAILED";

type StackDriftStatus =
  | "DRIFTED"
  | "IN_SYNC"
  | "UNKNOWN"
  | "NOT_CHECKED";

type StackResourceDriftStatus =
  | "IN_SYNC"
  | "MODIFIED"
  | "DELETED"
  | "NOT_CHECKED"
  | "UNKNOWN";

type ChangeAction =
  | "Add"
  | "Modify"
  | "Remove"
  | "Import"
  | "Dynamic";

type ChangeSetType =
  | "CREATE"
  | "UPDATE"
  | "IMPORT";

type OnFailure =
  | "DO_NOTHING"
  | "ROLLBACK"
  | "DELETE";

type OperationStatus =
  | "PENDING"
  | "IN_PROGRESS"
  | "SUCCESS"
  | "FAILED";

interface StackEvent {
  EventId: string;
  StackId: string;
  StackName: string;
  LogicalResourceId?: string;
  PhysicalResourceId?: string;
  ResourceType?: string;
  Timestamp: Date;
  ResourceStatus?: ResourceStatus;
  ResourceStatusReason?: string;
  ResourceProperties?: string;
  ClientRequestToken?: string;
}

interface StackDriftInformation {
  StackDriftStatus: StackDriftStatus;
  LastCheckTimestamp?: Date;
}

interface RollbackConfiguration {
  RollbackTriggers?: RollbackTrigger[];
  MonitoringTimeInMinutes?: number;
}

interface RollbackTrigger {
  Arn: string;
  Type: string;
}

interface Change {
  Type?: ChangeSetType;
  Action?: ChangeAction;
  LogicalResourceId?: string;
  PhysicalResourceId?: string;
  ResourceType?: string;
  Replacement?: Replacement;
  Scope?: ResourceAttribute[];
  Details?: ResourceChangeDetail[];
}

type Replacement =
  | "True"
  | "False"
  | "Conditional";

type ResourceAttribute =
  | "Properties"
  | "Metadata"
  | "CreationPolicy"
  | "UpdatePolicy"
  | "DeletionPolicy"
  | "Tags";

interface ResourceChangeDetail {
  Target?: ResourceTargetDefinition;
  Evaluation?: EvaluationType;
  ChangeSource?: ChangeSource;
  CausingEntity?: string;
}

interface ResourceTargetDefinition {
  Attribute?: ResourceAttribute;
  Name?: string;
  RequiresRecreation?: RequiresRecreation;
}

type EvaluationType =
  | "Static"
  | "Dynamic";

type ChangeSource =
  | "ResourceReference"
  | "ParameterReference"
  | "ResourceAttribute"
  | "DirectModification"
  | "Automatic";

type RequiresRecreation =
  | "Never"
  | "Conditionally"
  | "Always";

interface CloudFormationServiceException extends Error {
  name: string;
  message: string;
  stack?: string;
}