Files
floci/docs/services/cloudformation.md
T
Sam Fakhreddine 08e532ab1a feat(cloudformation): CDK Provider-framework custom resources and changeset/SSM param fidelity (#2688)
* feat(cloudformation): changeset diffs, stack params, SSM attributes

CDK's deploy loop reads all three: DescribeChangeSet now returns
computed Add/Modify/Remove resource changes instead of an empty list
(an empty list makes CDK skip ExecuteChangeSet on updates),
DescribeStacks echoes the stack's merged parameters, and
AWS::SSM::Parameter resources expose Value/Type/Name attributes so
Fn::GetAtt resolves the bootstrap version

(cherry picked from commit 80ac80063e84ef1be977fe625334e722cc1ed8bb)

* feat(cloudformation): resolve SSM-typed stack parameters

AWS::SSM::Parameter::Value<String> template parameters resolve through
SSM for the stack's account and region; missing parameters fail with the
real ValidationError message. Landing Zone Accelerator's security and
logging stacks depend on this typed-parameter resolution.

The IAM password-policy and S3 replication-config changes from the same
source commit ship separately in the iam and s3 branches.

(cherry picked from commit 10dbabbf5e31d763a398fc1fff16ab0484958af0)

* feat(cloudformation): drive CDK Provider framework custom resources

The CDK Provider framework defers its ResponseURL callback to a Step
Functions waiter that polls framework.isComplete on a Retry cadence until
the resource is ready. The custom-resource provisioner only waited the
synchronous single-lambda budget for a ResponseURL PUT, so the
waiter-driven PUT never landed. A framework.onEvent ServiceToken is now
awaited on a bounded async budget so that PUT is captured; onEvent-only
and single-lambda resources are unchanged.

The engine-side half of the original commit -- a Task-only Retry
implementation for the ASL executor (ErrorEquals/IntervalSeconds/
MaxAttempts/BackoffRate/MaxDelaySeconds) -- is dropped here: upstream
#2455 ("feat(sfn): support Retry policies in Task, Parallel, and Map
states") landed a broader Retry implementation independently (Task,
Parallel, and Map states; JitterStrategy; $$.State.RetryCount;
Retry-before-Catch ordering), a strict superset of what this commit
needed. The full stepfunctions suite (411 tests) is green against it
on this branch, and CustomResourceProviderFrameworkTest (a hermetic
test of the provisioner's own detect-and-wait logic, no Step Functions
involved) is unaffected by the drop.

(cherry picked from commit 5b3502d8c9dddf3766ca3f94fe7f146042dc00fd)

* docs(cloudformation): document CDK provisioning

Documents the CDK Provider-framework custom-resource support and folds
its cross-reference into upstream's existing "Retry policies" section
in step-functions.md rather than duplicating it with a separate
"State Retry" section (upstream #2455 already documents the Retry
engine itself).

* feat(cloudformation): budget custom-resource waits by idleness, not total time

The async custom-resource wait was a fixed 3-minute total budget. That is a
property of the emulator, but the time a CDK provider-framework resource needs
is a property of the work: Custom::CreateOrganizationAccounts creates exactly
one account per 15s waiter poll, so a 3-account org finishes in ~45s while a
15-account org needs ~195s. Past the budget the Lambda is guillotined mid-
success -- the accounts all exist, but the resource reports CREATE_FAILED, the
stack rolls back, and CDK's readback then surfaces the misleading "NoStack:
CloudFormationStack object does not hold a stack".

Measure idleness instead. The provisioner already embeds its callback token in
the ResponseURL it puts on every event, and the framework echoes that event into
each framework.isComplete poll, so a poll arriving at LambdaService is proof of
progress for a specific pending resource. Each poll resets the budget, which
makes the wait proportional to the work without CloudFormation needing to know
what the work is -- and a genuinely hung resource still fails after 3 idle
minutes exactly as before.

