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 \
    --role-name klug-builds-deployment-role \
    --target-account-id 987654321098 \
    --build-service-profile build-service-profile \
    --profile target-account-profile

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 (required)
  • --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.0.tar.gz (9.7 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.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: klug_builds-1.0.0.tar.gz
  • Upload date:
  • Size: 9.7 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.0.tar.gz
Algorithm Hash digest
SHA256 9249a81a966c0ad3066c446f2a4250516e32d43d4ccc10dc4fc4b6f13f0f1711
MD5 8c13871f1ab96aa624e7e59f03267e1e
BLAKE2b-256 bcc5d026f468f9d04f87af5c6171f3fa4a5a1d0d532a086b697844db7c48b7cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klug_builds-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 caccd5431b377072b51505714e4cd7623f500102d151da9693a77361794f405b
MD5 6f69d43facb3e36b53fc38fc5fdbee3d
BLAKE2b-256 f9a3ab351a9031b2c3d3c274ef2939ab3acb1b0bee82140dbec504b2beaa47ae

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