Skip to content

CloudFormation

CloudMock emulates AWS CloudFormation stack management, supporting stack lifecycle, template validation, resource listing, change sets, and exports. Stack resources are stored as metadata — CloudFormation does not create actual resources in the emulator.

OperationStatusNotes
CreateStackSupportedCreates a stack from a template
DeleteStackSupportedDeletes a stack
DescribeStacksSupportedReturns stack metadata and outputs
ListStacksSupportedReturns stack summaries with optional status filter
DescribeStackResourcesSupportedReturns the resources in a stack
DescribeStackEventsSupportedReturns the event history for a stack
GetTemplateSupportedReturns the template body for a stack
ValidateTemplateSupportedValidates a template and returns parameter names
ListExportsSupportedReturns all stack exports
CreateChangeSetSupportedCreates a change set for a stack
DescribeChangeSetSupportedReturns change set details
ExecuteChangeSetSupportedApplies a change set to a stack
DeleteChangeSetSupportedDiscards a change set
Terminal window
# Validate a template
curl -X POST "http://localhost:4566/?Action=ValidateTemplate&TemplateBody=%7B%22AWSTemplateFormatVersion%22%3A%222010-09-09%22%7D"
# Create a stack
curl -X POST "http://localhost:4566/?Action=CreateStack&StackName=my-stack&TemplateBody=%7B%22AWSTemplateFormatVersion%22%3A%222010-09-09%22%7D"
import { CloudFormationClient, CreateStackCommand, DescribeStacksCommand } from '@aws-sdk/client-cloudformation';
const cf = new CloudFormationClient({
endpoint: 'http://localhost:4566',
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
await cf.send(new CreateStackCommand({
StackName: 'infra',
TemplateBody: JSON.stringify({
AWSTemplateFormatVersion: '2010-09-09',
Resources: {
MyBucket: { Type: 'AWS::S3::Bucket', Properties: { BucketName: 'my-cf-bucket' } },
},
}),
}));
const { Stacks } = await cf.send(new DescribeStacksCommand({ StackName: 'infra' }));
console.log(Stacks?.[0]?.StackStatus); // CREATE_COMPLETE
import boto3
cf = boto3.client('cloudformation', endpoint_url='http://localhost:4566',
aws_access_key_id='test', aws_secret_access_key='test',
region_name='us-east-1')
template = """
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
BucketName:
Type: String
Resources:
MyBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
Outputs:
BucketArn:
Value: !GetAtt MyBucket.Arn
"""
cf.create_stack(
StackName='infra', TemplateBody=template,
Parameters=[{'ParameterKey': 'BucketName', 'ParameterValue': 'my-cf-bucket'}],
)
response = cf.describe_stacks(StackName='infra')
print(response['Stacks'][0]['StackStatus']) # CREATE_COMPLETE
cloudmock.yml
services:
cloudformation:
enabled: true

No additional service-specific configuration is required.

  • Stack resources listed in the template are stored as metadata only. CloudFormation does not create actual resources (e.g., an AWS::S3::Bucket in the template does not create a real S3 bucket).
  • Stacks immediately transition to CREATE_COMPLETE after CreateStack.
  • Change sets transition to CREATE_COMPLETE immediately and can be executed without waits.
  • Nested stacks, stack sets, and drift detection are not implemented.
  • Intrinsic functions (!Ref, !GetAtt, etc.) are not evaluated.
CodeHTTP StatusDescription
ValidationError400The template or parameters are not valid
AlreadyExistsException400A stack with this name already exists
ChangeSetNotFound404The specified change set does not exist
InsufficientCapabilitiesException400Required capabilities were not acknowledged