AWS CDK constructs library for Agent Broker
Project description
cdk-agent-broker
AWS CDK constructs library for deploying 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-agent-broker
# pip
pip install cdk-agent-broker
Usage
import { AgentBroker } from 'cdk-agent-broker';
new AgentBroker(this, 'Broker', {
configPath: './config.toml', // required: path to your local config.toml
});
// With custom settings
new AgentBroker(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/thepagent/agent-broker:dd7e1ca |
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/agent-broker/config.toml |
Exposed Resources
AgentBroker construct 暴露以下屬性,方便後續串接:
broker.vpc— VPCbroker.cluster— ECS Clusterbroker.service— Fargate Servicebroker.dataBucket— 持久化資料 S3 Bucket
Container Flow
data-init(init container):從 S3 data bucket 還原/home/agent資料,並從 S3 asset 下載config.tomlapp:主應用容器,等待 init 完成後啟動,掛載資料目錄(read-write)和 config(read-only)data-backup(sidecar):每 10 分鐘定期將/home/agentsync 到 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_agent_broker-0.0.2.tar.gz
(40.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cdk_agent_broker-0.0.2.tar.gz.
File metadata
- Download URL: cdk_agent_broker-0.0.2.tar.gz
- Upload date:
- Size: 40.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a18dc1fdfee96fffe98d18d8b6c781fec8a73320982f0600e3abc24c11bfdebc
|
|
| MD5 |
db99a16ce537e098d0562e499bf0d45d
|
|
| BLAKE2b-256 |
d1f9a72a61fc2080aaa37650601d2b28fe1998e73717315fd238fb0f44981b83
|
File details
Details for the file cdk_agent_broker-0.0.2-py3-none-any.whl.
File metadata
- Download URL: cdk_agent_broker-0.0.2-py3-none-any.whl
- Upload date:
- Size: 39.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5fd57f88c3075b3d6ed88c1f27894d27369d0d547bfacf4a33fca6c2ef31c3b
|
|
| MD5 |
7f472f46bea2db707c797e71a81891be
|
|
| BLAKE2b-256 |
a599aaff42ef9896d3eae30f07fdb7ebcf9d3e7d52112ac67fbea5021a671f2b
|