Skip to main content

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.Postgres
  • klotho.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.Postgres
  • klotho.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.

Metadata

Release files for klotho 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for klotho 0.1.1
File Size Uploaded Provenance Actions
klotho-0.1.1.tar.gz 25.5 kB Without provenance Details for klotho-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for klotho 0.1.1
File Interpreter ABI Platform Actions
klotho-0.1.1-py3-none-any.whl Python 3 none any Details for klotho-0.1.1-py3-none-any.whl

Total release size: 56.2 kB

Release files / klotho-0.1.1.tar.gz

Download URL klotho-0.1.1.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8c2eb4d113bc315cf1b9518be88a39de360e6ea08b22242b27a6fe87def9d4e8
BLAKE2b-256 checksum
How to use checksums
27c1a6fa615295c4a0771a263774794f326002951755daaa3b8317df20a3716d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / klotho-0.1.1-py3-none-any.whl

Download URL klotho-0.1.1-py3-none-any.whl
Size 30.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd85fdf934594b1547348840216dfe8096763a684b62254b87cc3c4b80140048
BLAKE2b-256 checksum
How to use checksums
abf387ec70261a7893763994d2389f8b6cd4e3f88d7f6342e5c4a156f66169fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Security for klotho 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page