CustomResourceLiveness lives in core.common so the Lambda service can report
progress without depending on CloudFormation; the dependency already runs the
other way.

(cherry picked from commit 14087c992ebb75d109999153a9e8af7e3c2d79f4)
(cherry picked from commit 51349e4e017ed08d90e6e71212414e2f306c826b)

* fix(cloudformation): call the caller-scoped getStackOrThrow overload that exists

The changeset-diff commit re-derived onto main carried a call to a
three-arg getStackOrThrow(name, region, accountId) overload that only
existed on the account-scoping commit deliberately skipped as superseded
by upstream. Upstream's resolveStack already scopes to the caller's
account, so the two-arg form is equivalent and compiles.

* fix(cloudformation): honour an arrived custom-resource response past its budget

A synchronous custom-resource handler PUTs to the ResponseURL from inside the
invoke the provisioner is blocked on, so its response can already be delivered
by the time await() is entered. Two independent flaws then threw it away.

The idle clock started at register(), before the invoke. A provider-framework
onEvent-only handler that took 75s to return -- two nested cold container
starts -- had spent its 10s CR_RESPONSE_TIMEOUT six times over before await
was reached, so the very first deadline check was already negative. Idleness
of the wait cannot include time the handler spent working; the clock now
starts when the caller starts waiting.

The deadline guard also threw without ever consulting the future, so a
response that had completed it was discarded as a timeout. Observed on
AccessAnalyzerServiceLinkedRoleCreateServiceLinkedRoleResource: the handler
logged its response at 15:52:11.768 and the resource was failed 24ms later.
An arrived response outranks the clock.

Both are pinned by red-first tests. The existing idle-timeout guarantees are
unchanged: nothing arriving still times out, and a resource that stops
reporting liveness still dies on schedule from its last touch.

(cherry picked from commit 7dc8bbca7d47b2a029b5656a89421a556b8296be)
(cherry picked from commit 77b71b31a634ae27d7460a078b52dac250d67dc7)

* refactor(cloudformation): extract Provider-framework detection from the provisioner

The CDK Provider-framework `framework.onEvent` detection and the longer idle
budget it earns lived in CloudFormationResourceProvisioner, adding ~55 lines to a
class that is being dismantled rather than grown.

Move the concern to ProviderFrameworkDetector: it owns the two waiter marker env
vars, the best-effort environment probe, the 3-minute async budget and the test
seam that shortens it. CustomResourceResponseStore — which already owns the
idle-timeout concept via touch/await — gains an await overload that resolves the
budget for a ServiceToken and delegates to the existing one, so the provisioner
only passes the token through and appends the store's timeout detail to its
error. Behaviour is unchanged.

(cherry picked from commit 5f93439f409a32012a01b996c5edd0c29d23b260)

* fix(stepfunctions): report custom-resource liveness on waiter polls

A CDK provider-framework waiter's framework.isComplete poll is itself a
Lambda Task the state machine invokes, so it goes through
AslExecutor.invokeResource -> LambdaExecutorService directly, bypassing
LambdaService.invoke() and the liveness hook it carries. A long-but-
progressing custom resource's idle budget in CustomResourceResponseStore
ticked down as if no polls were arriving, even while they kept landing.

AslExecutor now reports liveness the same way LambdaService does: extract
the callback token from the invoke payload and touch() it before invoking.

* perf(core): avoid materializing the full payload string in tokenIn

CustomResourceLiveness.tokenIn() ran on every Lambda invoke once liveness
reporting is wired in, decoding the whole invoke payload as a UTF-8 String
even though the overwhelming majority of invokes carry no callback URL at
all. Scan the raw bytes for the ASCII "/cfn-response/" marker instead, and
only allocate a String for the small token substring when one is found.

* fix(cloudformation): compute accurate changeset resource diffs

