Code Monkey home page Code Monkey logo

amazon-dax-lambda-nodejs-sample's Introduction

Amazon DynamoDB Accelerator (DAX) Lambda Node.js Sample

A sample application showing how to use Amazon DynamoDB Accelerator (DAX) with Lambda and CloudFormation. This is based on the blog post at TODO.

Setup & Deployment

Deploying the demo will require npm, the AWS CLI, and an AWS account. The AWS credentials for that account should be set up in the AWS CLI.

First, download the dependencies using npm:

npm install

Then, create a zip file called geturl.zip containing the lambda and node_modules folders. On Mac/Linux/WSL, uses the zip command:

zip -qur geturl node_modules lambda

Otherwise, put the necessary folders in a zip file.

CloudFormation needs the code & template to be stored in an S3 bucket (replace with something unique and remember it as you will need it when packaging and deploying):

aws s3 mb s3://<your-bucket-name>

Now we can create the CloudFormation package and deploy it:

aws cloudformation package --template-file template.yaml --output-template-file packaged-template.yaml --s3-bucket <your-bucket-name>
aws cloudformation deploy --template-file packaged-template.yaml --capabilities CAPABILITY_NAMED_IAM --stack-name amazon-dax-lambda-nodejs-sample

One the CloudFormation stack is created, determine the insternal endpoint name (macOS/Linux/WSL):

endpointUrl=$(aws apigatewayv2 get-apis --query "Items[?Name == 'amazon-dax-lambda-nodejs-sample'].ApiEndpoint" --output text)

To shorten a URL:

curl -d 'https://www.amazon.com' "$endpointUrl"

The output will be a "slug" that can be used to fetch the URL (in this case, grqpaeet):

curl -v "$endpointUrl/grqpaeet"

License Summary

This sample code is made available under a modified MIT license. See the LICENSE file.

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.