⚡ Lambda

Serverless function execution platform

Lambda runs JavaScript functions and static assets behind HTTP endpoints on HolaCloud.

Lambda

Key features

Create, update, list, delete, and invoke HTTP functions through the Lambda API.

JavaScript functions

Run JavaScript with the built-in runtime helpers such as write, body, query, and headers.

HTTP invocation

Invoke functions through public run URLs, authenticated admin run URLs, or owner/project mux routing.

Static responses

Serve static HTML, CSS, and JavaScript snippets with the same Lambda model.

Quick start

Quick start

Get started with Lambda in seconds using the API.

curl -X POST https://api.hola.cloud/api/v0/lambdas \
  -H 'X-Glue-Authentication: {"user":{"id":"user-123"}}' \
  -d '{"name":"hello","language":"javascript","method":"GET","path":"/hello","code":"write(\"Hello from Lambda\")"}'
POST /api/v0/lambdas HTTP/1.1
Host: api.hola.cloud
X-Glue-Authentication: {"user":{"id":"user-123"}}

{"name":"hello","language":"javascript","method":"GET","path":"/hello","code":"write(\"Hello from Lambda\")"}
// Go 1.21+, standard library only. Save as main.go and run: go run main.go
package main

import (
	"fmt"
	"io"
	"net/http"
	"encoding/json"
	"strings"
)

func main() {
	payload := map[string]any{"code": "write(\"Hello from Lambda\")", "language": "javascript", "method": "GET", "name": "hello", "path": "/hello"}
	bodyBytes, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}
	body := string(bodyBytes)

	req, err := http.NewRequest("POST", "https://api.hola.cloud/api/v0/lambdas", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("X-Glue-Authentication", "{\"user\":{\"id\":\"user-123\"}}")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(resp.Status)
	fmt.Println(string(responseBody))
}
<?php
// PHP 8+ with the curl extension. Save as example.php and run: php example.php

$payload = ['code' => 'write("Hello from Lambda")', 'language' => 'javascript', 'method' => 'GET', 'name' => 'hello', 'path' => '/hello'];
$body = json_encode($payload);

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/api/v0/lambdas',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'X-Glue-Authentication: {"user":{"id":"user-123"}}',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $response, "\n";
curl_close($ch);
# Python 3.8+. Install: pip install requests. Save as example.py and run: python example.py
import requests

headers = {
    "X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}",
}

payload = {"code": "write(\"Hello from Lambda\")", "language": "javascript", "method": "GET", "name": "hello", "path": "/hello"}

response = requests.request(
    "POST",
    "https://api.hola.cloud/api/v0/lambdas",
    headers=headers,
    json=payload
)

print(response.status_code)
print(response.text)
// Node.js 18+. Save as example.mjs and run: node example.mjs
const payload = {"code": "write(\"Hello from Lambda\")", "language": "javascript", "method": "GET", "name": "hello", "path": "/hello"};

const response = await fetch("https://api.hola.cloud/api/v0/lambdas", {
  method: "POST",
  headers: {
    "X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}"
  },
  body: JSON.stringify(payload)
});

console.log(response.status);
console.log(await response.text());
const payload = {"code": "write(\"Hello from Lambda\")", "language": "javascript", "method": "GET", "name": "hello", "path": "/hello"};

const response = await fetch("https://api.hola.cloud/api/v0/lambdas", {
  method: "POST",
  headers: {
    "X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}"
  },
  body: JSON.stringify(payload)
});

console.log(response.status);
console.log(await response.text());
// Java 17+, standard library only. Save as Main.java and run: java Main.java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var body = """
{"name":"hello","language":"javascript","method":"GET","path":"/hello","code":"write(\"Hello from Lambda\")"}
""";

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/api/v0/lambdas"))
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .header("X-Glue-Authentication", "{\"user\":{\"id\":\"user-123\"}}")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode());
        System.out.println(response.body());
    }
}
Use cases

Common use cases

Microservices orchestration

Build and deploy with Lambda on HolaCloud's enterprise platform, designed for security, reliability, and scale.

Data pipeline automation

Build and deploy with Lambda on HolaCloud's enterprise platform, designed for security, reliability, and scale.

Event-driven architectures

Build and deploy with Lambda on HolaCloud's enterprise platform, designed for security, reliability, and scale.

API backend development

Build and deploy with Lambda on HolaCloud's enterprise platform, designed for security, reliability, and scale.

Ready to get started?

Explore the documentation or launch the console to start building with Lambda.

Comments

Leave a comment