computeChangeSetChanges never read cs.getParameters(), so an update that
only changed parameter values reported an empty diff and CDK skipped
execution, leaving the old parameter-derived config deployed. It also
diffed a SAM change set's raw template against the stack's expanded
deployed template, reporting spurious Modify/Remove on every SAM-generated
resource for a no-op update, and hardcoded Replacement=False even when a
resource's Type changed.

Now the diff expands a SAM change set's template before comparing, marks a
resource Modify when it references a changed parameter, and reports
Replacement=True when a resource's Type changes.

* fix(cloudformation): restore last-successful parameters on update rollback

executeTemplate overwrote the stack's live parameter map with an update's
attempted values before resolving SSM-typed parameters, which can fail. A
failed resolution rolled the stack back, but the update snapshot never
captured parameters, so DescribeStacks reported the failed update's
attempted values instead of the last successfully deployed ones.

StackUpdateSnapshot now captures the stack's parameters alongside its
template body, and rollbackFailedUpdate restores them together.

* fix(cloudformation): log tolerated wait-slice timeouts in custom-resource poll loop

Each slice of the custom-resource poll loop below the outer idle budget
hit an intentionally-tolerated TimeoutException that was swallowed with
only a comment, against the repo's convention of logging deliberately
caught exceptions.

* fix(cloudformation): honor Parameters.member.N.UsePreviousValue

extractParameters never read UsePreviousValue, so submitting it without a
ParameterValue stored an empty string for that key. The new parameter-diff
logic in computeChangeSetChanges (9fb02c6a9) then treated that empty
string as different from the deployed value, reporting a spurious Modify
for every resource referencing an otherwise-unchanged parameter.

extractParameters now takes the stack's current parameters and resolves
UsePreviousValue against them; CloudFormationService.currentParameters
looks those up (empty map if the stack doesn't exist yet, e.g. a CREATE
change set).

* fix(cloudformation): resolve UsePreviousValue against deployed StackSet parameters

UpdateStackSet extracted parameters with the previous-value-unaware
extractParameters() overload, so a member with UsePreviousValue=true and no
ParameterValue stored an empty string and clobbered the StackSet's deployed
value instead of preserving it.

* fix(cloudformation): resolve template defaults for omitted parameters in changeset diff

computeChangeSetChanges compared only explicitly submitted parameters against
the deployed stack, so an update that omits a parameter (falling back to its
template Default) was never flagged as a change even when that default
differs from the deployed value. ExecuteChangeSet applies the default when it
actually runs, so the preview under-reported what would change. Resolve
defaults for the change set's parameters the same way execution does before
diffing.

* fix(cloudformation): resolve SSM parameter drift and no-default omissions in changeset diff

computeChangeSetChanges compared raw submitted parameter values against the
deployed stack, so it missed two cases ExecuteChangeSet actually handles
differently: an omitted parameter with no template Default disappears
entirely from the resolved map (previously undetected since the diff only
walked the new parameter set), and AWS::SSM::Parameter::Value<String>
parameters are resolved against the live SSM store at execution time but
compared as raw parameter names in the preview, masking a changed SSM value
behind an unchanged parameter name.

Stack now tracks resolvedParameters (the SSM-resolved map executeTemplate
last applied, restored on rollback like parameters already was) so the diff
can compare resolved values on both sides. The diff falls back to unresolved
values if SSM resolution fails, since a preview must not fail harder than
the operation it previews - ExecuteChangeSet still raises the real
ValidationError when it resolves for real.

* fix(stepfunctions): pass CustomResourceLiveness to AslExecutor in error-termination test

Upstream's issue #2666 regression test predates this branch's addition
of CustomResourceLiveness to AslExecutor's constructor. The merge from
upstream/main brought the file in as new content with no line overlap,
so it auto-merged cleanly but left the constructor call one argument
short.

* fix(cloudformation): evaluate Conditions in changeset diff, always restore params on rollback

