3.3.1 Create Application Test Events

Create Application Test Events

SAM Generate Events

sam local generate-event s3 put --bucket my-bucket --key file.json
sam local generate-event apigateway aws-proxy --method GET --path /orders
sam local generate-event sqs receive-message --body '{"orderId":"123"}'
sam local generate-event dynamodb update
sam local generate-event sns notification --message "test"
sam local generate-event eventbridge put-events

Custom Test Event (API Gateway Proxy)

{
  "httpMethod": "POST",
  "path": "/orders",
  "headers": {"Content-Type": "application/json"},
  "body": "{\"productId\": \"prod-123\", \"quantity\": 2}",
  "pathParameters": {"id": "order-123"},
  "queryStringParameters": {"status": "active"},
  "requestContext": {"authorizer": {"claims": {"sub": "user-456"}}}
}

Custom Test Event (SQS)

{
  "Records": [{
    "messageId": "msg-123",
    "body": "{\"orderId\": \"order-123\", \"action\": \"process\"}",
    "attributes": {"ApproximateReceiveCount": "1"},
    "eventSource": "aws:sqs"
  }]
}

Lambda Console Test Events

  • Create from templates (API GW, S3, SQS, etc.)
  • Save and share within account
  • Invoke directly from console

Exam Tip: sam local generate-event supports all major event sources. Custom JSON payloads for specific test scenarios. Console test events for quick validation.