Klotho 2.0
Terraform/CDK alternative designed for developers
Describe what your application needs in the way you think about it, Klotho does the rest
Think like an application architect
Describe how your application needs to work, not how it should be implemented
Think
I want my profile service to run in a container, that reads data from a Postgres database and is exposed as an API.
Write

Get

High-level building blocks and interactions
lambda_functions.py
1 # Define a Lambda function for handling profiles2 profile_lambda = Compute.Function(3 name="profile_lambda",4 handler="apps/profile.handler",5 )6 # Create a PostgreSQL database for storing profiles7 profiles_database = Databases.Postgres(name="profiles_db")8
9 # Grant the profile Lambda read access to the profiles database10 profile_lambda.reads_from(profiles_database)
Out-of-the-box open source frameworks built-in
Use Next.js, Django, Svelte, Astro with zero config, and easily add your own
infra.py
1# Next.js service2nextjs_service = Frameworks.NextJS(3 name="nextjs-app",4 context="./nextjs-app"5)
1# Astro service2astro_service = Frameworks.Astro(3 name="astro-app",4 context="./astro-app"5)
1# FastAPI service2fastapi_service = Frameworks.FastAPI(3 name="user-api",4 context="./user-api"5)
1# Django service2django_service = Frameworks.Django(3 name="django-app",4 context="./django-app"5)
1# Remix service2remix_service = Frameworks.Remix(3 name="remix-app",4 context="./remix-app"5)
Mix serverless and serverful technologies freely
lambda_functions.py
1 # Define a Lambda function for handling profiles2 profile_lambda = Compute.Function(3 name="profile_lambda",4 handler="apps/profile.handler",5 )6 # Create a PostgreSQL database for storing profiles7 profiles_database = Databases.Postgres(name="profiles_db")8
9 # Grant the profile Lambda read access to the profiles database10 profile_lambda.reads_from(profiles_database)
Easy domain and API routing
api_config.py
1 # Create a new API2 mysite_api = API(name="mysite-api")3
4 # Attach the profile Lambda function to the "/api/profiles" route5 mysite_api.attach_service(profile_lambda, route="/api/profiles")6
7 # Attach the OCR service to the "/api/ocr" route8 mysite_api.attach_service(ocr, route="/api/ocr")9
10 # Expose the API on this domain11 domain = Domain(name="mysite.com", exposes=mysite_api)
Multi-repo support
github.com/kentoso/invoices-service/infra.py
1 # 'kentoso' is the global the project name2 klotho.Application("billing-service", project="kentoso")3
4 # Define a Lambda function for handling profiles5 Compute.Function(6 name="invoice_lambda",7 handler="src/invoice.handler",8 )
github.com/kentoso/billing-service/infra.py
1 # The same 'kentoso' project2 klotho.Application("billing-service", project="kentoso")3
4 # Import invoice lambda from github.com/kentoso/invoices-service5 invoice_lambda = Compute.Function(from_project=True, name="invoice_lambda")6
7 # This container is defined in the current repo8 billing_service = Compute.Container(context="./billing-service")9
10 # The container we defined in this repo calls the lambda from the other repo11 billing_service.calls(invoice_lambda, protocol="https")
Use Klotho's runtime SDK
app.py
1 # Import the Klotho SDK2 import klotho3 import psycopg24
5 # Get the connection details from Klotho's config store6 users_db = klotho.config.datastores.get("users_db")7
8 # Use the connection details to connect to the database9 conn = psycopg2.connect(10 host=users_db.host,11 port=users_db.port,12 dbname=users_db.name,13 user=users_db.user,14 password=users_db.password15 )
Deploy your infrastructure

Join our community
1.1K+
Github stars
595+
Discord members
8K+
Subscribers