Skip to main content

CLI tool for building and deploying Lambda functions via KLUG Builds API

Project description

klug-builds

CLI tool for building and deploying Lambda functions via the KLUG Builds API.

Installation

pip install klug-builds

Configuration

Set the API endpoint (optional, defaults to production):

export KLUG_BUILDS_API_ENDPOINT=https://your-api-endpoint.com/prod

For cross-account deployments, you can set:

export KLUG_BUILDS_TARGET_ROLE_ARN=arn:aws:iam::TARGET_ACCOUNT:role/role-name
export KLUG_BUILDS_TARGET_REGION=eu-west-3

Usage

Build and Deploy

Build and deploy Lambda functions from API and layers directories:

klug-builds build api/ layers/ --system main --env dev

With cross-account deployment:

klug-builds build api/ layers/ \
    --system main \
    --env dev \
    --account-id 123456789012 \
    --target-role-arn arn:aws:iam::123456789012:role/klug-builds-role \
    --target-region eu-west-3

List Builds

List all builds:

klug-builds list

Filter by system and environment:

klug-builds list --system main --env dev

Get Build Status

Get status of a specific build:

klug-builds status <build-id>

Setup Cross-Account Role

Create an IAM role in a target AWS account for cross-account deployments:

klug-builds setup-role \
    --target-account-id 987654321098 \
    --build-service-profile build-service-profile \
    --profile target-account-profile

The role name defaults to klug-builds-role if not specified. You can customize it:

klug-builds setup-role \
    --role-name my-custom-role \
    --target-account-id 987654321098

Commands

build

Build and deploy Lambda functions.

Arguments:

  • api_path: Path to API code directory
  • layers_path: Path to layers code directory

Options:

  • --system: System ID (required)
  • --env: Environment name (required)
  • --account-id: Target AWS account ID (optional)
  • --target-role-arn: ARN of IAM role to assume in target account (optional)
  • --target-region: AWS region for target account (optional)

Example:

klug-builds build api/ layers/ --system main --env dev

list

List all builds with optional filtering.

Options:

  • --system: Filter by system ID
  • --env: Filter by environment name
  • --account-id: Filter by account ID

Example:

klug-builds list --system main --env dev

status

Get detailed status of a specific build.

Arguments:

  • build_id: Build ID to query

Example:

klug-builds status abc123-def456-ghi789

setup-role

Create IAM role in target AWS account for cross-account deployments.

Options:

  • --role-name: Name of the IAM role to create (default: klug-builds-role)
  • --target-account-id: Target AWS account ID (required)
  • --build-service-function-name: Build service Lambda function name (default: builds-handler)
  • --build-service-profile: AWS profile for build service account
  • --build-service-region: AWS region for build service (default: eu-west-3)
  • --profile: AWS profile for target account
  • --region: AWS region for target account (default: eu-west-3)

Example:

klug-builds setup-role \
    --role-name klug-builds-deployment-role \
    --target-account-id 987654321098 \
    --build-service-profile build-service \
    --profile target-account

Build Process

The build process follows these steps:

  1. Step 1: Check 3rd party layer → invoke Docker Lambda
  2. Step 2: Check main layer → upload to S3, invoke ZIP Lambda if needed
  3. Step 3: Lambda Functions:
    • 3.1: Create missing functions
    • 3.2: Delete unused functions
    • 3.3-3.5: Update existing functions (code, config, layers)
  4. Step 4: API Gateway → invoke ZIP Lambda
  5. Step 5: Add permissions → direct calls

All operations are idempotent and atomic.

Requirements

  • Python 3.8+
  • AWS credentials configured (for cross-account role setup)
  • Access to KLUG Builds API

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

klug_builds-1.0.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

klug_builds-1.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file klug_builds-1.0.1.tar.gz.

File metadata

  • Download URL: klug_builds-1.0.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for klug_builds-1.0.1.tar.gz
Algorithm Hash digest
SHA256 621039e0fc0c6f75d37d7c1d30c1081e7fd080d77944f8dce289208bb242f718
MD5 41647b1c8461e74c963dee72769c115f
BLAKE2b-256 cdf302ac674931b4613a9e53f82df6ae43daf42f51e53e8e8a8668904d235920

See more details on using hashes here.

File details

Details for the file klug_builds-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: klug_builds-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for klug_builds-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f2faebcfddf3f5ace44eaa363f595640e68d8aa0060cf0fc8b8bc0563323afe2
MD5 840d9387a47946bb9a761597ad2cf3f5
BLAKE2b-256 c289be0b3224019345250114747f104dc5fe9b3d00222ea4029ab0f9ecbe960a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page