Skip to content

AWS.CloudFormation reference

Source: src/AWS/CloudFormation/DescribeStackDriftDetectionStatus.ts

Runtime binding for the DescribeStackDriftDetectionStatus operation (IAM action cloudformation:DescribeStackDriftDetectionStatus on * — the detection id is not resource-scoped).

Polls a drift-detection run started with DetectStackDrift until it reaches DETECTION_COMPLETE / DETECTION_FAILED and reports the stack’s overall drift status. Provide the implementation with Effect.provide(AWS.CloudFormation.DescribeStackDriftDetectionStatusHttp).

DescribeStackDriftDetectionStatus: Drift Detection

Section titled “DescribeStackDriftDetectionStatus: Drift Detection”
const describeStackDriftDetectionStatus =
yield* AWS.CloudFormation.DescribeStackDriftDetectionStatus();
const status = yield* describeStackDriftDetectionStatus({
StackDriftDetectionId: detectionId,
});
// status.DetectionStatus, status.StackDriftStatus

Source: src/AWS/CloudFormation/DescribeStackEvents.ts

Runtime binding for the DescribeStackEvents operation (IAM action cloudformation:DescribeStackEvents).

Bind this operation to a Stack to read its event history — per-resource create/update/delete progress and failure reasons — from inside a function runtime. Useful for deployment dashboards and failure alerting. Provide the implementation with Effect.provide(AWS.CloudFormation.DescribeStackEventsHttp).

const describeStackEvents =
yield* AWS.CloudFormation.DescribeStackEvents(stack);
const { StackEvents } = yield* describeStackEvents();
const failures = (StackEvents ?? []).filter(
(e) => e.ResourceStatus?.endsWith("_FAILED"),
);

Source: src/AWS/CloudFormation/DescribeStackResourceDrifts.ts

Runtime binding for the DescribeStackResourceDrifts operation (IAM action cloudformation:DescribeStackResourceDrifts).

Bind this operation to a Stack to read per-resource drift results after a DetectStackDrift run — which resources were MODIFIED or DELETED out-of-band and the actual-vs-expected property differences. Provide the implementation with Effect.provide(AWS.CloudFormation.DescribeStackResourceDriftsHttp).

DescribeStackResourceDrifts: Drift Detection

Section titled “DescribeStackResourceDrifts: Drift Detection”
const describeStackResourceDrifts =
yield* AWS.CloudFormation.DescribeStackResourceDrifts(stack);
const { StackResourceDrifts } = yield* describeStackResourceDrifts({
StackResourceDriftStatusFilters: ["MODIFIED", "DELETED"],
});

Source: src/AWS/CloudFormation/DescribeStackResources.ts

Runtime binding for the DescribeStackResources operation (IAM action cloudformation:DescribeStackResources).

Bind this operation to a Stack to resolve the physical ids of the stack’s resources — e.g. look up a resource created by the template by its logical id from inside a function runtime. Provide the implementation with Effect.provide(AWS.CloudFormation.DescribeStackResourcesHttp).

DescribeStackResources: Reading Stack Resources

Section titled “DescribeStackResources: Reading Stack Resources”
const describeStackResources =
yield* AWS.CloudFormation.DescribeStackResources(stack);
const { StackResources } = yield* describeStackResources({
LogicalResourceId: "Param",
});
const physicalId = StackResources?.[0]?.PhysicalResourceId;

Source: src/AWS/CloudFormation/DescribeStacks.ts

Runtime binding for the DescribeStacks operation (IAM action cloudformation:DescribeStacks).

Bind this operation to a Stack to read its live status, parameters, and template outputs from inside a function runtime — the classic service-discovery pattern of resolving endpoints/ARNs from a stack’s outputs. Provide the implementation with Effect.provide(AWS.CloudFormation.DescribeStacksHttp).

// init — bind the operation to the stack
const describeStacks = yield* AWS.CloudFormation.DescribeStacks(stack);
// runtime
const { Stacks } = yield* describeStacks();
const outputs = Stacks?.[0]?.Outputs ?? [];

Source: src/AWS/CloudFormation/DetectStackDrift.ts

Runtime binding for the DetectStackDrift operation (IAM actions cloudformation:DetectStackDrift + cloudformation:DetectStackResourceDrift — AWS authorizes both on the per-stack call).

Bind this operation to a Stack to start drift detection from inside a function runtime — e.g. a scheduled drift monitor. Detection runs asynchronously; poll the returned StackDriftDetectionId with DescribeStackDriftDetectionStatus. Note that CloudFormation reads the live state of the stack’s resources with the caller’s credentials, so the function also needs read access to the resource types in the template for the detection to complete. Provide the implementation with Effect.provide(AWS.CloudFormation.DetectStackDriftHttp).

const detectStackDrift = yield* AWS.CloudFormation.DetectStackDrift(stack);
const { StackDriftDetectionId } = yield* detectStackDrift();

Source: src/AWS/CloudFormation/GetTemplate.ts

