forked from aws/agentcore-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_runtime_basic.py
More file actions
68 lines (56 loc) · 2.01 KB
/
Copy pathsetup_runtime_basic.py
File metadata and controls
68 lines (56 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
"""Setup: Bare minimum CodeZip runtime (PUBLIC, HTTP, basic entrypoint).
Tests: baseline import, entrypoint detection, CodeZip build type, executionRoleArn.
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from common import (
ensure_role, get_control_client, wait_for_runtime,
save_resource, print_import_command, upload_code,
NAME_SUFFIX,
)
def main():
role_arn = ensure_role()
client = get_control_client()
runtime_name = f"bugbash_basic_{NAME_SUFFIX}"
bucket, s3_key = upload_code(f"bugbash-basic-{NAME_SUFFIX}")
print(f"Creating basic runtime: {runtime_name}")
resp = client.create_agent_runtime(
agentRuntimeName=runtime_name,
roleArn=role_arn,
networkConfiguration={"networkMode": "PUBLIC"},
agentRuntimeArtifact={
"codeConfiguration": {
"code": {
"s3": {
"bucket": bucket,
"prefix": s3_key,
}
},
"runtime": "PYTHON_3_12",
"entryPoint": ["main.py"],
}
},
protocolConfiguration={"serverProtocol": "HTTP"},
)
runtime_id = resp["agentRuntimeId"]
runtime_arn = resp["agentRuntimeArn"]
print(f"Runtime ID: {runtime_id}")
print(f"Runtime ARN: {runtime_arn}")
save_resource("runtime-basic", runtime_arn, runtime_id)
if not wait_for_runtime(client, runtime_id):
sys.exit(1)
print()
print("Expected fields after import:")
print(" build: CodeZip")
print(" entrypoint: main.py")
print(" runtimeVersion: PYTHON_3_12")
print(" protocol: HTTP")
print(" networkMode: PUBLIC")
print(f" executionRoleArn: {role_arn}")
print(" lifecycleConfiguration: defaults (idleRuntimeSessionTimeout=900, maxLifetime=28800)")
print(" (no envVars, tags, or requestHeaderAllowlist)")
print_import_command("runtime", runtime_arn)
if __name__ == "__main__":
main()