A Terraform module for running AI agents on Amazon Bedrock AgentCore.
Includes a python test client to invoke the agent.
Deploy a code project with a Dockerfile to AgentCore Runtime.
name = "myagent"
enable_runtime = true
server_protocol = "HTTP" # or MCP, or A2A
dockerfile = "../"
environment_variables = {
FOO = "bar"
}name = "myagent"
enable_memory = true
memory_short_term_expiration_days = 30name = "myagent"
enable_code_interpreter = truename = "myagent"
enable_browser = truename = "myagent"
enable_gateway = true
# Optional: Use Cognito for authentication (default: true)
use_cognito_for_auth = true
# Optional: Custom JWT configuration (when use_cognito_for_auth = false)
gateway_jwt_discovery_url = "https://your-jwt-provider.com/.well-known/jwks.json"
gateway_jwt_allowed_audience = ["your-audience"]
gateway_jwt_allowed_clients = ["client-id-1", "client-id-2"] Choose a make command to run
init project initialization - install tools and register git hook
checks run all pre-commit checks
summary summary of terraform resource changes
Note that if using Amazon Q Developer CLI, the Hashicorp MCP server is pre-configured in the terraform agent.
q chat --agent terraformOnce the agent has deployed to AgentCore Runtime, you can use the included test client to invoke it.
One time setup of python virtual environment and packages:
make init && make installThen invoke the agent:
make start| Name | Version |
|---|---|
| terraform | >= 1.0 |
| aws | 6.18.0 |
| docker | ~> 3.0 |
| Name | Version |
|---|---|
| aws | 6.18.0 |
| docker | ~> 3.0 |
| random | n/a |
No modules.
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| dockerfile | Path to the Dockerfile context directory | string |
"../agent" |
no |
| enable_browser | Enable AgentCore Browser | bool |
false |
no |
| enable_code_interpreter | Enable AgentCore Code Interpreter | bool |
false |
no |
| enable_gateway | Enable AgentCore Gateway | bool |
false |
no |
| enable_memory | Enable AgentCore Memory | bool |
false |
no |
| enable_runtime | Enable AgentCore Runtime | bool |
true |
no |
| environment_variables | Environment variables for the AgentCore Runtime | map(string) |
{} |
no |
| gateway_jwt_allowed_audience | Allowed audience values for JWT token validation (required when use_cognito_for_auth is false) | list(string) |
[] |
no |
| gateway_jwt_allowed_clients | Allowed client IDs for JWT token validation (optional when use_cognito_for_auth is false) | list(string) |
[] |
no |
| gateway_jwt_discovery_url | JWT discovery URL for custom JWT authorizer (required when use_cognito_for_auth is false) | string |
null |
no |
| gateway_mcp_instructions | Instructions for the MCP protocol configuration | string |
null |
no |
| gateway_mcp_search_type | Search type for MCP | string |
"SEMANTIC" |
no |
| gateway_mcp_supported_versions | Supported MCP protocol versions | list(string) |
[ |
no |
| memory_short_term_expiration_days | Memory short term expiration in days | number |
30 |
no |
| name | Name for the AgentCore resources | string |
n/a | yes |
| server_protocol | Server protocol for AgentCore Runtime | string |
"HTTP" |
no |
| tags | Default tags to apply to all resources | map(string) |
{} |
no |
| use_cognito_for_auth | Use Cognito User Pool for gateway authentication. If false, custom JWT configuration is required. | bool |
true |
no |
| Name | Description |
|---|---|
| agentcore_runtime_arn | ARN of the AgentCore runtime |
| browser_arn | ARN of the AgentCore browser |
| browser_id | ID of the AgentCore browser |
| client_id | Client ID for gateway authentication |
| code_interpreter_arn | ARN of the AgentCore code interpreter |
| code_interpreter_id | ID of the AgentCore code interpreter |
| cognito_client_id | ID of the Cognito User Pool Client for gateway authentication |
| cognito_client_secret | Secret of the Cognito User Pool Client for gateway authentication |
| cognito_domain | Domain of the Cognito User Pool for OAuth endpoints |
| cognito_user_pool_id | ID of the Cognito User Pool for gateway authentication |
| gateway_arn | ARN of the AgentCore gateway |
| gateway_id | ID of the AgentCore gateway |
| gateway_role_arn | ARN of the Gateway execution role |
| gateway_url | URL of the AgentCore gateway |
| memory_id | ID of the AgentCore memory |
| token_url | Token URL for gateway authentication |