computeChangeSetChanges never evaluated template Conditions, so a resource
whose Condition depends on a changed parameter but whose own definition text
is unchanged was invisible to the diff even though ExecuteChangeSet would
Add or Remove it once the condition flips (see
deleteRemovedOrConditionFalseResources). The diff now resolves Conditions
against the new resolved parameters and compares against whether the
resource is actually present in stack.getResources() - the same ground
truth execution already uses to decide whether a resource was created -
falling back to the existing text-based Modify detection when the condition
doesn't change.

rollbackFailedUpdate only restored the last-successful parameter maps when
resource rollback itself also succeeded, so a stack that lands in
UPDATE_ROLLBACK_FAILED (resource rollback failed too) kept serving the
failed update's attempted parameter values via DescribeStacks and later
change-set previews. Parameters are independent of resource-rollback
outcome and are now restored unconditionally; templateBody restoration
stays gated on rollback success since a partially-rolled-back resource set
doesn't correspond to either template.

* fix(stepfunctions): pass EventBridgeHandler/SchedulerService/SchedulerController mocks in AslExecutor test

Merging upstream/main (55acdec6e) added these three constructor
parameters to AslExecutor without updating this test's call site,
breaking test-compile.
2026-08-29 15:01:00 -04:00

20 KiB

CloudFormation

Protocol: Query (XML) — POST http://localhost:4566/ with Action= parameter Endpoint: POST http://localhost:4566/

Supported Actions

Action Description
DescribeStacks Get stack status, parameters, and outputs
CreateStack Deploy a CloudFormation template
UpdateStack Update an existing stack
DeleteStack Delete a stack and its resources
UpdateTerminationProtection -
CreateChangeSet Create a change set
DescribeChangeSet Get change set details with a computed Add/Modify/Remove resource diff
ExecuteChangeSet Apply a change set
DeleteChangeSet Delete a change set
ListChangeSets List change sets for a stack
DescribeStackEvents Get stack creation/update event history
DescribeStackResources Get all resources in a stack
ListStackResources List resource summaries
GetTemplate Retrieve the template body
GetTemplateSummary Summarize a template's Parameters, Resources and Transform sections, by StackName, TemplateBody or TemplateURL
ValidateTemplate Accepted; returns success without validating (stub)
ListStacks List stacks by status
ListExports -
SetStackPolicy Accepted; no-op (stub — stack policies are not enforced)
GetStackPolicy Accepted; returns an empty policy (stub)
DescribeStackResource Get a specific stack resource
CreateStackSet Create a stack set from a template
DescribeStackSet Get stack set details
ListStackSets List stack sets
UpdateStackSet Update the stack set and re-apply to existing instances
DeleteStackSet Delete an empty stack set
CreateStackInstances Provision instances into target accounts/regions
ListStackInstances List instances (optionally filtered by account/region)
DescribeStackInstance -
DeleteStackInstances Remove instances and their resources
ListStackSetOperations List operations performed on a stack set
DescribeStackSetOperation -

Supported Resource Types

Resource types provisioned during CreateStack / UpdateStack / DeleteStack. Each delegates to the backing service and sets a real physical ID plus the Ref / Fn::GetAtt attributes used by cross-resource references.

Adding a type? See Adding a CloudFormation Resource Type. Types live in per-service provisioners under services/cloudformation/provisioners/; keep this table in step with them.

