LifecycleHook Class Added in v2.277.0
A hook the AgentCore service calls on the agent's container.
| Source | aws-bedrockagentcore/lib/runtime/types.ts |
|---|---|
| Type last changed |
Example
ts
const repository = new ecr.Repository(this, 'TestRepository', {
repositoryName: 'test-agent-runtime',
});
const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, 'v1.0.0');
new agentcore.Runtime(this, 'test-runtime', {
runtimeName: 'test_runtime',
agentRuntimeArtifact: agentRuntimeArtifact,
platformVersion: agentcore.PlatformVersion.V2,
buildHooks: {
warmup: agentcore.LifecycleHook.httpPost({ path: '/warmup', port: 8080 }),
},
});
python
repository = ecr.Repository(self, "TestRepository",
repository_name="test-agent-runtime"
)
agent_runtime_artifact = agentcore.AgentRuntimeArtifact.from_ecr_repository(repository, "v1.0.0")
agentcore.Runtime(self, "test-runtime",
runtime_name="test_runtime",
agent_runtime_artifact=agent_runtime_artifact,
platform_version=agentcore.PlatformVersion.V2,
build_hooks=agentcore.BuildLifecycleHooks(
warmup=agentcore.LifecycleHook.http_post(path="/warmup", port=8080)
)
)
java
Repository repository = Repository.Builder.create(this, "TestRepository")
.repositoryName("test-agent-runtime")
.build();
AgentRuntimeArtifact agentRuntimeArtifact = AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
Runtime.Builder.create(this, "test-runtime")
.runtimeName("test_runtime")
.agentRuntimeArtifact(agentRuntimeArtifact)
.platformVersion(PlatformVersion.V2)
.buildHooks(BuildLifecycleHooks.builder()
.warmup(LifecycleHook.httpPost(HttpPostLifecycleHookOptions.builder().path("/warmup").port(8080).build()))
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var repository = new Repository(this, "TestRepository", new RepositoryProps {
RepositoryName = "test-agent-runtime"
});
var agentRuntimeArtifact = AgentRuntimeArtifact.FromEcrRepository(repository, "v1.0.0");
new Runtime(this, "test-runtime", new RuntimeProps {
RuntimeName = "test_runtime",
AgentRuntimeArtifact = agentRuntimeArtifact,
PlatformVersion = PlatformVersion.V2,
BuildHooks = new BuildLifecycleHooks {
Warmup = LifecycleHook.HttpPost(new HttpPostLifecycleHookOptions { Path = "/warmup", Port = 8080 })
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
repository := ecr.NewRepository(this, jsii.String("TestRepository"), &RepositoryProps{
RepositoryName: jsii.String("test-agent-runtime"),
})
agentRuntimeArtifact := agentcore.AgentRuntimeArtifact_FromEcrRepository(repository, jsii.String("v1.0.0"))
agentcore.NewRuntime(this, jsii.String("test-runtime"), &RuntimeProps{
RuntimeName: jsii.String("test_runtime"),
AgentRuntimeArtifact: agentRuntimeArtifact,
PlatformVersion: agentcore.PlatformVersion_V2(),
BuildHooks: &BuildLifecycleHooks{
Warmup: agentcore.LifecycleHook_HttpPost(&HttpPostLifecycleHookOptions{
Path: jsii.String("/warmup"),
Port: jsii.Number(8080),
}),
},
})
Methods
httpPost(options: HttpPostLifecycleHookOptions): LifecycleHook // chainable@staticmethod def http_post(options: HttpPostLifecycleHookOptions) -> LifecycleHookpublic static LifecycleHook httpPost(HttpPostLifecycleHookOptions options)public static LifecycleHook HttpPost(HttpPostLifecycleHookOptions options)func HttpPost(Options HttpPostLifecycleHookOptions) LifecycleHook static #Send an HTTP POST to the agent's container.
Any 2xx response ends the hook; any other response fails it.