
terraform-aws-arc-bedrock¶
Module:
sourcefuse/arc-bedrock/awsRegistry: https://registry.terraform.io/modules/sourcefuse/arc-bedrock/aws
Category: AI / Machine Learning
Source: https://github.com/sourcefuse/terraform-aws-arc-bedrock
Overview¶
This Terraform module provides an automated way to deploy and manage AWS Bedrock Agents, Collaborators, Action Groups, and associated IAM Roles. The module is designed to be flexible, reusable, and configurable to suit various use cases.
Features¶
- Bedrock Agent Creation: Deploys an AWS Bedrock agent with configurable settings.
- Collaborator Management: Supports multiple collaborators with required IAM permissions.
- Action Groups: Enables defining multiple action groups for executing Lambda-based functions.
- IAM Role Management: Automatically provisions IAM roles with necessary policies for Bedrock resources.
What It Does¶
- Bedrock Agent with configurable foundation model and instructions
- Multi-agent collaboration (supervisor + collaborator pattern)
- Action groups with Lambda function schemas
- Knowledge base with S3 data sources and OpenSearch Serverless vector store
- IAM roles auto-provisioned for agents
For more information about this repository and its usage, please see Terraform AWS BEDROCK Usage Guide.
Quickstart¶
Module Components¶
1. Bedrock Agent¶
- Configurable name, foundation model, and instruction set.
- Supports enabling/disabling agent collaboration.
- Customizable session timeout settings.
2. Collaborators¶
- Allows defining multiple collaborators with their own permissions.
- IAM roles and policies created dynamically.
3. Action Groups¶
- Enables defining multiple action groups.
- Supports dynamic function schemas for action execution.
- Integrates AWS Lambda functions.
4. IAM Roles & Policies¶
- Automatically provisions IAM roles for agents and collaborators.
- Grants necessary permissions for Bedrock services.
Usage¶
Prerequisites¶
Before using this module, ensure you have the following:
- AWS credentials configured.
- Terraform installed.
- A working knowledge of Terraform.
Getting Started¶
- Define the Module
Initially, it's essential to define a Terraform module, which is organized as a distinct directory encompassing Terraform configuration files. Within this module directory, input variables and output values must be defined in the variables.tf and outputs.tf files, respectively. The following illustrates an example directory structure:
- Define Input Variables
Inside the variables.tf or in *.tfvars file, you should define values for the variables that the module requires.
- Use the Module in Your Main Configuration
In your main Terraform configuration file (e.g., main.tf), you can use the module. Specify the source of the module, and version, For
Example
Required Inputs¶
| Name | Type | Description |
|---|---|---|
namespace |
string |
Namespace prefix |
environment |
string |
Deployment environment |
| ## Key Outputs |
| Name | Description |
|---|---|
agent_id |
Bedrock Agent ID |
agent_arn |
Bedrock Agent ARN |
agent_role_arn |
IAM role ARN for the agent |
| ## Full Variable & Output Reference |
The complete inputs/outputs reference is auto-generated below.
- Output Values
Inside the outputs.tf file of the module, you can define output values that can be referenced in the main configuration. For example:
- .tfvars
Inside the .tfvars file of the module, you can provide desired values that can be referenced in the main configuration. For example:
Edit the locals.tf file and provide desired values.
collaborators - List of Collaborator Agents
action_groups - Action groups for Collaborator Agents
First Time Usage¶
uncomment the backend block in main.tf
terraform init should be fine
Create a dev workspace
Plan Terraform
Apply Terraform
Production Setup¶
Create a prod workspace
Plan Terraform
Apply Terraform
Cleanup¶
Destroy Terraform
Module Usage¶
To see a full example, check out the main.tf file in the example folder.
Requirements¶
| Name | Version |
|---|---|
| terraform | >= 1.3, < 2.0.0 |
| aws | >= 5.0, < 6.0 |
| opensearch | 2.3.1 |
| time | 0.13.0 |
Providers¶
| Name | Version |
|---|---|
| aws | 5.89.0 |
Modules¶
| Name | Source | Version |
|---|---|---|
| collaborators | ./modules/collaborator | n/a |
| knowledge_base | ./modules/knowledge-base | n/a |
Resources¶
| Name | Type |
|---|---|
| aws_bedrockagent_agent.collaborator | resource |
| aws_bedrockagent_agent.this | resource |
| aws_bedrockagent_agent_alias.this | resource |
| aws_iam_role.collaborator | resource |
| aws_iam_role.this | resource |
| aws_iam_role_policy.collaborator | resource |
| aws_iam_role_policy.this | resource |
| aws_caller_identity.current | data source |
| aws_iam_policy_document.agent_permissions | data source |
| aws_iam_policy_document.agent_trust | data source |
| aws_iam_policy_document.collaborator_agent_permissions | data source |
| aws_partition.current | data source |
| aws_region.current | data source |
Inputs¶
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| agent_collaborator | Configuration object for a collaborator, including name, instructions, and settings. | object({ |
null |
no |
| bedrock_agent_config | Configuration for the Amazon Bedrock Agent, including name, session TTL, foundation model, tags, instructions, collaboration settings, and preparation options. | object({ |
{ |
no |
| environment | Name of the environment, i.e. dev, stage, prod | string |
n/a | yes |
| knowledge_base_config | Configuration for AWS Bedrock Agent Knowledge Base, including vector storage, embedding model, and OpenSearch integration. | object({ |
{ |
no |
| namespace | Namespace of the project, i.e. arc | string |
n/a | yes |
| tags | Tags for Bedrock resources | map(string) |
{} |
no |
Outputs¶
| Name | Description |
|---|---|
| agent_arn | Agent arn |
| agent_id | Agent ID |
| agent_role_arn | Agent Role arn |
| alias_arn | ARN of the alias |
| alias_id | Unique identifier of the alias. |
| collaborator_agent_id | Agent ID created for collaborators. |
| collaborator_role_arns | ARNs of the IAM roles created for collaborators. |
| opensearch_collection_endpoint | Opensearch Collection endpoint |
Development¶
Prerequisites¶
Configurations¶
- Configure pre-commit hooks
Git commits¶
while Contributing or doing git commit please specify the breaking change in your commit message whether its major,minor or patch
For Example
Tests¶
- Tests are available in
testdirectory - Configure the dependencies
- Now execute the test
Contributing¶
See CONTRIBUTING.md for commit conventions and development setup.
Authors¶
This project is authored by: - SourceFuse ARC Team