Skip to content

Latest commit

 

History

History

py-redis

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Redis Sample App

The redis sample app shows how to use the klotho::persist annotation on a node.js redis client to store data.

Prerequisites

This guide assumes:

Run the app locally

To install redis locally follow the instructions on the official redis getting started page

make install
make run

Hit your endpoints

curl -X POST http://localhost:3000/users -d '{"first_name": "john", "last_name": "doe"}' -H "Content-Type: application/json"
# > Success

curl http://localhost:3000/users/john
# > doe

Compile and Deploy with Klotho

run the terminal commands:

# Compile the app
klotho . --app py-redis -p aws

# Go into the compiled directory
cd compiled

# If you didn't set the aws region as indicated in the compiler output, do that now
pulumi config set aws:region YOUR_REGION -s py-redis

# npm install
npm install

# Deploy
pulumi up -s py-redis

# Outputs: {
#   apiUrl: 'https://<...>.execute-api.<YOUR_REGION>.amazonaws.com/stage/'
# }

Calling your service

# Add a user 
curl -X POST  https://<...>.execute-api.us-east-1.amazonaws.com/stage/users -d '{"first_name": "john", "last_name": "doe"}' -H "Content-Type: application/json"
# > Success

# Get a users last name
curl https://<...>.execute-api.us-east-1.amazonaws.com/stage/users/john
# > doe

Clean Up

# Tear down when done
pulumi destroy -s py-redis