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. The role allows the klug-autocloud account (372315927986) to assume it and deploy resources.

klug-builds setup-role \
    --target-account-id 987654321098 \
    --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

What it does:

  • Creates an IAM role in the target account with all necessary permissions
  • Allows the klug-autocloud account (372315927986) to assume the role
  • Includes permissions for:
    • Lambda: Create, update, delete functions and layers
    • API Gateway: Create, update, deploy APIs
    • S3: Read/write for code storage
    • IAM: Pass role for Lambda execution
    • CloudWatch Logs: Create log groups and streams

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)
  • --profile: AWS profile for target account (optional, will prompt for credentials if not provided)
  • --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.2.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.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: klug_builds-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 173496e63704f168b2faff6b456cfec88436833367bc787f79be26642b76921e
MD5 074751fc621d4313e9b872b67ddf1b10
BLAKE2b-256 bfd2b3a874c91b14e3cd269ea94841753f7928997ff8a9efb1e8865effb8f366

See more details on using hashes here.

File details

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

File metadata

  • Download URL: klug_builds-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9bc5be191de30cf359a84b1766a618f1791792c8b86a3b287776aa814ea17e4f
MD5 16c5e882971aef990f1b8026845f21e9
BLAKE2b-256 bbcd4f8fe20f2109a5d4ce40b6a05af632503e27b122c2d11dd89aef097f2e5b

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