SQS to Fargate to DynamoDB Pattern

This pattern demonstrates how to build and deploy Fargate service using Go which receives messages from SQS queue and stores it in DynamoDB table.

Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage – please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.


  • Create an AWS account if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
  • AWS CLI installed and configured
  • Git installed
  • AWS CDK installed
  • Go installed
  • Docker installed

Deployment Instructions

  1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:
    git clone https://github.com/aws-samples/sqs-fargate-ddb-cdk-go.git
  2. Change directory to the pattern directory:
    cd sqs-fargate-ddb-cdk-go
  3. From the command line, use the following command to deploy the stack using CDK:
    make deploy

How it works

In this pattern we created SQS queue, Fargate Service, and DynamoDB table. Fargate service is receiving messages from SQS queue using long polling (20 seconds) Once you send SQS message to the queue, Fargate service receives this message, parses it, and puts message text into a new item of DynamoDB table.


  1. Open SQS console
  2. Find SQS queue with name sqs-fargate-queue
  3. Press Send and Receive message button
  4. Enter the message into “Message Body” field, e.g.

    "message": "Hello, Fargate"


  1. Press Send message
  2. Open ECS console
  3. Find cluster with name go-service-cluster
  4. Find service named go-fargate-service
  5. Open CloudWatch logs for active task of this service and you’ll messages from the service in the log.


  1. Open DynamoDB console and find sqs-fargate-ddb-table table
  2. Press Explore table items button and you’ll see messages that Fargate service put into the table.



  1. Delete the stack
    make destroy
  2. Confirm the stack has been deleted
    aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'SqsFargate')].StackStatus"


This code is licensed under the MIT-0 License. See the LICENSE file.


View Github