Retrieve detailed information about CloudFormation stacks, their resources, events, and operational status.
Retrieves detailed information about CloudFormation stacks including status, parameters, outputs, and metadata.
/**
* Returns the description for the specified stack or all stacks
* If stack name is omitted, returns information for all stacks
*/
class DescribeStacksCommand {
constructor(input: DescribeStacksCommandInput);
}
interface DescribeStacksCommandInput {
/** Name or ARN of the stack to describe (optional for all stacks) */
StackName?: string;
/** Token for pagination of results */
NextToken?: string;
}
interface DescribeStacksCommandOutput {
/** Array of stack descriptions */
Stacks?: Stack[];
/** Token for retrieving next page of results */
NextToken?: string;
}Usage Examples:
import { CloudFormationClient, DescribeStacksCommand } from "@aws-sdk/client-cloudformation";
const client = new CloudFormationClient({ region: "us-east-1" });
// Describe a specific stack
const command = new DescribeStacksCommand({
StackName: "my-stack"
});
const result = await client.send(command);
const stack = result.Stacks?.[0];
console.log("Stack Status:", stack?.StackStatus);
console.log("Creation Time:", stack?.CreationTime);
console.log("Outputs:", stack?.Outputs);
// List all stacks in the region
const allStacksCommand = new DescribeStacksCommand({});
const allStacks = await client.send(allStacksCommand);
for (const stack of allStacks.Stacks || []) {
console.log(`${stack.StackName}: ${stack.StackStatus}`);
}Returns summary information for CloudFormation stacks with optional status filtering.
/**
* Returns summary information for stacks whose status matches specified filters
* Deleted stacks are listed for 90 days after deletion
*/
class ListStacksCommand {
constructor(input: ListStacksCommandInput);
}
interface ListStacksCommandInput {
/** Token for pagination */
NextToken?: string;
/** Filter by stack status */
StackStatusFilter?: StackStatus[];
}
interface ListStacksCommandOutput {
/** Array of stack summaries */
StackSummaries?: StackSummary[];
/** Token for next page of results */
NextToken?: string;
}
interface StackSummary {
/** Unique stack identifier */
StackId?: string;
/** Stack name */
StackName: string;
/** Stack creation time */
CreationTime: Date;
/** Last update time */
LastUpdatedTime?: Date;
/** Stack deletion time */
DeletionTime?: Date;
/** Current stack status */
StackStatus: StackStatus;
/** Reason for current status */
StackStatusReason?: string;
/** Parent stack ID for nested stacks */
ParentId?: string;
/** Root stack ID for nested stacks */
RootId?: string;
/** Drift information summary */
DriftInformation?: StackDriftInformationSummary;
}Lists all resources in a CloudFormation stack with their current status and properties.
/**
* Returns AWS resource descriptions for running resources in a stack
* Resources are sorted by their logical ID
*/
class DescribeStackResourcesCommand {
constructor(input: DescribeStackResourcesCommandInput);
}
interface DescribeStackResourcesCommandInput {
/** Name or ARN of the stack */
StackName?: string;
/** Logical name of the resource */
LogicalResourceId?: string;
/** Physical name of the resource */
PhysicalResourceId?: string;
}
interface DescribeStackResourcesCommandOutput {
/** Array of stack resource descriptions */
StackResources?: StackResource[];
}
interface StackResource {
/** Unique stack identifier */
StackId?: string;
/** Stack name */
StackName?: string;
/** Logical resource identifier from template */
LogicalResourceId: string;
/** Physical resource identifier from AWS */
PhysicalResourceId?: string;
/** AWS resource type */
ResourceType: string;
/** Resource creation timestamp */
Timestamp: Date;
/** Current resource status */
ResourceStatus: ResourceStatus;
/** Reason for current status */
ResourceStatusReason?: string;
/** Resource description from template */
Description?: string;
/** Resource metadata */
Metadata?: string;
/** Drift information */
DriftInformation?: StackResourceDriftInformation;
/** Module information for nested stacks */
ModuleInfo?: ModuleInfo;
}Returns all stack-related events for a specified stack in reverse chronological order.
/**
* Returns all stack related events for a specified stack
* Events are returned in reverse chronological order (newest first)
*/
class DescribeStackEventsCommand {
constructor(input: DescribeStackEventsCommandInput);
}
interface DescribeStackEventsCommandInput {
/** Name or ARN of the stack */
StackName?: string;
/** Token for pagination */
NextToken?: string;
}
interface DescribeStackEventsCommandOutput {
/** Array of stack events */
StackEvents?: StackEvent[];
/** Token for next page of results */
NextToken?: string;
}
interface StackEvent {
/** Unique stack identifier */
StackId: string;
/** Event unique identifier */
EventId: string;
/** Stack name */
StackName: string;
/** Logical resource identifier */
LogicalResourceId?: string;
/** Physical resource identifier */
PhysicalResourceId?: string;
/** AWS resource type */
ResourceType?: string;
/** Event timestamp */
Timestamp: Date;
/** Resource status at time of event */
ResourceStatus?: ResourceStatus;
/** Reason for resource status */
ResourceStatusReason?: string;
/** Resource properties from template */
ResourceProperties?: string;
/** Unique client request token */
ClientRequestToken?: string;
/** Hook information for pre/post hooks */
HookType?: string;
HookStatus?: HookStatus;
HookStatusReason?: string;
HookInvocationPoint?: HookInvocationPoint;
HookFailureMode?: HookFailureMode;
}Usage Examples:
// List all active stacks
const listCommand = new ListStacksCommand({
StackStatusFilter: [
"CREATE_COMPLETE",
"UPDATE_COMPLETE",
"UPDATE_ROLLBACK_COMPLETE"
]
});
const stacks = await client.send(listCommand);
// Get detailed resource information
const resourcesCommand = new DescribeStackResourcesCommand({
StackName: "my-stack"
});
const resources = await client.send(resourcesCommand);
for (const resource of resources.StackResources || []) {
console.log(`${resource.LogicalResourceId} (${resource.ResourceType}): ${resource.ResourceStatus}`);
}
// Monitor recent stack events
const eventsCommand = new DescribeStackEventsCommand({
StackName: "my-stack"
});
const events = await client.send(eventsCommand);
// Show most recent 5 events
events.StackEvents?.slice(0, 5).forEach(event => {
console.log(`${event.Timestamp}: ${event.LogicalResourceId} - ${event.ResourceStatus}`);
});Lists resources in a stack with pagination support for large stacks.
/**
* Returns descriptions of all resources in the specified stack
* For deleted stacks, returns resource information for up to 90 days
*/
class ListStackResourcesCommand {
constructor(input: ListStackResourcesCommandInput);
}
interface ListStackResourcesCommandInput {
/** Name or ARN of the stack */
StackName: string;
/** Token for pagination */
NextToken?: string;
}
interface ListStackResourcesCommandOutput {
/** Array of stack resource summaries */
StackResourceSummaries?: StackResourceSummary[];
/** Token for next page of results */
NextToken?: string;
}
interface StackResourceSummary {
/** Logical resource identifier */
LogicalResourceId: string;
/** Physical resource identifier */
PhysicalResourceId?: string;
/** AWS resource type */
ResourceType: string;
/** Last update timestamp */
LastUpdatedTimestamp: Date;
/** Current resource status */
ResourceStatus: ResourceStatus;
/** Reason for current status */
ResourceStatusReason?: string;
/** Drift information summary */
DriftInformation?: StackResourceDriftInformationSummary;
/** Module information */
ModuleInfo?: ModuleInfo;
}