Service Resource types
S3 Bucket, BucketPolicy (accepted; policy not enforced)
SQS Queue, QueuePolicy (accepted; policy not enforced)
SNS Topic, Subscription
DynamoDB Table, GlobalTable
Lambda Function (Zip via S3/inline ZipFile, and Image), LayerVersion, EventSourceMapping (SQS, Kinesis, DynamoDB Streams), Version, Alias (also what SAM's AutoPublishAlias expands into). Inline ZipFile packages include the cfn-response (Node.js) / cfnresponse (Python) module AWS injects for that code path, so Solutions-style custom-resource handlers work
IAM Role, User, AccessKey, Policy, ManagedPolicy, InstanceProfile
Organizations Organization, OrganizationalUnit, Account, Policy, ResourcePolicy
SSM Parameter
KMS Key, Alias
Secrets Manager Secret, SecretTargetAttachment
ECR Repository
ECS Cluster, TaskDefinition, Service
EKS Cluster, Nodegroup
RDS DBInstance, DBCluster, DBSubnetGroup, DBParameterGroup, DBClusterParameterGroup (DBInstance/DBCluster start real containers)
EC2 VPC, Subnet, SecurityGroup (including inline SecurityGroupIngress/SecurityGroupEgress), SecurityGroupIngress, SecurityGroupEgress, InternetGateway, RouteTable, SubnetRouteTableAssociation, Route, NatGateway, EIP, Instance, LaunchTemplate, VPCGatewayAttachment, NetworkAcl, NetworkAclEntry, SubnetNetworkAclAssociation, FlowLog
Elastic Load Balancing v2 LoadBalancer, TargetGroup, Listener, ListenerRule
Auto Scaling LaunchConfiguration, AutoScalingGroup, LifecycleHook
Route 53 HostedZone, RecordSet
API Gateway (v1) RestApi, Resource, Authorizer, Method, Deployment, Stage, Account
API Gateway v2 Api, Route, Integration, Stage, Deployment
Step Functions StateMachine
CodePipeline Pipeline, CustomActionType, Webhook
CodeBuild Project
Batch ComputeEnvironment, JobQueue, JobDefinition
Cognito UserPool, UserPoolClient
EventBridge Rule, EventBus, EventBusPolicy
Pipes Pipe
Kinesis Stream
Kinesis Data Firehose DeliveryStream
CloudWatch Alarm
CloudWatch Logs LogGroup
CloudFormation Stack (nested stacks), CustomResource and Custom::* (Lambda-backed)
CDK CDK::Metadata (accepted; no-op)

All other resource types are accepted without error and assigned a synthetic physical ID (with an arn:aws:stub:::<logicalId> ARN attribute), so templates with unsupported types still reach CREATE_COMPLETE rather than failing.

EventBridge Event Buses

AWS::Events::EventBus creates a real custom EventBridge bus. Name is required, Ref returns the bus name, and Fn::GetAtt supports Arn and Name. Description and Tags are applied when the bus is created. Rules that reference the bus are removed before stack deletion.

The current implementation is limited to custom buses with the Name, Description, Tags, and Policy properties. EventSourceName, KmsKeyIdentifier, DeadLetterConfig, and LogConfig are rejected with ValidationError instead of being silently ignored. AWS models a Name change as resource replacement; Floci currently rejects that update until generic replacement handling is available. Policy is applied when the bus is created. Changing Description, Tags, or Policy during UpdateStack is rejected until transactional resource rollback is available; this prevents a failed stack update from leaving the live bus in the rejected configuration.

Secrets Manager Target Attachments

AWS::SecretsManager::SecretTargetAttachment adds the target's database connection fields to the referenced secret while preserving credentials and custom fields. Ref and Fn::GetAtt Id return the complete secret ARN, only one attachment can own a secret, and deleting the attachment removes only its managed connection fields.

Supported target types are:

  • AWS::RDS::DBInstance
  • AWS::RDS::DBCluster
  • AWS::DocDB::DBInstance
  • AWS::DocDB::DBCluster

Redshift clusters, Redshift Serverless namespaces, and DocumentDB Elastic clusters are not supported because their backing services are not implemented. A SecretId change is applied in place rather than reproducing CloudFormation's replacement event sequence; failed changes restore affected secret data and attachment ownership.

Organizations

AWS::Organizations::Organization uses the stack's calling account as the management account, so the rest of the stack's Organizations resources are provisioned into that account's organization. Fn::GetAtt Org.RootId is the usual way to root the OU tree in the same template. Organization is the one type in this section where bare Ref does not return the resource's own id: per AWS, Ref returns the management account id, while Fn::GetAtt Org.Id returns the organization id.

  • OrganizationalUnit — ParentId is create-only per the registry schema, so an update only renames the OU in place; the physical id survives, keeping every Ref to it valid.
  • Account — ParentIds accepts a single entry and the account is moved there after creation (accounts are always created under the root). Because Floci resolves a 12-digit access key id straight to an account, Ref/Fn::GetAtt AccountId yields an id you can immediately use as a caller identity against other services. State mirrors Status, the parameter AWS is retiring it in favour of; Floci does not model the PENDING_ACTIVATION or CLOSED phases that only State can express.
  • Policy — TargetIds is reconciled on update: targets the template adds are attached and ones it drops are detached. Deleting the resource detaches its remaining targets first, since DeletePolicy refuses while a policy is still attached.
  • ResourcePolicy — backed by PutResourcePolicy, which is already create-or-update.

Fn::GetAtt OrganizationalUnit.Path and Fn::GetAtt Account.Paths return the organization path — o-<org>/r-<root>/[ou-<ou>/…]<id>/. An account has one parent and therefore one path, so the list-typed Paths holds a single entry; read it with Fn::Select as you would on AWS.

Deleting the stack removes the resources in dependency order and finally the organization itself. Deleting a resource that is already gone is tolerated.

Auto Scaling Launch Template Resolution

AWS::AutoScaling::AutoScalingGroup resolves its launch template through any of the shapes AWS accepts, not only by name:

  • LaunchTemplate with LaunchTemplateId or LaunchTemplateName (plus an optional Version). The id and name are distinct lookup keys, so an lt- id is matched as an id rather than being treated as a name.
  • A Ref to an in-stack AWS::EC2::LaunchTemplate, whose Ref returns the lt- id and whose Fn::GetAtt LatestVersionNumber supplies the version.
  • MixedInstancesPolicy → LaunchTemplate → LaunchTemplateSpecification, including Overrides[].InstanceType and InstancesDistribution (OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, SpotAllocationStrategy). A non-integer where AWS expects a number fails the stack rather than being dropped.

Lambda Stack Updates

AWS::Lambda::Function resources are reconciled during UpdateStack in the same shape as CloudFormation/CDK deployments:

  • A no-op redeploy keeps the existing physical function name and does not call Lambda update APIs, so warm containers can be reused.
  • Code and mutable configuration changes update the existing function in place.
  • Replacement-only changes such as FunctionName or PackageType changes create a replacement function and remove the old one.
  • S3-backed code stays linked through S3Bucket / S3Key, so Lambda's reactive S3 sync continues to work for functions created by CloudFormation or CDK.

RDS Credential Dynamic References

AWS::RDS::DBInstance and AWS::RDS::DBCluster resolve CloudFormation dynamic references in MasterUsername and MasterUserPassword during resource creation:

  • secretsmanager references support whole secret strings, JSON keys, version stages, and version IDs.
  • ssm references accept String and StringList parameters, using either the latest value or an explicit positive version.
  • ssm-secure references require a SecureString parameter and are supported only for MasterUserPassword, matching the AWS resource-property allowlist.

Dynamic-reference expansion is currently scoped to these RDS credential properties.

Account-Aware Provisioning

Resources provisioned by CreateStack / UpdateStack land in the caller's account namespace (determined from the request's access key — see Multi-Account Isolation). Deleting the stack removes them from that same account.

