Introducing: Spotinst Serverless Document Store

Introducing: Spotinst Serverless Document Store

Reading Time: 3 minutes

The short-lived nature of functions is great but limiting

Functions are a great way to avoid both the complexity and costs involved with provisioning your infrastructure. This power comes from their transience – Serverless functions only exist when they are called. The caveat here is that any variable that gets set when one function is called gets overwritten, so your data is as transient, disappearing as fast as the Function.  

By introducing Spotinst’s Serverless Document Store (SDS), you can now run store and access the data from your functions, even after they finish running.  

Introducing: Spotinst Serverless Document Store

The Serverless document store allows you to store documents to the environment where your function is running. Here’s how it’s done:

  1. You make a simple HTTP request – GET, POST, or DELETE – or using simple in-function SDK command to interact with the document store.
  2. Those requests are sent securely to a local data store within your environment. With a 1-2ms response time.


This data can then be accessed between function invocations and by multiple functions that are in the same environment. Basically, Spotinst’s Serverless Document Store is exposing an http-based endpoint through which you can fetch stored documents at low latency and at any scale.

You can use the Serverless Document Store to create and store any document up to 5MB with any key. Authorization and identification are handled internally by Spotinst Functions. No other resource or endpoint can access the document unless it is in your Spotinst Function Environment, providing total isolation.

Use Cases

Whether you’re looking to run a stateful application on Serverless or just pass data from one function to another, there are two ways to utilize our Serverless Document Store:

  • Passing data between functions – Here you can pass data between different functions within the same environment. For example, the first function manipulates and stores the data, while the next function takes the data then displays it as a web page.
  • Passing data between invocations – This allows you to store data and pass it on to the next function invocation. For example, you can set a counter that adds one every time a function is called to calculate averages based on the number of invocations

How to start using the Serverless Document Store

All you need to do is make a request to the Spotinst Document Store API. The syntax is straightforward and familiar:

    • GET – gets data from the Document Store
    • CREATE – adds new data to Document Store
    • DELETE – delete an item from Document Store


// NodeJS example
context.getDoc("myKey", function(err, res) {
  if(res) {
    console.log('my Value is ' + res);
    var body = {
      res: res

//Python example
def main(event, context):
    print ('context: %s' % context)

    doc = context.get_doc('myKey')
    print(doc)  #myValue

    res = {
        'statusCode': 200,
        'body': 'res: %s' % doc,
        'headers': {"Content-Type": "application/json"}
    return res


let addDocument = {
  method: "POST",
  qs: {accountId: YourAccount},
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer " + YourToken},
  body: {
    "userDocument": {
      "key": YourKey,
      "value": YourValue}

For more detailed examples, you can check out our Document Store how-to guide or our GitHub repo.