Skip to main content

CloudWatch Logs

Protocol: JSON 1.1 (X-Amz-Target: Logs.*)
Endpoint: POST http://localhost:4566/
CloudWatch Logs supports log groups, log streams, event ingestion, retention policies, filtering, and tagging.
ActionDescription
CreateLogGroupCreate a log group
DeleteLogGroupDelete a log group
DescribeLogGroupsList log groups
CreateLogStreamCreate a log stream inside a log group
DeleteLogStreamDelete a log stream
DescribeLogStreamsList log streams in a group
PutLogEventsWrite log events to a stream
GetLogEventsRead log events from a stream
FilterLogEventsSearch log events with a filter pattern
PutRetentionPolicySet log retention (days)
DeleteRetentionPolicyRemove log retention policy
TagLogGroupTag a log group
UntagLogGroupRemove tags
ListTagsLogGroupList tags

Configuration

floci:
  services:
    cloudwatchlogs:
      enabled: true
      max-events-per-query: 10000

Examples

export AWS_ENDPOINT=http://localhost:4566

# Create a log group and stream
aws logs create-log-group --log-group-name /app/backend --endpoint-url $AWS_ENDPOINT
aws logs create-log-stream \
  --log-group-name /app/backend \
  --log-stream-name 2025/01/app-1 \
  --endpoint-url $AWS_ENDPOINT

# Write log events
TIMESTAMP=$(date +%s%3N)   # milliseconds
aws logs put-log-events \
  --log-group-name /app/backend \
  --log-stream-name 2025/01/app-1 \
  --log-events "[{\"timestamp\":$TIMESTAMP,\"message\":\"Service started\"}]" \
  --endpoint-url $AWS_ENDPOINT

# Read log events
aws logs get-log-events \
  --log-group-name /app/backend \
  --log-stream-name 2025/01/app-1 \
  --endpoint-url $AWS_ENDPOINT

# Search logs
aws logs filter-log-events \
  --log-group-name /app/backend \
  --filter-pattern "ERROR" \
  --endpoint-url $AWS_ENDPOINT

# Set retention
aws logs put-retention-policy \
  --log-group-name /app/backend \
  --retention-in-days 30 \
  --endpoint-url $AWS_ENDPOINT

CloudWatch Metrics

Protocol: Query (XML) and JSON 1.1 (both supported)
Endpoint: POST http://localhost:4566/
CloudWatch Metrics supports publishing custom metrics, querying statistics, and managing alarms.
ActionDescription
PutMetricDataPublish custom metrics
ListMetricsList available metrics
GetMetricStatisticsGet metric statistics (Average, Sum, etc.)
GetMetricDataQuery metrics with math expressions
PutMetricAlarmCreate a metric alarm
DescribeAlarmsList alarms
DeleteAlarmsDelete alarms
SetAlarmStateManually set alarm state

Examples

export AWS_ENDPOINT=http://localhost:4566

# Publish a custom metric
aws cloudwatch put-metric-data \
  --namespace MyApp \
  --metric-data '[{
    "MetricName": "RequestCount",
    "Value": 42,
    "Unit": "Count",
    "Dimensions": [{"Name":"Service","Value":"api"}]
  }]' \
  --endpoint-url $AWS_ENDPOINT

# List metrics
aws cloudwatch list-metrics \
  --namespace MyApp \
  --endpoint-url $AWS_ENDPOINT

# Get statistics
aws cloudwatch get-metric-statistics \
  --namespace MyApp \
  --metric-name RequestCount \
  --dimensions Name=Service,Value=api \
  --start-time $(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ) \
  --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
  --period 300 \
  --statistics Sum \
  --endpoint-url $AWS_ENDPOINT

# Create an alarm
aws cloudwatch put-metric-alarm \
  --alarm-name high-error-rate \
  --metric-name ErrorCount \
  --namespace MyApp \
  --statistic Sum \
  --period 60 \
  --threshold 10 \
  --comparison-operator GreaterThanThreshold \
  --evaluation-periods 1 \
  --endpoint-url $AWS_ENDPOINT

Step Functions

Protocol: JSON 1.1 (X-Amz-Target: AmazonStatesService.*)
Endpoint: POST http://localhost:4566/
Step Functions supports Standard and Express state machines with full ASL execution, task token callbacks, and execution history.
ActionDescription
CreateStateMachineCreate a state machine (Standard or Express)
DescribeStateMachineGet state machine definition and metadata
ListStateMachinesList all state machines
DeleteStateMachineDelete a state machine
StartExecutionStart a new execution
DescribeExecutionGet execution status and output
ListExecutionsList executions for a state machine
StopExecutionStop a running execution
GetExecutionHistoryGet the full event history of an execution
SendTaskSuccessReport task success (for .waitForTaskToken tasks)
SendTaskFailureReport task failure
SendTaskHeartbeatSend a heartbeat for long-running tasks

Examples

export AWS_ENDPOINT=http://localhost:4566

# Create a state machine
SM_ARN=$(aws stepfunctions create-state-machine \
  --name my-workflow \
  --definition '{
    "Comment": "Simple workflow",
    "StartAt": "HelloWorld",
    "States": {
      "HelloWorld": {
        "Type": "Pass",
        "Result": {"message": "Hello, World!"},
        "End": true
      }
    }
  }' \
  --role-arn arn:aws:iam::000000000000:role/step-functions-role \
  --query stateMachineArn --output text \
  --endpoint-url $AWS_ENDPOINT)

# Start an execution
EXEC_ARN=$(aws stepfunctions start-execution \
  --state-machine-arn $SM_ARN \
  --input '{"key":"value"}' \
  --query executionArn --output text \
  --endpoint-url $AWS_ENDPOINT)

# Check status
aws stepfunctions describe-execution \
  --execution-arn $EXEC_ARN \
  --endpoint-url $AWS_ENDPOINT

# Get event history
aws stepfunctions get-execution-history \
  --execution-arn $EXEC_ARN \
  --endpoint-url $AWS_ENDPOINT

CloudFormation

Protocol: Query (XML) — POST http://localhost:4566/ with Action= parameter CloudFormation supports stacks, change sets, resource provisioning, stack sets, and stack policies.
ActionDescription
CreateStackDeploy a CloudFormation template
UpdateStackUpdate an existing stack
DeleteStackDelete a stack and its resources
DescribeStacksGet stack status and outputs
ListStacksList stacks by status
DescribeStackEventsGet stack creation/update event history
DescribeStackResourcesGet all resources in a stack
DescribeStackResourceGet a specific stack resource
ListStackResourcesList resource summaries
GetTemplateRetrieve the template body
ValidateTemplateValidate a template without deploying
CreateChangeSetCreate a change set
DescribeChangeSetGet change set details
ExecuteChangeSetApply a change set
ListChangeSetsList change sets for a stack
DeleteChangeSetDelete a change set
SetStackPolicySet a stack policy
GetStackPolicyRetrieve the current stack policy
ListStackSetsList StackSets
DescribeStackSetGet StackSet details
CreateStackSetCreate a new StackSet

Examples

export AWS_ENDPOINT=http://localhost:4566

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

# 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

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

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

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

# 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

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

# Execute the change set
aws cloudformation execute-change-set \
  --stack-name my-stack \
  --change-set-name my-change-set \
  --endpoint-url $AWS_ENDPOINT

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

Build docs developers (and LLMs) love