Stacks, change sets, and exports are scoped to the caller account. ListExports returns only the exports created by that account's stacks, and Fn::ImportValue resolves against the same account's export table — so two accounts can each own an export with the same name without colliding, mirroring how CloudFormation isolates exports per account and region. This is what lets a multi-account LZA deployment reuse identical export names across its member accounts.

Template Parameters

Parameters passed to CreateStack / UpdateStack (and echoed back by DescribeStacks) are resolved before provisioning:

  • String, Number, CommaDelimitedList, and List<...> parameter types are accepted and substituted into resource properties via Ref.
  • AWS::SSM::Parameter::Value<String>-typed parameters are resolved at deploy time: the value the caller supplies is treated as an SSM parameter name, and floci substitutes the current value of that SSM parameter into the template. This is the pattern CDK uses to pull bootstrap values (image tags, bucket names) from Parameter Store.
  • AWS::SSM::Parameter::Value<List<String>> and AWS::SSM::Parameter::Name typed parameters are not yet resolved — they are passed through as their literal input.

The AWS::SSM::Parameter resource type exposes Value, Type, and Name attributes through Ref / Fn::GetAtt so downstream resources can consume a parameter the same stack creates.

Conditions

Template Conditions are evaluated before provisioning. A resource whose Condition evaluates to false is skipped — it is never provisioned, does not appear in DescribeStackResources, and its Ref / Fn::GetAtt are not required to resolve. This matches CloudFormation and is required for the condition-heavy templates CDK and LZA emit.

