Skip to content

Lambda

CloudMock emulates AWS Lambda function management (create, update, delete, list, invoke). Function invocation returns a stub 200 response — actual code execution is not performed.

OperationStatusNotes
CreateFunctionSupportedStores function configuration and code reference
DeleteFunctionSupportedRemoves a function
GetFunctionSupportedReturns function configuration
ListFunctionsSupportedReturns all functions
UpdateFunctionCodeSupportedUpdates the code reference
UpdateFunctionConfigurationSupportedUpdates runtime, handler, environment, etc.
InvokeFunctionSupportedReturns a stub 200 response; does not execute code
AddPermissionSupportedStores a resource-based policy statement
RemovePermissionSupportedRemoves a policy statement
CreateEventSourceMappingSupportedStores an event source mapping
ListEventSourceMappingsSupportedReturns all event source mappings
TagResourceSupportedAdds tags to a function
UntagResourceSupportedRemoves tags from a function
Terminal window
# Create a function
curl -X POST http://localhost:4566/2015-03-31/functions \
-H "Content-Type: application/json" \
-d '{
"FunctionName": "my-function",
"Runtime": "nodejs20.x",
"Role": "arn:aws:iam::000000000000:role/lambda-role",
"Handler": "index.handler",
"Code": {"ZipFile": "UEsDBBQAAAAI..."}
}'
# Invoke (stub response)
curl -X POST http://localhost:4566/2015-03-31/functions/my-function/invocations \
-d '{"key": "value"}'
import { LambdaClient, CreateFunctionCommand, InvokeCommand } from '@aws-sdk/client-lambda';
const lambda = new LambdaClient({
endpoint: 'http://localhost:4566',
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
await lambda.send(new CreateFunctionCommand({
FunctionName: 'hello',
Runtime: 'nodejs20.x',
Role: 'arn:aws:iam::000000000000:role/lambda-role',
Handler: 'index.handler',
Code: { ZipFile: Buffer.from('placeholder') },
}));
const response = await lambda.send(new InvokeCommand({
FunctionName: 'hello', Payload: Buffer.from('{}'),
}));
import boto3, zipfile, io
client = boto3.client('lambda', endpoint_url='http://localhost:4566',
aws_access_key_id='test', aws_secret_access_key='test',
region_name='us-east-1')
buf = io.BytesIO()
with zipfile.ZipFile(buf, 'w') as zf:
zf.writestr('index.js', 'exports.handler = async () => ({ statusCode: 200 });')
buf.seek(0)
client.create_function(
FunctionName='hello', Runtime='nodejs20.x',
Role='arn:aws:iam::000000000000:role/lambda-role',
Handler='index.handler', Code={'ZipFile': buf.read()},
)
response = client.invoke(FunctionName='hello', Payload=b'{}')
print(response['StatusCode']) # 200
cloudmock.yml
services:
lambda:
enabled: true

No additional service-specific configuration is required.

  • Invocation is a stubInvokeFunction returns an empty 200 response without executing any code.
  • Event source mappings are stored and returned but no trigger logic runs.
  • Layers, versions, and aliases are not implemented.
  • Concurrency limits are not enforced.
  • To test Lambda-triggered workflows, invoke your function logic directly in your test code and use CloudMock for the downstream services (SQS, DynamoDB, S3, etc.).
CodeHTTP StatusDescription
ResourceNotFoundException404The specified function does not exist
ResourceConflictException409A function with this name already exists
InvalidParameterValueException400A parameter value is not valid
ServiceException500Internal service error