Runtime binding for the GetTemplate operation (IAM action cloudformation:GetTemplate).

Bind this operation to a Stack to read the deployed template body from inside a function runtime — e.g. audit tooling that archives or diffs the template actually running in the account. Provide the implementation with Effect.provide(AWS.CloudFormation.GetTemplateHttp).

const getTemplate = yield* AWS.CloudFormation.GetTemplate(stack);
const { TemplateBody } = yield* getTemplate();

Source: src/AWS/CloudFormation/ListExports.ts

Runtime binding for the ListExports operation (IAM action cloudformation:ListExports on * — exports are account-scoped).

Lists all cross-stack exported output values in the account and region — runtime service discovery of values shared via Fn::ImportValue. Provide the implementation with Effect.provide(AWS.CloudFormation.ListExportsHttp).

const listExports = yield* AWS.CloudFormation.ListExports();
const { Exports } = yield* listExports();
const apiUrl = Exports?.find((e) => e.Name === "ApiUrl")?.Value;

Source: src/AWS/CloudFormation/ListImports.ts

Runtime binding for the ListImports operation (IAM action cloudformation:ListImports on * — imports are account-scoped).

Lists the stacks importing a given exported output value — e.g. impact analysis before rotating a shared value. Provide the implementation with Effect.provide(AWS.CloudFormation.ListImportsHttp).

const listImports = yield* AWS.CloudFormation.ListImports();
const { Imports } = yield* listImports({ ExportName: "ApiUrl" });

Source: src/AWS/CloudFormation/ListStackResources.ts

Runtime binding for the ListStackResources operation (IAM action cloudformation:ListStackResources).

Bind this operation to a Stack to enumerate all of the stack’s resource summaries (paginated) from inside a function runtime — the lighter-weight alternative to DescribeStackResources for stacks with many resources. Provide the implementation with Effect.provide(AWS.CloudFormation.ListStackResourcesHttp).

ListStackResources: Reading Stack Resources

Section titled “ListStackResources: Reading Stack Resources”
const listStackResources =
yield* AWS.CloudFormation.ListStackResources(stack);
const { StackResourceSummaries } = yield* listStackResources();
const types = (StackResourceSummaries ?? []).map((r) => r.ResourceType);

Source: src/AWS/CloudFormation/SignalResource.ts

Runtime binding for the SignalResource operation (IAM action cloudformation:SignalResource).

Bind this operation to a Stack to send SUCCESS/FAILURE signals to a resource with a CreationPolicy or a WaitCondition in the stack — e.g. a function that performs out-of-band initialization and unblocks the stack when done. Provide the implementation with Effect.provide(AWS.CloudFormation.SignalResourceHttp).

const signalResource = yield* AWS.CloudFormation.SignalResource(stack);
yield* signalResource({
LogicalResourceId: "WaitCondition",
UniqueId: "init-1",
Status: "SUCCESS",
});

Source: src/AWS/CloudFormation/Stack.ts

An AWS CloudFormation stack — deploy an existing CloudFormation template from Alchemy as an interop/escape hatch.

Create and update are asynchronous: the provider submits the template and then polls (bounded) until the stack reaches a terminal state, surfacing a CREATE_FAILED / ROLLBACK_COMPLETE / UPDATE_ROLLBACK_COMPLETE status as a typed error rather than hanging. An update whose template and parameters are unchanged is a no-op (No updates are to be performed). Deletion waits for DELETE_COMPLETE.

Inline Template (SNS Topic)

const stack = yield* CloudFormation.Stack("Notifications", {
templateBody: JSON.stringify({
Resources: {
Topic: { Type: "AWS::SNS::Topic", Properties: { DisplayName: "alerts" } },
},
Outputs: { TopicArn: { Value: { Ref: "Topic" } } },
}),
});
// stack.outputs.TopicArn -> "arn:aws:sns:us-west-2:...:Notifications-Topic-..."

Template with Parameters

const stack = yield* CloudFormation.Stack("Config", {
templateBody: JSON.stringify({
Parameters: { Value: { Type: "String" } },
Resources: {
Param: {
Type: "AWS::SSM::Parameter",
Properties: { Type: "String", Value: { Ref: "Value" } },
},
},
}),
parameters: { Value: "hello" },
});
const stack = yield* CloudFormation.Stack("Roles", {
templateBody: iamTemplateJson,
capabilities: ["CAPABILITY_NAMED_IAM"],
});

Source: src/AWS/CloudFormation/ValidateTemplate.ts

Runtime binding for the ValidateTemplate operation (IAM action cloudformation:ValidateTemplate on * — validation is not resource-scoped).

Validates a template body or URL and reports its parameters, capabilities, and declaration errors — e.g. a platform service that lints user-submitted templates before deploying them. Provide the implementation with Effect.provide(AWS.CloudFormation.ValidateTemplateHttp).

const validateTemplate = yield* AWS.CloudFormation.ValidateTemplate();
const { Parameters, Capabilities } = yield* validateTemplate({
TemplateBody: templateJson,
});