Custom Resources and the CDK Provider Framework

AWS::CloudFormation::CustomResource and Custom::* resources are backed by their ServiceToken Lambda. floci supports two shapes:

  • Direct custom resources — floci invokes the handler Lambda with the CloudFormation custom-resource event and waits for it to PUT its SUCCESS/FAILED result to the response URL. Inline ZipFile handlers get the cfn-response / cfnresponse module bundled in (see the Lambda row in Supported Resource Types), so Solutions-style handlers work unmodified.
  • CDK Provider framework — when the ServiceToken points at a CDK framework.onEvent function, floci drives the asynchronous provider protocol: onEvent starts the work and framework.isComplete is polled (via Step Functions Retry) until it reports done, at which point the ResponseURL callback fires. The wait is bounded by an async custom-resource timeout (3 minutes by default); a resource that never completes fails the stack rather than hanging.

Deletion Policies

A resource's DeletionPolicy attribute is honored on DeleteStack and on the rollback of a failed CreateStack:

Value DeleteStack Rollback of the create that made the resource
Delete (default) deleted deleted
Retain kept kept
RetainExceptOnCreate kept deleted

A kept resource is reported as DELETE_SKIPPED in DescribeStackEvents and does not fail the deletion — the stack still reaches DELETE_COMPLETE while the resource keeps existing. This also lets a stack owning a non-empty S3 bucket be deleted, since the bucket is never touched.

Deviations from AWS to be aware of:

  • Snapshot deletes the resource without taking a snapshot; floci has no snapshot support for the types AWS allows it on.
  • Every resource defaults to Delete. AWS instead defaults AWS::RDS::DBCluster, and AWS::RDS::DBInstance without a DBClusterIdentifier, to Snapshot.
  • Unrecognized values are treated as Delete.
  • An update that removes a resource from the template does not delete it (or consult its policy); only the new template's resources are provisioned. AWS applies DeletionPolicy to update-time removals as well.
  • After DeleteStack completes, a retained resource's DELETE_SKIPPED record is only visible through DescribeStackEvents for the deleted stack, not DescribeStackResources.
  • UpdateReplacePolicy, and the RetainExceptOnCreate request parameter of CreateStack / UpdateStack, are not implemented.

StackSets

StackSets deploy a single template into many target accounts and regions:

export AWS_ENDPOINT_URL=http://localhost:4566

# 1. Create the stack set (in the administration account)
aws cloudformation create-stack-set \
  --stack-set-name my-set \
  --template-body file://template.yml \
  --endpoint-url $AWS_ENDPOINT_URL

# 2. Create instances in two target accounts
aws cloudformation create-stack-instances \
  --stack-set-name my-set \
  --accounts 222222222222 333333333333 \
  --regions us-east-1 \
  --endpoint-url $AWS_ENDPOINT_URL

