Git Product home page Git Product logo

dynamodbstreams-lambda-sns-sqs's Introduction

Overview

This is an example of tracking a dynamodb table's changes using dynamodbstreams. Table item updates will trigger a lambda function that will then forward the event payload to an SNS topic. An example SQS subscriber is also provided that will subscribe to the SNS topic and print all event data.

A cloudformation template is provided to create the resources needed in this example. The example-consumer will create the SQS queue that subscribes to the SNS topic upon execution, if needed. The lambda code is in main.go.

How to run

You need to have the following required environment variables:

AWS_ACCT_ID={your-aws-account-id}
AWS_REGION={your-aws-region}
AWS_ACCESS_KEY_ID={key}
AWS_SECRET_ACCESS_KEY={secret}

You also need to create an S3 bucket named lambda-deploy-development for lambda deployment.

This example assumes that you will use an existing table. In my case, I used a test table named TESTSTREAM with dynamodbstreams enabled. View type is "New and old images". The streams' ARN is in the template (EventSourceArn) so you might want to update that part.

Then run the following command from the repo's root folder:

# Note that the GO111MODULE=on variable is enabled during the build.
$ make deploy

Your stack should be ready at this point, provided that the AWS credentials has the permission to create the resources. You can now run the example consumer for testing.

$ cd example-consumer/
$ go build -v
$ ./example-consumer

While the consumer is running, you can update your test table by inserting new items, modifying or removing existing items. The running consumer should print all event data.

Finally, to cleanup the stack, run the following command from the repo's root folder:

# This command will delete the cloudformation stack. It will not delete the SQS queue
# created by example-consumer so you need to delete that manually.
$ make remove

dynamodbstreams-lambda-sns-sqs's People

Contributors

flowerinthenight avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

syllogy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.