The redis sample app shows how to use the klotho::persist
annotation on a node.js redis client to store data.
This guide assumes:
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
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/'
# }
# 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
# Tear down when done
pulumi destroy -s py-redis