# 3. The resources materialize in each target account's namespace
aws cloudformation list-stack-instances \
  --stack-set-name my-set \
  --endpoint-url $AWS_ENDPOINT_URL

CreateStackInstances drives the single-stack engine once per (account, region) pair, provisioning each instance's resources into that target account's namespace — so a queue named orders deployed into accounts 222222222222 and 333333333333 exists independently in each. The stack set, its instances, and its operation history are recorded in the administration (caller) account.

DeleteStackInstances removes instances and their resources, unless RetainStacks=true, which detaches the instances from the stack set but leaves their underlying stacks and resources in place. A stack set must be empty before DeleteStackSet.

A CreateStackInstances / UpdateStackSet operation reports FAILED if any of its instances fails to deploy (the instance is marked INOPERABLE), so polling DescribeStackSetOperation reflects real provisioning outcomes rather than always returning SUCCEEDED.

Configuration

Variable Default Description
FLOCI_SERVICES_CLOUDFORMATION_ENABLED true Enable or disable the service

Examples

export AWS_ENDPOINT_URL=http://localhost:4566

# Validate a template
aws cloudformation validate-template \
  --template-body file://template.yml \
  --endpoint-url $AWS_ENDPOINT_URL

# Deploy a stack
aws cloudformation create-stack \
  --stack-name my-stack \
  --template-body file://template.yml \
  --parameters ParameterKey=Env,ParameterValue=dev \
  --endpoint-url $AWS_ENDPOINT_URL

# Check status
aws cloudformation describe-stacks \
  --stack-name my-stack \
  --endpoint-url $AWS_ENDPOINT_URL

# Watch events
aws cloudformation describe-stack-events \
  --stack-name my-stack \
  --endpoint-url $AWS_ENDPOINT_URL

# Update
aws cloudformation update-stack \
  --stack-name my-stack \
  --template-body file://template.yml \
  --endpoint-url $AWS_ENDPOINT_URL

# Delete
aws cloudformation delete-stack \
  --stack-name my-stack \
  --endpoint-url $AWS_ENDPOINT_URL

# Create a change set
aws cloudformation create-change-set \
  --stack-name my-stack \
  --change-set-name my-change-set \
  --template-body file://template.yml \
  --endpoint-url $AWS_ENDPOINT_URL

# List change sets
aws cloudformation list-change-sets \
  --stack-name my-stack \
  --endpoint-url $AWS_ENDPOINT_URL

# Describe a change set
aws cloudformation describe-change-set \
  --stack-name my-stack \
  --change-set-name my-change-set \
  --endpoint-url $AWS_ENDPOINT_URL

# Delete a change set
aws cloudformation delete-change-set \
  --stack-name my-stack \
  --change-set-name my-change-set \
  --endpoint-url $AWS_ENDPOINT_URL

Lambda + SQS Event Source Mapping

Deploy a Lambda function wired to an SQS queue as a single stack:

# template.yml
Resources:
  MyQueue:
    Type: AWS::SQS::Queue
    Properties:
      QueueName: my-queue

  MyFunction:
    Type: AWS::Lambda::Function
    Properties:
      FunctionName: my-function
      Runtime: nodejs22.x
      Handler: index.handler
      Role: arn:aws:iam::000000000000:role/lambda-role
      Code:
        ZipFile: |
          exports.handler = async (event) => {
            console.log(JSON.stringify(event));
          };

  MyESM:
    Type: AWS::Lambda::EventSourceMapping
    Properties:
      FunctionName: !Ref MyFunction
      EventSourceArn: !GetAtt MyQueue.Arn
      Enabled: true
      BatchSize: 10
aws cloudformation create-stack \
  --stack-name my-lambda-sqs-stack \
  --template-body file://template.yml \
  --endpoint-url $AWS_ENDPOINT_URL

!!! note "Dependency ordering" Use !Ref MyFunction (not a plain string) for FunctionName so CloudFormation provisions the function before the event source mapping.