Skip to main content

AWS CDK constructs library for OpenAB

Project description

cdk-openab

AWS CDK constructs library for deploying OpenAB aka Agent Broker on AWS ECS Fargate.

Architecture
┌───────────────────────────────────────────────────────────────────┐
│  AWS Cloud                                                        │
│                                                                   │
│  ┌─────────────────────────────────────────────────────────────┐  │
│  │  VPC (default: 10.168.0.0/16)                               │  │
│  │                                                             │  │
│  │  ┌───────────────────────────────────────────────────────┐  │  │
│  │  │  Public Subnet                                        │  │  │
│  │  │                                                       │  │  │
│  │  │  ┌─────────────────────────────────────────────────┐  │  │  │
│  │  │  │  ECS Cluster                                    │  │  │  │
│  │  │  │                                                 │  │  │  │
│  │  │  │  ┌───────────────────────────────────────────┐  │  │  │  │
│  │  │  │  │  Fargate Service (FARGATE_SPOT | FARGATE) │  │  │  │  │
│  │  │  │  │                                           │  │  │  │  │
│  │  │  │  │  ┌───────────┐  ┌──────────────────────┐  │  │  │  │  │
│  │  │  │  │  │ data-init │─▶│  app container       │  │  │  │  │  │
│  │  │  │  │  │ (S3 pull) │  │  (port 80)           │  │  │  │  │  │
│  │  │  │  │  └───────────┘  └──────────┬───────────┘  │  │  │  │  │
│  │  │  │  │                            │ stops        │  │  │  │  │
│  │  │  │  │                            ▼              │  │  │  │  │
│  │  │  │  │                 ┌───────────────────────┐ │  │  │  │  │
│  │  │  │  │                 │ data-backup (sidecar) │ │  │  │  │  │
│  │  │  │  │                 │ S3 sync on app stop   │ │  │  │  │  │
│  │  │  │  │                 └───────────────────────┘ │  │  │  │  │
│  │  │  │  └───────────────────────────────────────────┘  │  │  │  │
│  │  │  └─────────────────────────────────────────────────┘  │  │  │
│  │  └───────────────────────────────────────────────────────┘  │  │
│  └─────────────────────────────────────────────────────────────┘  │
│                                                                   │
│  ┌──────────────────┐    ┌──────────────────┐                     │
│  │  S3 (config      │    │  S3 (data        │                     │
│  │  asset)          │    │  bucket)         │                     │
│  │  config.toml     │    │  /home/agent     │                     │
│  └──────────────────┘    └──────────────────┘                     │
└───────────────────────────────────────────────────────────────────┘
Install
# npm
npm install cdk-openab

# pip
pip install cdk-openab
Usage
import { OpenAB } from 'cdk-openab';

new OpenAB(this, 'Broker', {
  configPath: './config.toml',  // required: path to your local config.toml
});

// With custom settings
new OpenAB(this, 'Broker', {
  cpu: 2048,
  memoryLimitMiB: 4096,
  dataS3Prefix: 'my-agent-data',
  configPath: './config.toml',
});
Props
Prop Type Default Description
vpc ec2.IVpc New VPC (public subnet) 自訂 VPC
vpcCidr string 10.168.0.0/16 新建 VPC 的 CIDR
image ecs.ContainerImage ghcr.io/openabdev/openab:9c70cdd Container image
memoryLimitMiB number 4096 Task memory (MiB)
cpu number 2048 Task CPU units
assignPublicIp boolean true 是否分配 public IP
enableFargateSpot boolean true 啟用 FARGATE_SPOT
dataBucket s3.IBucket 自動建立 持久化資料用的 S3 bucket
dataS3Prefix string agent-data S3 資料前綴
dataLocalPath string /home/agent 資料掛載路徑
configPath string 必填 本地 config.toml 路徑,透過 S3 init container 掛載到 /etc/openab/config.toml
Exposed Resources

OpenAB construct 暴露以下屬性,方便後續串接:

  • broker.vpc — VPC
  • broker.cluster — ECS Cluster
  • broker.service — Fargate Service
  • broker.dataBucket — 持久化資料 S3 Bucket
Container Flow
  1. data-init (init container):從 S3 data bucket 還原 /home/agent 資料,並從 S3 asset 下載 config.toml
  2. app:主應用容器,等待 init 完成後啟動,掛載資料目錄(read-write)和 config(read-only)
  3. data-backup (sidecar):每 10 分鐘定期將 /home/agent sync 到 S3 data bucket,並在收到 SIGTERM(app 停止)時執行最後一次備份

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

cdk_openab-0.0.5.tar.gz (40.6 kB view details)

Uploaded Source

Built Distribution

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

cdk_openab-0.0.5-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

Details for the file cdk_openab-0.0.5.tar.gz.

File metadata

  • Download URL: cdk_openab-0.0.5.tar.gz
  • Upload date:
  • Size: 40.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.14.3

File hashes

Hashes for cdk_openab-0.0.5.tar.gz
Algorithm Hash digest
SHA256 03f9b708c5e1a2a98973e2429e372342ec39406f8ac6c75c9cda2119e3c3ef9c
MD5 bfd5bd97a1a112e244ecd723da6b785e
BLAKE2b-256 10176dbe1fb0fb7f5f9f897a8716d6a317f0116562494177d89ba949e89c027a

See more details on using hashes here.

File details

Details for the file cdk_openab-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: cdk_openab-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 39.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.14.3

File hashes

Hashes for cdk_openab-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f0f4517274d101442d4f7a531bb9a5a7205c7e7458c405fa30a316b0eb2c406f
MD5 a4250ee0efad9abd7fd703ef8c09bb62
BLAKE2b-256 b9fc2231a3a5e965f83ff1245bb35ecabb21d5fa761f8f45065ee906e72f8647

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