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.
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:
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
module"bedrock_agents"{source="sourcefuse/arc-bedrock/aws"version="0.0.1"bedrock_agent_config={create=truename="arc-bedrock-agent"foundation_model="anthropic.claude-3-5-sonnet-20241022-v2:0"instruction="You are a customer support assistant. Answer user queries."agent_collaboration="SUPERVISOR"prepare_agent=falsedescription="Supervisor agent"}agent_collaborator={name="collab-1"collaborator_name="Collaborator-One"foundation_model="anthropic.claude-3-5-sonnet-20241022-v2:0"instruction="do what the supervisor is asking you to do"collaboration_instruction="tell the other agent on what to do"alias_name="DocProcessor"description="Collaborator 1"relay_conversation_history="TO_COLLABORATOR"prepare_agent=trueidle_session_ttl_in_seconds=600action_groups=local.action_groups}tags=module.tags.tags}
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:
output"agent_arn"{value=module.bedrock_agent.agent_arndescription="Agent arn"}output"agent_id"{value=module.bedrock_agent.agent_iddescription="Agent ID"}output"collaborator_agent_id"{description="Agent ID created for collaborators."value=module.bedrock_agent.collaborator_agent_id}output"agent_role_arn"{value=module.bedrock_agent.agent_role_arndescription="Agent Role arn"}
.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
locals{collaborators=[{name="collab-2"supervisor_agent_id=module.bedrock_agent.agent_idcollaborator_name="Collaborator-Two"foundation_model="anthropic.claude-3-5-sonnet-20241022-v2:0"instruction="do what the supervisor is asking you to do"collaboration_instruction="tell the other agent on what to do"alias_name="TechSupport"description="Collaborator 2"relay_conversation_history="TO_COLLABORATOR"prepare_agent=trueidle_session_ttl_in_seconds=600action_groups=local.action_groups},{name="collab-3"supervisor_agent_id=module.bedrock_agent.agent_idcollaborator_name="Collaborator-Three"foundation_model="anthropic.claude-3-5-sonnet-20241022-v2:0"instruction="do what the supervisor is asking you to do"collaboration_instruction="tell the other agent on what to do"alias_name="TechSupport"description="Collaborator 3"relay_conversation_history="TO_COLLABORATOR"prepare_agent=trueidle_session_ttl_in_seconds=600action_groups=local.action_groups}]action_groups=[{name="singlerulegenerationagent-actiongroup"state="ENABLED"agent_version="DRAFT"skip_resource_in_use_check=trueaction_group_executor={lambda="arn:aws:lambda:us-east-1:884360309640:function:arc-debug-budgets-default"}function_schema=[{functions=[{name="extract_general_props"description="Extracts general info properties based on the user prompt."parameters=[{map_block_key="prompt"type="string"description="The user instruction/prompt to create or edit the rule."required=true},{map_block_key="rule_context"type="string"description="The existing rule to be updated, if provided."required=false}]},{name="extract_static_props"description="Extracts static properties based on the user prompt."parameters=[{map_block_key="prompt"type="string"description="The user instruction/prompt to create or edit the rule."required=true},{map_block_key="rule_context"type="string"description="The existing rule to be updated, if provided."required=false}]}]}]}]}
Configuration for the Amazon Bedrock Agent, including name, session TTL, foundation model, tags, instructions, collaboration settings, and preparation options.
By specifying this , it will bump the version and if you dont specify this in your commit message then by default it will consider patch and will bump that accordingly