Skip to content

Commit 57cd28f

Browse files
committed
feat(tf): Create agent runtime from Terraform
Extend the Terraform IaC to include provisioning the Agent to Bedrock AgentCore Runtime.
1 parent 17578d0 commit 57cd28f

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

infra/main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,26 @@ module "secrets" {
8181
depends_on = [module.cognito]
8282
}
8383

84+
# Deploy the endpoint
85+
resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
86+
agent_runtime_name = "langgraph_cx_agent"
87+
description = "Example customer service agent for Agentic AI Foundation"
88+
role_arn = module.bedrock_role.role_arn
89+
authorizer_configuration {
90+
custom_jwt_authorizer {
91+
discovery_url = module.cognito.user_pool_discovery_url
92+
allowed_clients = [module.cognito.user_pool_client_id]
93+
}
94+
}
95+
agent_runtime_artifact {
96+
container_configuration {
97+
container_uri = module.container_image.ecr_image_uri
98+
}
99+
}
100+
network_configuration {
101+
network_mode = "PUBLIC"
102+
}
103+
protocol_configuration {
104+
server_protocol = "HTTP"
105+
}
106+
}

infra/modules/cognito/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
data "aws_region" "current" {}
2+
13
resource "aws_cognito_user_pool" "user_pool" {
24
name = var.user_pool_name
35

infra/modules/cognito/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ output "user_pool_arn" {
88
value = aws_cognito_user_pool.user_pool.arn
99
}
1010

11+
output "user_pool_discovery_url" {
12+
value = "https://cognito-idp.${data.aws_region.current.name}.amazonaws.com/${aws_cognito_user_pool.user_pool.id}/.well-known/openid-configuration"
13+
}
14+
1115
output "user_pool_client_id" {
1216
description = "ID of the Cognito User Pool Client"
1317
value = aws_cognito_user_pool_client.user_pool_client.id

infra/terraform.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ terraform {
77

88
required_providers {
99
aws = {
10-
source = "hashicorp/aws"
10+
source = "hashicorp/aws"
1111
# v6.18 added support for Bedrock AgentCore Memory
1212
version = ">= 6.18"
1313
}

0 commit comments

Comments
 (0)