A Python SDK for Klotho2
Project description
Klotho Python IaC SDK
The Klotho Python IaC SDK is a Python package that provides a pythonic interface to build Klotho applications. The SDK provides a set of APIs to declare and compose Klotho constructs that when executed by the Klotho CLI, will provision and configure the necessary cloud resources to run the application.
⚠️ Important
Klotho 2 is in pre-alpha status.
- Some features may be unstable or incomplete.
- Secrets are currently stored in plaintext.
This SDK is intended for testing and experimentation only and is not suitable for production use.
Installation
Install the Klotho Python Language SDK using Pipenv:
pipenv install klotho
⚠️ Important
Other Python package managers are not yet supported by Klotho.
Pipenv is required by the Klotho CLI.
Usage
The following is an example of a simple Klotho application that creates a Container exposed via an API built using the Klotho Python Language SDK:
import klotho
import klotho.aws as aws
# Create a Klotho application
app = klotho.Application(
name="my-app",
project="my-project",
environment="dev",
default_region="us-east-1",
)
# Create a Postgres database
postgres = aws.Postgres(
"my-postgres",
username="admin",
password=os.getenv("DB_PASSWORD"),
database_name="mydb",
)
# Create a Container resource that binds to the Postgres database
container = aws.Container("my-container", dockerfile="Dockerfile", bindings=[postgres])
# Expose the container via an API
api = aws.API("my-api")
api.route("/my-container", to="container")
Supported Constructs
AWS
Container
The Container construct represents a containerized application that will be deployed as an ECS service to AWS Fargate.
Supported Bindings:
klotho.aws.Postgresklotho.aws.Bucket
Example:
container = klotho.aws.Container("my-container", dockerfile="Dockerfile")
API
The API construct represents an API Gateway (v1) that can be used to expose a containerized application.
Example:
api = klotho.aws.API("my-api")
api.route("/my-container", to=my_container)
Postgres
The Postgres construct represents a PostgreSQL database that can be used by other constructs.
Example:
postgres = klotho.aws.Postgres("my-postgres", username="admin", password=os.getenv("DB_PASSWORD"), database_name="mydb")
FastAPI
The FastAPI construct represents a FastAPI application that can be deployed as an ECS service to AWS Fargate.
Supported Bindings:
klotho.aws.Postgresklotho.aws.Bucket
Example:
fastapi = klotho.aws.FastAPI("my-fastapi", dockerfile="Dockerfile")
Bucket
The Bucket construct represents an S3 bucket that can be used by other constructs.
Example:
bucket = klotho.aws.Bucket("my-bucket")
Support
For questions or issues, please contact the Klotho team on Discord.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file klotho-0.1.1.tar.gz.
File metadata
- Download URL: klotho-0.1.1.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c2eb4d113bc315cf1b9518be88a39de360e6ea08b22242b27a6fe87def9d4e8
|
|
| MD5 |
bb3b40875df41fe7280385efccd16723
|
|
| BLAKE2b-256 |
27c1a6fa615295c4a0771a263774794f326002951755daaa3b8317df20a3716d
|
File details
Details for the file klotho-0.1.1-py3-none-any.whl.
File metadata
- Download URL: klotho-0.1.1-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd85fdf934594b1547348840216dfe8096763a684b62254b87cc3c4b80140048
|
|
| MD5 |
98cd03babe9e5dc6610f731b0cd9acfd
|
|
| BLAKE2b-256 |
abf387ec70261a7893763994d2389f8b6cd4e3f88d7f6342e5c4a156f66169fa
|