[{"data":1,"prerenderedAt":76},["ShallowReactive",2],{"pattern-apigw-websocket-sqs-lambda-terraform":3},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":12,"deploy":14,"description":18,"extension":19,"framework":20,"gitHub":21,"highlight":6,"introBox":27,"language":36,"level":37,"meta":38,"patternArch":39,"resources":58,"s3URL":6,"services":6,"stem":70,"testing":71,"videoId":6,"__hash__":75},"patterns\u002Fpatterns\u002Fapigw-websocket-sqs-lambda-terraform.json","Amazon API Gateway WebSocket API to Amazon SQS to AWS Lambda",null,{"headline":8,"text":9},"Cleanup",[10,11],"1. Delete the stack: \u003Ccode>terraform destroy\u003C\u002Fcode>.","2. Confirm the stack has been deleted: \u003Ccode>terraform show\u003C\u002Fcode>",[13],"content\u002Fcontributors\u002Fcarlos-bauer.json",{"text":15},[16,17],"terraform init","terraform apply","Create an API Gateway WebSocket API that sends events to SQS and then to Lambda","json","Terraform",{"template":22},{"projectFolder":23,"repoURL":24,"templateURL":25,"templateFile":26},"apigw-websocket-api-sqs-lambda-terraform","https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fserverless-patterns\u002Ftree\u002Fmain\u002Fapigw-websocket-api-sqs-lambda-terraform","serverless-patterns\u002Fapigw-websocket-api-sqs-lambda-terraform","main.tf",{"headline":28,"text":29},"How it works",[30,31,32,33,34,35],"The API Gateway handles websocket message events by putting the message into a SQS FIFO (First-In-First-Out) queue.","The SQS FIFO queue is used to ensure processing order of the websocket messages.","The message payload must contain a MessageGroupId field which is used by SQS FIFO queue.","If message order is not required, a standard SQS queue can also be used and the message payload would not require the MessageGroupId field.","The API Gateway websocket request integration passes the connectionId and requestId as metadata and the message body as the payload.","The Lambda function can now process the SQS FIFO requests in a batch manner (10 requests at a time) and send a response back to the websocket connection.","Python","200",{},{"icon1":40,"icon2":45,"icon3":48,"line1":52,"line2":56},{"x":41,"y":42,"service":43,"label":44},20,50,"apigw","API Gateway WebSocket API",{"x":42,"y":42,"service":46,"label":47},"sqs","SQS",{"x":49,"y":42,"service":50,"label":51},80,"lambda","AWS Lambda",{"from":53,"to":54,"label":55},"icon1","icon2","",{"from":54,"to":57,"label":55},"icon3",{"headline":59,"bullets":60},"Additional resources",[61,64,67],{"text":62,"link":63},"Working with WebSocket APIs","https:\u002F\u002Fdocs.aws.amazon.com\u002Fapigateway\u002Flatest\u002Fdeveloperguide\u002Fapigateway-websocket-api.html",{"text":65,"link":66},"Announcing WebSocket APIs in Amazon API Gateway","https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Fannouncing-websocket-apis-in-amazon-api-gateway\u002F",{"text":68,"link":69},"Lambda Function Handler","https:\u002F\u002Fdocs.aws.amazon.com\u002Fwhitepapers\u002Flatest\u002Fserverless-architectures-lambda\u002Fthe-handler.html","patterns\u002Fapigw-websocket-sqs-lambda-terraform",{"headline":72,"text":73},"Testing",[74],"See the repo for detailed testing instructions.","kZOsJ63hNLZNUjEwaEQzRP4yh8556NHTE4OewctWLCw",1779186908242]