cdk-openab 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cdk_openab-0.0.4/LICENSE +202 -0
- cdk_openab-0.0.4/MANIFEST.in +1 -0
- cdk_openab-0.0.4/PKG-INFO +130 -0
- cdk_openab-0.0.4/README.md +103 -0
- cdk_openab-0.0.4/pyproject.toml +9 -0
- cdk_openab-0.0.4/setup.cfg +4 -0
- cdk_openab-0.0.4/setup.py +64 -0
- cdk_openab-0.0.4/src/cdk_openab/__init__.py +495 -0
- cdk_openab-0.0.4/src/cdk_openab/_jsii/__init__.py +42 -0
- cdk_openab-0.0.4/src/cdk_openab/_jsii/cdk-openab@0.0.4.jsii.tgz +0 -0
- cdk_openab-0.0.4/src/cdk_openab/py.typed +1 -0
- cdk_openab-0.0.4/src/cdk_openab.egg-info/PKG-INFO +130 -0
- cdk_openab-0.0.4/src/cdk_openab.egg-info/SOURCES.txt +14 -0
- cdk_openab-0.0.4/src/cdk_openab.egg-info/dependency_links.txt +1 -0
- cdk_openab-0.0.4/src/cdk_openab.egg-info/requires.txt +5 -0
- cdk_openab-0.0.4/src/cdk_openab.egg-info/top_level.txt +1 -0
cdk_openab-0.0.4/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include pyproject.toml
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cdk-openab
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: AWS CDK constructs library for OpenAB
|
|
5
|
+
Home-page: https://github.com/neilkuan/cdk-openab.git
|
|
6
|
+
Author: Neil Kuan<guan840912@gmail.com>
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Project-URL: Source, https://github.com/neilkuan/cdk-openab.git
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: JavaScript
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Classifier: Development Status :: 4 - Beta
|
|
18
|
+
Classifier: License :: OSI Approved
|
|
19
|
+
Requires-Python: ~=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: aws-cdk-lib<3.0.0,>=2.170.0
|
|
23
|
+
Requires-Dist: constructs<11.0.0,>=10.5.1
|
|
24
|
+
Requires-Dist: jsii<2.0.0,>=1.127.0
|
|
25
|
+
Requires-Dist: publication>=0.0.3
|
|
26
|
+
Requires-Dist: typeguard==2.13.3
|
|
27
|
+
|
|
28
|
+
# cdk-openab
|
|
29
|
+
|
|
30
|
+
AWS CDK constructs library for deploying [OpenAB aka Agent Broker](https://github.com/openabdev/openab) on AWS ECS Fargate.
|
|
31
|
+
|
|
32
|
+
##### Architecture
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
┌───────────────────────────────────────────────────────────────────┐
|
|
36
|
+
│ AWS Cloud │
|
|
37
|
+
│ │
|
|
38
|
+
│ ┌─────────────────────────────────────────────────────────────┐ │
|
|
39
|
+
│ │ VPC (default: 10.168.0.0/16) │ │
|
|
40
|
+
│ │ │ │
|
|
41
|
+
│ │ ┌───────────────────────────────────────────────────────┐ │ │
|
|
42
|
+
│ │ │ Public Subnet │ │ │
|
|
43
|
+
│ │ │ │ │ │
|
|
44
|
+
│ │ │ ┌─────────────────────────────────────────────────┐ │ │ │
|
|
45
|
+
│ │ │ │ ECS Cluster │ │ │ │
|
|
46
|
+
│ │ │ │ │ │ │ │
|
|
47
|
+
│ │ │ │ ┌───────────────────────────────────────────┐ │ │ │ │
|
|
48
|
+
│ │ │ │ │ Fargate Service (FARGATE_SPOT | FARGATE) │ │ │ │ │
|
|
49
|
+
│ │ │ │ │ │ │ │ │ │
|
|
50
|
+
│ │ │ │ │ ┌───────────┐ ┌──────────────────────┐ │ │ │ │ │
|
|
51
|
+
│ │ │ │ │ │ data-init │─▶│ app container │ │ │ │ │ │
|
|
52
|
+
│ │ │ │ │ │ (S3 pull) │ │ (port 80) │ │ │ │ │ │
|
|
53
|
+
│ │ │ │ │ └───────────┘ └──────────┬───────────┘ │ │ │ │ │
|
|
54
|
+
│ │ │ │ │ │ stops │ │ │ │ │
|
|
55
|
+
│ │ │ │ │ ▼ │ │ │ │ │
|
|
56
|
+
│ │ │ │ │ ┌───────────────────────┐ │ │ │ │ │
|
|
57
|
+
│ │ │ │ │ │ data-backup (sidecar) │ │ │ │ │ │
|
|
58
|
+
│ │ │ │ │ │ S3 sync on app stop │ │ │ │ │ │
|
|
59
|
+
│ │ │ │ │ └───────────────────────┘ │ │ │ │ │
|
|
60
|
+
│ │ │ │ └───────────────────────────────────────────┘ │ │ │ │
|
|
61
|
+
│ │ │ └─────────────────────────────────────────────────┘ │ │ │
|
|
62
|
+
│ │ └───────────────────────────────────────────────────────┘ │ │
|
|
63
|
+
│ └─────────────────────────────────────────────────────────────┘ │
|
|
64
|
+
│ │
|
|
65
|
+
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
66
|
+
│ │ S3 (config │ │ S3 (data │ │
|
|
67
|
+
│ │ asset) │ │ bucket) │ │
|
|
68
|
+
│ │ config.toml │ │ /home/agent │ │
|
|
69
|
+
│ └──────────────────┘ └──────────────────┘ │
|
|
70
|
+
└───────────────────────────────────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
##### Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# npm
|
|
77
|
+
npm install cdk-openab
|
|
78
|
+
|
|
79
|
+
# pip
|
|
80
|
+
pip install cdk-openab
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
##### Usage
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import { OpenAB } from 'cdk-openab';
|
|
87
|
+
|
|
88
|
+
new OpenAB(this, 'Broker', {
|
|
89
|
+
configPath: './config.toml', // required: path to your local config.toml
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// With custom settings
|
|
93
|
+
new OpenAB(this, 'Broker', {
|
|
94
|
+
cpu: 2048,
|
|
95
|
+
memoryLimitMiB: 4096,
|
|
96
|
+
dataS3Prefix: 'my-agent-data',
|
|
97
|
+
configPath: './config.toml',
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
##### Props
|
|
102
|
+
|
|
103
|
+
| Prop | Type | Default | Description |
|
|
104
|
+
|------|------|---------|-------------|
|
|
105
|
+
| `vpc` | `ec2.IVpc` | New VPC (public subnet) | 自訂 VPC |
|
|
106
|
+
| `vpcCidr` | `string` | `10.168.0.0/16` | 新建 VPC 的 CIDR |
|
|
107
|
+
| `image` | `ecs.ContainerImage` | `ghcr.io/thepagent/openab:dd7e1ca` | Container image |
|
|
108
|
+
| `memoryLimitMiB` | `number` | `4096` | Task memory (MiB) |
|
|
109
|
+
| `cpu` | `number` | `2048` | Task CPU units |
|
|
110
|
+
| `assignPublicIp` | `boolean` | `true` | 是否分配 public IP |
|
|
111
|
+
| `enableFargateSpot` | `boolean` | `true` | 啟用 FARGATE_SPOT |
|
|
112
|
+
| `dataBucket` | `s3.IBucket` | 自動建立 | 持久化資料用的 S3 bucket |
|
|
113
|
+
| `dataS3Prefix` | `string` | `agent-data` | S3 資料前綴 |
|
|
114
|
+
| `dataLocalPath` | `string` | `/home/agent` | 資料掛載路徑 |
|
|
115
|
+
| `configPath` | `string` | **必填** | 本地 config.toml 路徑,透過 S3 init container 掛載到 `/etc/openab/config.toml` |
|
|
116
|
+
|
|
117
|
+
##### Exposed Resources
|
|
118
|
+
|
|
119
|
+
`OpenAB` construct 暴露以下屬性,方便後續串接:
|
|
120
|
+
|
|
121
|
+
* `broker.vpc` — VPC
|
|
122
|
+
* `broker.cluster` — ECS Cluster
|
|
123
|
+
* `broker.service` — Fargate Service
|
|
124
|
+
* `broker.dataBucket` — 持久化資料 S3 Bucket
|
|
125
|
+
|
|
126
|
+
##### Container Flow
|
|
127
|
+
|
|
128
|
+
1. **`data-init`** (init container):從 S3 data bucket 還原 `/home/agent` 資料,並從 S3 asset 下載 `config.toml`
|
|
129
|
+
2. **`app`**:主應用容器,等待 init 完成後啟動,掛載資料目錄(read-write)和 config(read-only)
|
|
130
|
+
3. **`data-backup`** (sidecar):每 10 分鐘定期將 `/home/agent` sync 到 S3 data bucket,並在收到 SIGTERM(app 停止)時執行最後一次備份
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# cdk-openab
|
|
2
|
+
|
|
3
|
+
AWS CDK constructs library for deploying [OpenAB aka Agent Broker](https://github.com/openabdev/openab) on AWS ECS Fargate.
|
|
4
|
+
|
|
5
|
+
##### Architecture
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌───────────────────────────────────────────────────────────────────┐
|
|
9
|
+
│ AWS Cloud │
|
|
10
|
+
│ │
|
|
11
|
+
│ ┌─────────────────────────────────────────────────────────────┐ │
|
|
12
|
+
│ │ VPC (default: 10.168.0.0/16) │ │
|
|
13
|
+
│ │ │ │
|
|
14
|
+
│ │ ┌───────────────────────────────────────────────────────┐ │ │
|
|
15
|
+
│ │ │ Public Subnet │ │ │
|
|
16
|
+
│ │ │ │ │ │
|
|
17
|
+
│ │ │ ┌─────────────────────────────────────────────────┐ │ │ │
|
|
18
|
+
│ │ │ │ ECS Cluster │ │ │ │
|
|
19
|
+
│ │ │ │ │ │ │ │
|
|
20
|
+
│ │ │ │ ┌───────────────────────────────────────────┐ │ │ │ │
|
|
21
|
+
│ │ │ │ │ Fargate Service (FARGATE_SPOT | FARGATE) │ │ │ │ │
|
|
22
|
+
│ │ │ │ │ │ │ │ │ │
|
|
23
|
+
│ │ │ │ │ ┌───────────┐ ┌──────────────────────┐ │ │ │ │ │
|
|
24
|
+
│ │ │ │ │ │ data-init │─▶│ app container │ │ │ │ │ │
|
|
25
|
+
│ │ │ │ │ │ (S3 pull) │ │ (port 80) │ │ │ │ │ │
|
|
26
|
+
│ │ │ │ │ └───────────┘ └──────────┬───────────┘ │ │ │ │ │
|
|
27
|
+
│ │ │ │ │ │ stops │ │ │ │ │
|
|
28
|
+
│ │ │ │ │ ▼ │ │ │ │ │
|
|
29
|
+
│ │ │ │ │ ┌───────────────────────┐ │ │ │ │ │
|
|
30
|
+
│ │ │ │ │ │ data-backup (sidecar) │ │ │ │ │ │
|
|
31
|
+
│ │ │ │ │ │ S3 sync on app stop │ │ │ │ │ │
|
|
32
|
+
│ │ │ │ │ └───────────────────────┘ │ │ │ │ │
|
|
33
|
+
│ │ │ │ └───────────────────────────────────────────┘ │ │ │ │
|
|
34
|
+
│ │ │ └─────────────────────────────────────────────────┘ │ │ │
|
|
35
|
+
│ │ └───────────────────────────────────────────────────────┘ │ │
|
|
36
|
+
│ └─────────────────────────────────────────────────────────────┘ │
|
|
37
|
+
│ │
|
|
38
|
+
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
39
|
+
│ │ S3 (config │ │ S3 (data │ │
|
|
40
|
+
│ │ asset) │ │ bucket) │ │
|
|
41
|
+
│ │ config.toml │ │ /home/agent │ │
|
|
42
|
+
│ └──────────────────┘ └──────────────────┘ │
|
|
43
|
+
└───────────────────────────────────────────────────────────────────┘
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
##### Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# npm
|
|
50
|
+
npm install cdk-openab
|
|
51
|
+
|
|
52
|
+
# pip
|
|
53
|
+
pip install cdk-openab
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
##### Usage
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import { OpenAB } from 'cdk-openab';
|
|
60
|
+
|
|
61
|
+
new OpenAB(this, 'Broker', {
|
|
62
|
+
configPath: './config.toml', // required: path to your local config.toml
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// With custom settings
|
|
66
|
+
new OpenAB(this, 'Broker', {
|
|
67
|
+
cpu: 2048,
|
|
68
|
+
memoryLimitMiB: 4096,
|
|
69
|
+
dataS3Prefix: 'my-agent-data',
|
|
70
|
+
configPath: './config.toml',
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
##### Props
|
|
75
|
+
|
|
76
|
+
| Prop | Type | Default | Description |
|
|
77
|
+
|------|------|---------|-------------|
|
|
78
|
+
| `vpc` | `ec2.IVpc` | New VPC (public subnet) | 自訂 VPC |
|
|
79
|
+
| `vpcCidr` | `string` | `10.168.0.0/16` | 新建 VPC 的 CIDR |
|
|
80
|
+
| `image` | `ecs.ContainerImage` | `ghcr.io/thepagent/openab:dd7e1ca` | Container image |
|
|
81
|
+
| `memoryLimitMiB` | `number` | `4096` | Task memory (MiB) |
|
|
82
|
+
| `cpu` | `number` | `2048` | Task CPU units |
|
|
83
|
+
| `assignPublicIp` | `boolean` | `true` | 是否分配 public IP |
|
|
84
|
+
| `enableFargateSpot` | `boolean` | `true` | 啟用 FARGATE_SPOT |
|
|
85
|
+
| `dataBucket` | `s3.IBucket` | 自動建立 | 持久化資料用的 S3 bucket |
|
|
86
|
+
| `dataS3Prefix` | `string` | `agent-data` | S3 資料前綴 |
|
|
87
|
+
| `dataLocalPath` | `string` | `/home/agent` | 資料掛載路徑 |
|
|
88
|
+
| `configPath` | `string` | **必填** | 本地 config.toml 路徑,透過 S3 init container 掛載到 `/etc/openab/config.toml` |
|
|
89
|
+
|
|
90
|
+
##### Exposed Resources
|
|
91
|
+
|
|
92
|
+
`OpenAB` construct 暴露以下屬性,方便後續串接:
|
|
93
|
+
|
|
94
|
+
* `broker.vpc` — VPC
|
|
95
|
+
* `broker.cluster` — ECS Cluster
|
|
96
|
+
* `broker.service` — Fargate Service
|
|
97
|
+
* `broker.dataBucket` — 持久化資料 S3 Bucket
|
|
98
|
+
|
|
99
|
+
##### Container Flow
|
|
100
|
+
|
|
101
|
+
1. **`data-init`** (init container):從 S3 data bucket 還原 `/home/agent` 資料,並從 S3 asset 下載 `config.toml`
|
|
102
|
+
2. **`app`**:主應用容器,等待 init 完成後啟動,掛載資料目錄(read-write)和 config(read-only)
|
|
103
|
+
3. **`data-backup`** (sidecar):每 10 分鐘定期將 `/home/agent` sync 到 S3 data bucket,並在收到 SIGTERM(app 停止)時執行最後一次備份
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import setuptools
|
|
3
|
+
|
|
4
|
+
kwargs = json.loads(
|
|
5
|
+
"""
|
|
6
|
+
{
|
|
7
|
+
"name": "cdk-openab",
|
|
8
|
+
"version": "0.0.4",
|
|
9
|
+
"description": "AWS CDK constructs library for OpenAB",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"url": "https://github.com/neilkuan/cdk-openab.git",
|
|
12
|
+
"long_description_content_type": "text/markdown",
|
|
13
|
+
"author": "Neil Kuan<guan840912@gmail.com>",
|
|
14
|
+
"bdist_wheel": {
|
|
15
|
+
"universal": true
|
|
16
|
+
},
|
|
17
|
+
"project_urls": {
|
|
18
|
+
"Source": "https://github.com/neilkuan/cdk-openab.git"
|
|
19
|
+
},
|
|
20
|
+
"package_dir": {
|
|
21
|
+
"": "src"
|
|
22
|
+
},
|
|
23
|
+
"packages": [
|
|
24
|
+
"cdk_openab",
|
|
25
|
+
"cdk_openab._jsii"
|
|
26
|
+
],
|
|
27
|
+
"package_data": {
|
|
28
|
+
"cdk_openab._jsii": [
|
|
29
|
+
"cdk-openab@0.0.4.jsii.tgz"
|
|
30
|
+
],
|
|
31
|
+
"cdk_openab": [
|
|
32
|
+
"py.typed"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"python_requires": "~=3.9",
|
|
36
|
+
"install_requires": [
|
|
37
|
+
"aws-cdk-lib>=2.170.0, <3.0.0",
|
|
38
|
+
"constructs>=10.5.1, <11.0.0",
|
|
39
|
+
"jsii>=1.127.0, <2.0.0",
|
|
40
|
+
"publication>=0.0.3",
|
|
41
|
+
"typeguard==2.13.3"
|
|
42
|
+
],
|
|
43
|
+
"classifiers": [
|
|
44
|
+
"Intended Audience :: Developers",
|
|
45
|
+
"Operating System :: OS Independent",
|
|
46
|
+
"Programming Language :: JavaScript",
|
|
47
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
48
|
+
"Programming Language :: Python :: 3.9",
|
|
49
|
+
"Programming Language :: Python :: 3.10",
|
|
50
|
+
"Programming Language :: Python :: 3.11",
|
|
51
|
+
"Typing :: Typed",
|
|
52
|
+
"Development Status :: 4 - Beta",
|
|
53
|
+
"License :: OSI Approved"
|
|
54
|
+
],
|
|
55
|
+
"scripts": []
|
|
56
|
+
}
|
|
57
|
+
"""
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
with open("README.md", encoding="utf8") as fp:
|
|
61
|
+
kwargs["long_description"] = fp.read()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
setuptools.setup(**kwargs)
|
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
r'''
|
|
2
|
+
# cdk-openab
|
|
3
|
+
|
|
4
|
+
AWS CDK constructs library for deploying [OpenAB aka Agent Broker](https://github.com/openabdev/openab) on AWS ECS Fargate.
|
|
5
|
+
|
|
6
|
+
##### Architecture
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
┌───────────────────────────────────────────────────────────────────┐
|
|
10
|
+
│ AWS Cloud │
|
|
11
|
+
│ │
|
|
12
|
+
│ ┌─────────────────────────────────────────────────────────────┐ │
|
|
13
|
+
│ │ VPC (default: 10.168.0.0/16) │ │
|
|
14
|
+
│ │ │ │
|
|
15
|
+
│ │ ┌───────────────────────────────────────────────────────┐ │ │
|
|
16
|
+
│ │ │ Public Subnet │ │ │
|
|
17
|
+
│ │ │ │ │ │
|
|
18
|
+
│ │ │ ┌─────────────────────────────────────────────────┐ │ │ │
|
|
19
|
+
│ │ │ │ ECS Cluster │ │ │ │
|
|
20
|
+
│ │ │ │ │ │ │ │
|
|
21
|
+
│ │ │ │ ┌───────────────────────────────────────────┐ │ │ │ │
|
|
22
|
+
│ │ │ │ │ Fargate Service (FARGATE_SPOT | FARGATE) │ │ │ │ │
|
|
23
|
+
│ │ │ │ │ │ │ │ │ │
|
|
24
|
+
│ │ │ │ │ ┌───────────┐ ┌──────────────────────┐ │ │ │ │ │
|
|
25
|
+
│ │ │ │ │ │ data-init │─▶│ app container │ │ │ │ │ │
|
|
26
|
+
│ │ │ │ │ │ (S3 pull) │ │ (port 80) │ │ │ │ │ │
|
|
27
|
+
│ │ │ │ │ └───────────┘ └──────────┬───────────┘ │ │ │ │ │
|
|
28
|
+
│ │ │ │ │ │ stops │ │ │ │ │
|
|
29
|
+
│ │ │ │ │ ▼ │ │ │ │ │
|
|
30
|
+
│ │ │ │ │ ┌───────────────────────┐ │ │ │ │ │
|
|
31
|
+
│ │ │ │ │ │ data-backup (sidecar) │ │ │ │ │ │
|
|
32
|
+
│ │ │ │ │ │ S3 sync on app stop │ │ │ │ │ │
|
|
33
|
+
│ │ │ │ │ └───────────────────────┘ │ │ │ │ │
|
|
34
|
+
│ │ │ │ └───────────────────────────────────────────┘ │ │ │ │
|
|
35
|
+
│ │ │ └─────────────────────────────────────────────────┘ │ │ │
|
|
36
|
+
│ │ └───────────────────────────────────────────────────────┘ │ │
|
|
37
|
+
│ └─────────────────────────────────────────────────────────────┘ │
|
|
38
|
+
│ │
|
|
39
|
+
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
40
|
+
│ │ S3 (config │ │ S3 (data │ │
|
|
41
|
+
│ │ asset) │ │ bucket) │ │
|
|
42
|
+
│ │ config.toml │ │ /home/agent │ │
|
|
43
|
+
│ └──────────────────┘ └──────────────────┘ │
|
|
44
|
+
└───────────────────────────────────────────────────────────────────┘
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
##### Install
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# npm
|
|
51
|
+
npm install cdk-openab
|
|
52
|
+
|
|
53
|
+
# pip
|
|
54
|
+
pip install cdk-openab
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
##### Usage
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import { OpenAB } from 'cdk-openab';
|
|
61
|
+
|
|
62
|
+
new OpenAB(this, 'Broker', {
|
|
63
|
+
configPath: './config.toml', // required: path to your local config.toml
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// With custom settings
|
|
67
|
+
new OpenAB(this, 'Broker', {
|
|
68
|
+
cpu: 2048,
|
|
69
|
+
memoryLimitMiB: 4096,
|
|
70
|
+
dataS3Prefix: 'my-agent-data',
|
|
71
|
+
configPath: './config.toml',
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
##### Props
|
|
76
|
+
|
|
77
|
+
| Prop | Type | Default | Description |
|
|
78
|
+
|------|------|---------|-------------|
|
|
79
|
+
| `vpc` | `ec2.IVpc` | New VPC (public subnet) | 自訂 VPC |
|
|
80
|
+
| `vpcCidr` | `string` | `10.168.0.0/16` | 新建 VPC 的 CIDR |
|
|
81
|
+
| `image` | `ecs.ContainerImage` | `ghcr.io/thepagent/openab:dd7e1ca` | Container image |
|
|
82
|
+
| `memoryLimitMiB` | `number` | `4096` | Task memory (MiB) |
|
|
83
|
+
| `cpu` | `number` | `2048` | Task CPU units |
|
|
84
|
+
| `assignPublicIp` | `boolean` | `true` | 是否分配 public IP |
|
|
85
|
+
| `enableFargateSpot` | `boolean` | `true` | 啟用 FARGATE_SPOT |
|
|
86
|
+
| `dataBucket` | `s3.IBucket` | 自動建立 | 持久化資料用的 S3 bucket |
|
|
87
|
+
| `dataS3Prefix` | `string` | `agent-data` | S3 資料前綴 |
|
|
88
|
+
| `dataLocalPath` | `string` | `/home/agent` | 資料掛載路徑 |
|
|
89
|
+
| `configPath` | `string` | **必填** | 本地 config.toml 路徑,透過 S3 init container 掛載到 `/etc/openab/config.toml` |
|
|
90
|
+
|
|
91
|
+
##### Exposed Resources
|
|
92
|
+
|
|
93
|
+
`OpenAB` construct 暴露以下屬性,方便後續串接:
|
|
94
|
+
|
|
95
|
+
* `broker.vpc` — VPC
|
|
96
|
+
* `broker.cluster` — ECS Cluster
|
|
97
|
+
* `broker.service` — Fargate Service
|
|
98
|
+
* `broker.dataBucket` — 持久化資料 S3 Bucket
|
|
99
|
+
|
|
100
|
+
##### Container Flow
|
|
101
|
+
|
|
102
|
+
1. **`data-init`** (init container):從 S3 data bucket 還原 `/home/agent` 資料,並從 S3 asset 下載 `config.toml`
|
|
103
|
+
2. **`app`**:主應用容器,等待 init 完成後啟動,掛載資料目錄(read-write)和 config(read-only)
|
|
104
|
+
3. **`data-backup`** (sidecar):每 10 分鐘定期將 `/home/agent` sync 到 S3 data bucket,並在收到 SIGTERM(app 停止)時執行最後一次備份
|
|
105
|
+
'''
|
|
106
|
+
from pkgutil import extend_path
|
|
107
|
+
__path__ = extend_path(__path__, __name__)
|
|
108
|
+
|
|
109
|
+
import abc
|
|
110
|
+
import builtins
|
|
111
|
+
import datetime
|
|
112
|
+
import enum
|
|
113
|
+
import typing
|
|
114
|
+
|
|
115
|
+
import jsii
|
|
116
|
+
import publication
|
|
117
|
+
import typing_extensions
|
|
118
|
+
|
|
119
|
+
import typeguard
|
|
120
|
+
from importlib.metadata import version as _metadata_package_version
|
|
121
|
+
TYPEGUARD_MAJOR_VERSION = int(_metadata_package_version('typeguard').split('.')[0])
|
|
122
|
+
|
|
123
|
+
def check_type(argname: str, value: object, expected_type: typing.Any) -> typing.Any:
|
|
124
|
+
if TYPEGUARD_MAJOR_VERSION <= 2:
|
|
125
|
+
return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore
|
|
126
|
+
else:
|
|
127
|
+
if isinstance(value, jsii._reference_map.InterfaceDynamicProxy): # pyright: ignore [reportAttributeAccessIssue]
|
|
128
|
+
pass
|
|
129
|
+
else:
|
|
130
|
+
if TYPEGUARD_MAJOR_VERSION == 3:
|
|
131
|
+
typeguard.config.collection_check_strategy = typeguard.CollectionCheckStrategy.ALL_ITEMS # type:ignore
|
|
132
|
+
typeguard.check_type(value=value, expected_type=expected_type) # type:ignore
|
|
133
|
+
else:
|
|
134
|
+
typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore
|
|
135
|
+
|
|
136
|
+
from ._jsii import *
|
|
137
|
+
|
|
138
|
+
import aws_cdk.aws_ec2 as _aws_cdk_aws_ec2_ceddda9d
|
|
139
|
+
import aws_cdk.aws_ecs as _aws_cdk_aws_ecs_ceddda9d
|
|
140
|
+
import aws_cdk.aws_logs as _aws_cdk_aws_logs_ceddda9d
|
|
141
|
+
import aws_cdk.aws_s3 as _aws_cdk_aws_s3_ceddda9d
|
|
142
|
+
import constructs as _constructs_77d1e7e8
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class OpenAB(
|
|
146
|
+
_constructs_77d1e7e8.Construct,
|
|
147
|
+
metaclass=jsii.JSIIMeta,
|
|
148
|
+
jsii_type="cdk-openab.OpenAB",
|
|
149
|
+
):
|
|
150
|
+
'''
|
|
151
|
+
:stability: experimental
|
|
152
|
+
'''
|
|
153
|
+
|
|
154
|
+
def __init__(
|
|
155
|
+
self,
|
|
156
|
+
scope: "_constructs_77d1e7e8.Construct",
|
|
157
|
+
id: builtins.str,
|
|
158
|
+
*,
|
|
159
|
+
config_path: builtins.str,
|
|
160
|
+
assign_public_ip: typing.Optional[builtins.bool] = None,
|
|
161
|
+
cpu: typing.Optional[jsii.Number] = None,
|
|
162
|
+
data_bucket: typing.Optional["_aws_cdk_aws_s3_ceddda9d.IBucket"] = None,
|
|
163
|
+
data_local_path: typing.Optional[builtins.str] = None,
|
|
164
|
+
data_s3_prefix: typing.Optional[builtins.str] = None,
|
|
165
|
+
enable_fargate_spot: typing.Optional[builtins.bool] = None,
|
|
166
|
+
image: typing.Optional["_aws_cdk_aws_ecs_ceddda9d.ContainerImage"] = None,
|
|
167
|
+
log_group: typing.Optional["_aws_cdk_aws_logs_ceddda9d.ILogGroup"] = None,
|
|
168
|
+
memory_limit_mib: typing.Optional[jsii.Number] = None,
|
|
169
|
+
vpc: typing.Optional["_aws_cdk_aws_ec2_ceddda9d.IVpc"] = None,
|
|
170
|
+
vpc_cidr: typing.Optional[builtins.str] = None,
|
|
171
|
+
) -> None:
|
|
172
|
+
'''
|
|
173
|
+
:param scope: -
|
|
174
|
+
:param id: -
|
|
175
|
+
:param config_path:
|
|
176
|
+
:param assign_public_ip:
|
|
177
|
+
:param cpu:
|
|
178
|
+
:param data_bucket:
|
|
179
|
+
:param data_local_path:
|
|
180
|
+
:param data_s3_prefix:
|
|
181
|
+
:param enable_fargate_spot:
|
|
182
|
+
:param image:
|
|
183
|
+
:param log_group:
|
|
184
|
+
:param memory_limit_mib:
|
|
185
|
+
:param vpc:
|
|
186
|
+
:param vpc_cidr:
|
|
187
|
+
|
|
188
|
+
:stability: experimental
|
|
189
|
+
'''
|
|
190
|
+
if __debug__:
|
|
191
|
+
type_hints = typing.get_type_hints(_typecheckingstub__d23a6ad055129bd01a8355aadfbeea9f3674209f7ac54c29dd5cc0863dc50950)
|
|
192
|
+
check_type(argname="argument scope", value=scope, expected_type=type_hints["scope"])
|
|
193
|
+
check_type(argname="argument id", value=id, expected_type=type_hints["id"])
|
|
194
|
+
props = OpenABProps(
|
|
195
|
+
config_path=config_path,
|
|
196
|
+
assign_public_ip=assign_public_ip,
|
|
197
|
+
cpu=cpu,
|
|
198
|
+
data_bucket=data_bucket,
|
|
199
|
+
data_local_path=data_local_path,
|
|
200
|
+
data_s3_prefix=data_s3_prefix,
|
|
201
|
+
enable_fargate_spot=enable_fargate_spot,
|
|
202
|
+
image=image,
|
|
203
|
+
log_group=log_group,
|
|
204
|
+
memory_limit_mib=memory_limit_mib,
|
|
205
|
+
vpc=vpc,
|
|
206
|
+
vpc_cidr=vpc_cidr,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
jsii.create(self.__class__, self, [scope, id, props])
|
|
210
|
+
|
|
211
|
+
@builtins.property
|
|
212
|
+
@jsii.member(jsii_name="cluster")
|
|
213
|
+
def cluster(self) -> "_aws_cdk_aws_ecs_ceddda9d.Cluster":
|
|
214
|
+
'''
|
|
215
|
+
:stability: experimental
|
|
216
|
+
'''
|
|
217
|
+
return typing.cast("_aws_cdk_aws_ecs_ceddda9d.Cluster", jsii.get(self, "cluster"))
|
|
218
|
+
|
|
219
|
+
@builtins.property
|
|
220
|
+
@jsii.member(jsii_name="dataBucket")
|
|
221
|
+
def data_bucket(self) -> "_aws_cdk_aws_s3_ceddda9d.IBucket":
|
|
222
|
+
'''
|
|
223
|
+
:stability: experimental
|
|
224
|
+
'''
|
|
225
|
+
return typing.cast("_aws_cdk_aws_s3_ceddda9d.IBucket", jsii.get(self, "dataBucket"))
|
|
226
|
+
|
|
227
|
+
@builtins.property
|
|
228
|
+
@jsii.member(jsii_name="logGroup")
|
|
229
|
+
def log_group(self) -> "_aws_cdk_aws_logs_ceddda9d.ILogGroup":
|
|
230
|
+
'''
|
|
231
|
+
:stability: experimental
|
|
232
|
+
'''
|
|
233
|
+
return typing.cast("_aws_cdk_aws_logs_ceddda9d.ILogGroup", jsii.get(self, "logGroup"))
|
|
234
|
+
|
|
235
|
+
@builtins.property
|
|
236
|
+
@jsii.member(jsii_name="service")
|
|
237
|
+
def service(self) -> "_aws_cdk_aws_ecs_ceddda9d.FargateService":
|
|
238
|
+
'''
|
|
239
|
+
:stability: experimental
|
|
240
|
+
'''
|
|
241
|
+
return typing.cast("_aws_cdk_aws_ecs_ceddda9d.FargateService", jsii.get(self, "service"))
|
|
242
|
+
|
|
243
|
+
@builtins.property
|
|
244
|
+
@jsii.member(jsii_name="vpc")
|
|
245
|
+
def vpc(self) -> "_aws_cdk_aws_ec2_ceddda9d.IVpc":
|
|
246
|
+
'''
|
|
247
|
+
:stability: experimental
|
|
248
|
+
'''
|
|
249
|
+
return typing.cast("_aws_cdk_aws_ec2_ceddda9d.IVpc", jsii.get(self, "vpc"))
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
@jsii.data_type(
|
|
253
|
+
jsii_type="cdk-openab.OpenABProps",
|
|
254
|
+
jsii_struct_bases=[],
|
|
255
|
+
name_mapping={
|
|
256
|
+
"config_path": "configPath",
|
|
257
|
+
"assign_public_ip": "assignPublicIp",
|
|
258
|
+
"cpu": "cpu",
|
|
259
|
+
"data_bucket": "dataBucket",
|
|
260
|
+
"data_local_path": "dataLocalPath",
|
|
261
|
+
"data_s3_prefix": "dataS3Prefix",
|
|
262
|
+
"enable_fargate_spot": "enableFargateSpot",
|
|
263
|
+
"image": "image",
|
|
264
|
+
"log_group": "logGroup",
|
|
265
|
+
"memory_limit_mib": "memoryLimitMiB",
|
|
266
|
+
"vpc": "vpc",
|
|
267
|
+
"vpc_cidr": "vpcCidr",
|
|
268
|
+
},
|
|
269
|
+
)
|
|
270
|
+
class OpenABProps:
|
|
271
|
+
def __init__(
|
|
272
|
+
self,
|
|
273
|
+
*,
|
|
274
|
+
config_path: builtins.str,
|
|
275
|
+
assign_public_ip: typing.Optional[builtins.bool] = None,
|
|
276
|
+
cpu: typing.Optional[jsii.Number] = None,
|
|
277
|
+
data_bucket: typing.Optional["_aws_cdk_aws_s3_ceddda9d.IBucket"] = None,
|
|
278
|
+
data_local_path: typing.Optional[builtins.str] = None,
|
|
279
|
+
data_s3_prefix: typing.Optional[builtins.str] = None,
|
|
280
|
+
enable_fargate_spot: typing.Optional[builtins.bool] = None,
|
|
281
|
+
image: typing.Optional["_aws_cdk_aws_ecs_ceddda9d.ContainerImage"] = None,
|
|
282
|
+
log_group: typing.Optional["_aws_cdk_aws_logs_ceddda9d.ILogGroup"] = None,
|
|
283
|
+
memory_limit_mib: typing.Optional[jsii.Number] = None,
|
|
284
|
+
vpc: typing.Optional["_aws_cdk_aws_ec2_ceddda9d.IVpc"] = None,
|
|
285
|
+
vpc_cidr: typing.Optional[builtins.str] = None,
|
|
286
|
+
) -> None:
|
|
287
|
+
'''
|
|
288
|
+
:param config_path:
|
|
289
|
+
:param assign_public_ip:
|
|
290
|
+
:param cpu:
|
|
291
|
+
:param data_bucket:
|
|
292
|
+
:param data_local_path:
|
|
293
|
+
:param data_s3_prefix:
|
|
294
|
+
:param enable_fargate_spot:
|
|
295
|
+
:param image:
|
|
296
|
+
:param log_group:
|
|
297
|
+
:param memory_limit_mib:
|
|
298
|
+
:param vpc:
|
|
299
|
+
:param vpc_cidr:
|
|
300
|
+
|
|
301
|
+
:stability: experimental
|
|
302
|
+
'''
|
|
303
|
+
if __debug__:
|
|
304
|
+
type_hints = typing.get_type_hints(_typecheckingstub__b457779e8a3427a2270e7c538c314f226ab1f5702f473aedf395bce81d020f2b)
|
|
305
|
+
check_type(argname="argument config_path", value=config_path, expected_type=type_hints["config_path"])
|
|
306
|
+
check_type(argname="argument assign_public_ip", value=assign_public_ip, expected_type=type_hints["assign_public_ip"])
|
|
307
|
+
check_type(argname="argument cpu", value=cpu, expected_type=type_hints["cpu"])
|
|
308
|
+
check_type(argname="argument data_bucket", value=data_bucket, expected_type=type_hints["data_bucket"])
|
|
309
|
+
check_type(argname="argument data_local_path", value=data_local_path, expected_type=type_hints["data_local_path"])
|
|
310
|
+
check_type(argname="argument data_s3_prefix", value=data_s3_prefix, expected_type=type_hints["data_s3_prefix"])
|
|
311
|
+
check_type(argname="argument enable_fargate_spot", value=enable_fargate_spot, expected_type=type_hints["enable_fargate_spot"])
|
|
312
|
+
check_type(argname="argument image", value=image, expected_type=type_hints["image"])
|
|
313
|
+
check_type(argname="argument log_group", value=log_group, expected_type=type_hints["log_group"])
|
|
314
|
+
check_type(argname="argument memory_limit_mib", value=memory_limit_mib, expected_type=type_hints["memory_limit_mib"])
|
|
315
|
+
check_type(argname="argument vpc", value=vpc, expected_type=type_hints["vpc"])
|
|
316
|
+
check_type(argname="argument vpc_cidr", value=vpc_cidr, expected_type=type_hints["vpc_cidr"])
|
|
317
|
+
self._values: typing.Dict[builtins.str, typing.Any] = {
|
|
318
|
+
"config_path": config_path,
|
|
319
|
+
}
|
|
320
|
+
if assign_public_ip is not None:
|
|
321
|
+
self._values["assign_public_ip"] = assign_public_ip
|
|
322
|
+
if cpu is not None:
|
|
323
|
+
self._values["cpu"] = cpu
|
|
324
|
+
if data_bucket is not None:
|
|
325
|
+
self._values["data_bucket"] = data_bucket
|
|
326
|
+
if data_local_path is not None:
|
|
327
|
+
self._values["data_local_path"] = data_local_path
|
|
328
|
+
if data_s3_prefix is not None:
|
|
329
|
+
self._values["data_s3_prefix"] = data_s3_prefix
|
|
330
|
+
if enable_fargate_spot is not None:
|
|
331
|
+
self._values["enable_fargate_spot"] = enable_fargate_spot
|
|
332
|
+
if image is not None:
|
|
333
|
+
self._values["image"] = image
|
|
334
|
+
if log_group is not None:
|
|
335
|
+
self._values["log_group"] = log_group
|
|
336
|
+
if memory_limit_mib is not None:
|
|
337
|
+
self._values["memory_limit_mib"] = memory_limit_mib
|
|
338
|
+
if vpc is not None:
|
|
339
|
+
self._values["vpc"] = vpc
|
|
340
|
+
if vpc_cidr is not None:
|
|
341
|
+
self._values["vpc_cidr"] = vpc_cidr
|
|
342
|
+
|
|
343
|
+
@builtins.property
|
|
344
|
+
def config_path(self) -> builtins.str:
|
|
345
|
+
'''
|
|
346
|
+
:stability: experimental
|
|
347
|
+
'''
|
|
348
|
+
result = self._values.get("config_path")
|
|
349
|
+
assert result is not None, "Required property 'config_path' is missing"
|
|
350
|
+
return typing.cast(builtins.str, result)
|
|
351
|
+
|
|
352
|
+
@builtins.property
|
|
353
|
+
def assign_public_ip(self) -> typing.Optional[builtins.bool]:
|
|
354
|
+
'''
|
|
355
|
+
:stability: experimental
|
|
356
|
+
'''
|
|
357
|
+
result = self._values.get("assign_public_ip")
|
|
358
|
+
return typing.cast(typing.Optional[builtins.bool], result)
|
|
359
|
+
|
|
360
|
+
@builtins.property
|
|
361
|
+
def cpu(self) -> typing.Optional[jsii.Number]:
|
|
362
|
+
'''
|
|
363
|
+
:stability: experimental
|
|
364
|
+
'''
|
|
365
|
+
result = self._values.get("cpu")
|
|
366
|
+
return typing.cast(typing.Optional[jsii.Number], result)
|
|
367
|
+
|
|
368
|
+
@builtins.property
|
|
369
|
+
def data_bucket(self) -> typing.Optional["_aws_cdk_aws_s3_ceddda9d.IBucket"]:
|
|
370
|
+
'''
|
|
371
|
+
:stability: experimental
|
|
372
|
+
'''
|
|
373
|
+
result = self._values.get("data_bucket")
|
|
374
|
+
return typing.cast(typing.Optional["_aws_cdk_aws_s3_ceddda9d.IBucket"], result)
|
|
375
|
+
|
|
376
|
+
@builtins.property
|
|
377
|
+
def data_local_path(self) -> typing.Optional[builtins.str]:
|
|
378
|
+
'''
|
|
379
|
+
:stability: experimental
|
|
380
|
+
'''
|
|
381
|
+
result = self._values.get("data_local_path")
|
|
382
|
+
return typing.cast(typing.Optional[builtins.str], result)
|
|
383
|
+
|
|
384
|
+
@builtins.property
|
|
385
|
+
def data_s3_prefix(self) -> typing.Optional[builtins.str]:
|
|
386
|
+
'''
|
|
387
|
+
:stability: experimental
|
|
388
|
+
'''
|
|
389
|
+
result = self._values.get("data_s3_prefix")
|
|
390
|
+
return typing.cast(typing.Optional[builtins.str], result)
|
|
391
|
+
|
|
392
|
+
@builtins.property
|
|
393
|
+
def enable_fargate_spot(self) -> typing.Optional[builtins.bool]:
|
|
394
|
+
'''
|
|
395
|
+
:stability: experimental
|
|
396
|
+
'''
|
|
397
|
+
result = self._values.get("enable_fargate_spot")
|
|
398
|
+
return typing.cast(typing.Optional[builtins.bool], result)
|
|
399
|
+
|
|
400
|
+
@builtins.property
|
|
401
|
+
def image(self) -> typing.Optional["_aws_cdk_aws_ecs_ceddda9d.ContainerImage"]:
|
|
402
|
+
'''
|
|
403
|
+
:stability: experimental
|
|
404
|
+
'''
|
|
405
|
+
result = self._values.get("image")
|
|
406
|
+
return typing.cast(typing.Optional["_aws_cdk_aws_ecs_ceddda9d.ContainerImage"], result)
|
|
407
|
+
|
|
408
|
+
@builtins.property
|
|
409
|
+
def log_group(self) -> typing.Optional["_aws_cdk_aws_logs_ceddda9d.ILogGroup"]:
|
|
410
|
+
'''
|
|
411
|
+
:stability: experimental
|
|
412
|
+
'''
|
|
413
|
+
result = self._values.get("log_group")
|
|
414
|
+
return typing.cast(typing.Optional["_aws_cdk_aws_logs_ceddda9d.ILogGroup"], result)
|
|
415
|
+
|
|
416
|
+
@builtins.property
|
|
417
|
+
def memory_limit_mib(self) -> typing.Optional[jsii.Number]:
|
|
418
|
+
'''
|
|
419
|
+
:stability: experimental
|
|
420
|
+
'''
|
|
421
|
+
result = self._values.get("memory_limit_mib")
|
|
422
|
+
return typing.cast(typing.Optional[jsii.Number], result)
|
|
423
|
+
|
|
424
|
+
@builtins.property
|
|
425
|
+
def vpc(self) -> typing.Optional["_aws_cdk_aws_ec2_ceddda9d.IVpc"]:
|
|
426
|
+
'''
|
|
427
|
+
:stability: experimental
|
|
428
|
+
'''
|
|
429
|
+
result = self._values.get("vpc")
|
|
430
|
+
return typing.cast(typing.Optional["_aws_cdk_aws_ec2_ceddda9d.IVpc"], result)
|
|
431
|
+
|
|
432
|
+
@builtins.property
|
|
433
|
+
def vpc_cidr(self) -> typing.Optional[builtins.str]:
|
|
434
|
+
'''
|
|
435
|
+
:stability: experimental
|
|
436
|
+
'''
|
|
437
|
+
result = self._values.get("vpc_cidr")
|
|
438
|
+
return typing.cast(typing.Optional[builtins.str], result)
|
|
439
|
+
|
|
440
|
+
def __eq__(self, rhs: typing.Any) -> builtins.bool:
|
|
441
|
+
return isinstance(rhs, self.__class__) and rhs._values == self._values
|
|
442
|
+
|
|
443
|
+
def __ne__(self, rhs: typing.Any) -> builtins.bool:
|
|
444
|
+
return not (rhs == self)
|
|
445
|
+
|
|
446
|
+
def __repr__(self) -> str:
|
|
447
|
+
return "OpenABProps(%s)" % ", ".join(
|
|
448
|
+
k + "=" + repr(v) for k, v in self._values.items()
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
__all__ = [
|
|
453
|
+
"OpenAB",
|
|
454
|
+
"OpenABProps",
|
|
455
|
+
]
|
|
456
|
+
|
|
457
|
+
publication.publish()
|
|
458
|
+
|
|
459
|
+
def _typecheckingstub__d23a6ad055129bd01a8355aadfbeea9f3674209f7ac54c29dd5cc0863dc50950(
|
|
460
|
+
scope: _constructs_77d1e7e8.Construct,
|
|
461
|
+
id: builtins.str,
|
|
462
|
+
*,
|
|
463
|
+
config_path: builtins.str,
|
|
464
|
+
assign_public_ip: typing.Optional[builtins.bool] = None,
|
|
465
|
+
cpu: typing.Optional[jsii.Number] = None,
|
|
466
|
+
data_bucket: typing.Optional[_aws_cdk_aws_s3_ceddda9d.IBucket] = None,
|
|
467
|
+
data_local_path: typing.Optional[builtins.str] = None,
|
|
468
|
+
data_s3_prefix: typing.Optional[builtins.str] = None,
|
|
469
|
+
enable_fargate_spot: typing.Optional[builtins.bool] = None,
|
|
470
|
+
image: typing.Optional[_aws_cdk_aws_ecs_ceddda9d.ContainerImage] = None,
|
|
471
|
+
log_group: typing.Optional[_aws_cdk_aws_logs_ceddda9d.ILogGroup] = None,
|
|
472
|
+
memory_limit_mib: typing.Optional[jsii.Number] = None,
|
|
473
|
+
vpc: typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc] = None,
|
|
474
|
+
vpc_cidr: typing.Optional[builtins.str] = None,
|
|
475
|
+
) -> None:
|
|
476
|
+
"""Type checking stubs"""
|
|
477
|
+
pass
|
|
478
|
+
|
|
479
|
+
def _typecheckingstub__b457779e8a3427a2270e7c538c314f226ab1f5702f473aedf395bce81d020f2b(
|
|
480
|
+
*,
|
|
481
|
+
config_path: builtins.str,
|
|
482
|
+
assign_public_ip: typing.Optional[builtins.bool] = None,
|
|
483
|
+
cpu: typing.Optional[jsii.Number] = None,
|
|
484
|
+
data_bucket: typing.Optional[_aws_cdk_aws_s3_ceddda9d.IBucket] = None,
|
|
485
|
+
data_local_path: typing.Optional[builtins.str] = None,
|
|
486
|
+
data_s3_prefix: typing.Optional[builtins.str] = None,
|
|
487
|
+
enable_fargate_spot: typing.Optional[builtins.bool] = None,
|
|
488
|
+
image: typing.Optional[_aws_cdk_aws_ecs_ceddda9d.ContainerImage] = None,
|
|
489
|
+
log_group: typing.Optional[_aws_cdk_aws_logs_ceddda9d.ILogGroup] = None,
|
|
490
|
+
memory_limit_mib: typing.Optional[jsii.Number] = None,
|
|
491
|
+
vpc: typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc] = None,
|
|
492
|
+
vpc_cidr: typing.Optional[builtins.str] = None,
|
|
493
|
+
) -> None:
|
|
494
|
+
"""Type checking stubs"""
|
|
495
|
+
pass
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from pkgutil import extend_path
|
|
2
|
+
__path__ = extend_path(__path__, __name__)
|
|
3
|
+
|
|
4
|
+
import abc
|
|
5
|
+
import builtins
|
|
6
|
+
import datetime
|
|
7
|
+
import enum
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
import jsii
|
|
11
|
+
import publication
|
|
12
|
+
import typing_extensions
|
|
13
|
+
|
|
14
|
+
import typeguard
|
|
15
|
+
from importlib.metadata import version as _metadata_package_version
|
|
16
|
+
TYPEGUARD_MAJOR_VERSION = int(_metadata_package_version('typeguard').split('.')[0])
|
|
17
|
+
|
|
18
|
+
def check_type(argname: str, value: object, expected_type: typing.Any) -> typing.Any:
|
|
19
|
+
if TYPEGUARD_MAJOR_VERSION <= 2:
|
|
20
|
+
return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore
|
|
21
|
+
else:
|
|
22
|
+
if isinstance(value, jsii._reference_map.InterfaceDynamicProxy): # pyright: ignore [reportAttributeAccessIssue]
|
|
23
|
+
pass
|
|
24
|
+
else:
|
|
25
|
+
if TYPEGUARD_MAJOR_VERSION == 3:
|
|
26
|
+
typeguard.config.collection_check_strategy = typeguard.CollectionCheckStrategy.ALL_ITEMS # type:ignore
|
|
27
|
+
typeguard.check_type(value=value, expected_type=expected_type) # type:ignore
|
|
28
|
+
else:
|
|
29
|
+
typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore
|
|
30
|
+
|
|
31
|
+
import aws_cdk._jsii
|
|
32
|
+
import constructs._jsii
|
|
33
|
+
|
|
34
|
+
__jsii_assembly__ = jsii.JSIIAssembly.load(
|
|
35
|
+
"cdk-openab", "0.0.4", __name__[0:-6], "cdk-openab@0.0.4.jsii.tgz"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"__jsii_assembly__",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
publication.publish()
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cdk-openab
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: AWS CDK constructs library for OpenAB
|
|
5
|
+
Home-page: https://github.com/neilkuan/cdk-openab.git
|
|
6
|
+
Author: Neil Kuan<guan840912@gmail.com>
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Project-URL: Source, https://github.com/neilkuan/cdk-openab.git
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: JavaScript
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Classifier: Development Status :: 4 - Beta
|
|
18
|
+
Classifier: License :: OSI Approved
|
|
19
|
+
Requires-Python: ~=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: aws-cdk-lib<3.0.0,>=2.170.0
|
|
23
|
+
Requires-Dist: constructs<11.0.0,>=10.5.1
|
|
24
|
+
Requires-Dist: jsii<2.0.0,>=1.127.0
|
|
25
|
+
Requires-Dist: publication>=0.0.3
|
|
26
|
+
Requires-Dist: typeguard==2.13.3
|
|
27
|
+
|
|
28
|
+
# cdk-openab
|
|
29
|
+
|
|
30
|
+
AWS CDK constructs library for deploying [OpenAB aka Agent Broker](https://github.com/openabdev/openab) on AWS ECS Fargate.
|
|
31
|
+
|
|
32
|
+
##### Architecture
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
┌───────────────────────────────────────────────────────────────────┐
|
|
36
|
+
│ AWS Cloud │
|
|
37
|
+
│ │
|
|
38
|
+
│ ┌─────────────────────────────────────────────────────────────┐ │
|
|
39
|
+
│ │ VPC (default: 10.168.0.0/16) │ │
|
|
40
|
+
│ │ │ │
|
|
41
|
+
│ │ ┌───────────────────────────────────────────────────────┐ │ │
|
|
42
|
+
│ │ │ Public Subnet │ │ │
|
|
43
|
+
│ │ │ │ │ │
|
|
44
|
+
│ │ │ ┌─────────────────────────────────────────────────┐ │ │ │
|
|
45
|
+
│ │ │ │ ECS Cluster │ │ │ │
|
|
46
|
+
│ │ │ │ │ │ │ │
|
|
47
|
+
│ │ │ │ ┌───────────────────────────────────────────┐ │ │ │ │
|
|
48
|
+
│ │ │ │ │ Fargate Service (FARGATE_SPOT | FARGATE) │ │ │ │ │
|
|
49
|
+
│ │ │ │ │ │ │ │ │ │
|
|
50
|
+
│ │ │ │ │ ┌───────────┐ ┌──────────────────────┐ │ │ │ │ │
|
|
51
|
+
│ │ │ │ │ │ data-init │─▶│ app container │ │ │ │ │ │
|
|
52
|
+
│ │ │ │ │ │ (S3 pull) │ │ (port 80) │ │ │ │ │ │
|
|
53
|
+
│ │ │ │ │ └───────────┘ └──────────┬───────────┘ │ │ │ │ │
|
|
54
|
+
│ │ │ │ │ │ stops │ │ │ │ │
|
|
55
|
+
│ │ │ │ │ ▼ │ │ │ │ │
|
|
56
|
+
│ │ │ │ │ ┌───────────────────────┐ │ │ │ │ │
|
|
57
|
+
│ │ │ │ │ │ data-backup (sidecar) │ │ │ │ │ │
|
|
58
|
+
│ │ │ │ │ │ S3 sync on app stop │ │ │ │ │ │
|
|
59
|
+
│ │ │ │ │ └───────────────────────┘ │ │ │ │ │
|
|
60
|
+
│ │ │ │ └───────────────────────────────────────────┘ │ │ │ │
|
|
61
|
+
│ │ │ └─────────────────────────────────────────────────┘ │ │ │
|
|
62
|
+
│ │ └───────────────────────────────────────────────────────┘ │ │
|
|
63
|
+
│ └─────────────────────────────────────────────────────────────┘ │
|
|
64
|
+
│ │
|
|
65
|
+
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
66
|
+
│ │ S3 (config │ │ S3 (data │ │
|
|
67
|
+
│ │ asset) │ │ bucket) │ │
|
|
68
|
+
│ │ config.toml │ │ /home/agent │ │
|
|
69
|
+
│ └──────────────────┘ └──────────────────┘ │
|
|
70
|
+
└───────────────────────────────────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
##### Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# npm
|
|
77
|
+
npm install cdk-openab
|
|
78
|
+
|
|
79
|
+
# pip
|
|
80
|
+
pip install cdk-openab
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
##### Usage
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import { OpenAB } from 'cdk-openab';
|
|
87
|
+
|
|
88
|
+
new OpenAB(this, 'Broker', {
|
|
89
|
+
configPath: './config.toml', // required: path to your local config.toml
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// With custom settings
|
|
93
|
+
new OpenAB(this, 'Broker', {
|
|
94
|
+
cpu: 2048,
|
|
95
|
+
memoryLimitMiB: 4096,
|
|
96
|
+
dataS3Prefix: 'my-agent-data',
|
|
97
|
+
configPath: './config.toml',
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
##### Props
|
|
102
|
+
|
|
103
|
+
| Prop | Type | Default | Description |
|
|
104
|
+
|------|------|---------|-------------|
|
|
105
|
+
| `vpc` | `ec2.IVpc` | New VPC (public subnet) | 自訂 VPC |
|
|
106
|
+
| `vpcCidr` | `string` | `10.168.0.0/16` | 新建 VPC 的 CIDR |
|
|
107
|
+
| `image` | `ecs.ContainerImage` | `ghcr.io/thepagent/openab:dd7e1ca` | Container image |
|
|
108
|
+
| `memoryLimitMiB` | `number` | `4096` | Task memory (MiB) |
|
|
109
|
+
| `cpu` | `number` | `2048` | Task CPU units |
|
|
110
|
+
| `assignPublicIp` | `boolean` | `true` | 是否分配 public IP |
|
|
111
|
+
| `enableFargateSpot` | `boolean` | `true` | 啟用 FARGATE_SPOT |
|
|
112
|
+
| `dataBucket` | `s3.IBucket` | 自動建立 | 持久化資料用的 S3 bucket |
|
|
113
|
+
| `dataS3Prefix` | `string` | `agent-data` | S3 資料前綴 |
|
|
114
|
+
| `dataLocalPath` | `string` | `/home/agent` | 資料掛載路徑 |
|
|
115
|
+
| `configPath` | `string` | **必填** | 本地 config.toml 路徑,透過 S3 init container 掛載到 `/etc/openab/config.toml` |
|
|
116
|
+
|
|
117
|
+
##### Exposed Resources
|
|
118
|
+
|
|
119
|
+
`OpenAB` construct 暴露以下屬性,方便後續串接:
|
|
120
|
+
|
|
121
|
+
* `broker.vpc` — VPC
|
|
122
|
+
* `broker.cluster` — ECS Cluster
|
|
123
|
+
* `broker.service` — Fargate Service
|
|
124
|
+
* `broker.dataBucket` — 持久化資料 S3 Bucket
|
|
125
|
+
|
|
126
|
+
##### Container Flow
|
|
127
|
+
|
|
128
|
+
1. **`data-init`** (init container):從 S3 data bucket 還原 `/home/agent` 資料,並從 S3 asset 下載 `config.toml`
|
|
129
|
+
2. **`app`**:主應用容器,等待 init 完成後啟動,掛載資料目錄(read-write)和 config(read-only)
|
|
130
|
+
3. **`data-backup`** (sidecar):每 10 分鐘定期將 `/home/agent` sync 到 S3 data bucket,並在收到 SIGTERM(app 停止)時執行最後一次備份
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
src/cdk_openab/__init__.py
|
|
7
|
+
src/cdk_openab/py.typed
|
|
8
|
+
src/cdk_openab.egg-info/PKG-INFO
|
|
9
|
+
src/cdk_openab.egg-info/SOURCES.txt
|
|
10
|
+
src/cdk_openab.egg-info/dependency_links.txt
|
|
11
|
+
src/cdk_openab.egg-info/requires.txt
|
|
12
|
+
src/cdk_openab.egg-info/top_level.txt
|
|
13
|
+
src/cdk_openab/_jsii/__init__.py
|
|
14
|
+
src/cdk_openab/_jsii/cdk-openab@0.0.4.jsii.tgz
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cdk_openab
|