### Create Knowledge Base with S3 Vectors Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Sets up a Knowledge Base using S3 Vectors, enabling vector storage directly on Amazon S3. This configuration includes advanced embedding model parameters and agent setup. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" # Create S3 Vectors knowledge base create_s3_vectors_config = true s3_vectors_index_arn = "arn:aws:s3vectors:us-east-1:123456789012:index/my-index" # Advanced embedding model configuration embedding_model_dimensions = 1024 embedding_data_type = "FLOAT32" # Agent configuration foundation_model = "anthropic.claude-3-sonnet-20240229-v1:0" instruction = "You are an assistant that can search through vector data stored in S3." } ``` -------------------------------- ### Run Terratest Integration Tests Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/CONTRIBUTING.md Executes Terratest integration tests for Terraform modules. This involves initializing the Go module, tidying dependencies, installing the Terratest library, and running the tests. ```shell # from the root of the repository cd test go mod init github.com/aws-ia/terraform-project-ephemeral go mod tidy go install github.com/gruntwork-io/terratest/modules/terraform go test -timeout 45m ``` -------------------------------- ### Terraform Initialization and Validation Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/CONTRIBUTING.md Performs initial setup and validation for Terraform configurations. This includes initializing the Terraform working directory and validating the syntax of the configuration files. ```shell terraform init terraform validate ``` -------------------------------- ### Use Existing Knowledge Base with Terraform Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/.header.md This example shows how to configure the AWS Bedrock Terraform module to attach an existing Amazon Bedrock Knowledge Base to a Bedrock Agent. It requires specifying the existing knowledge base ID and its current state. ```hcl module "bedrock_agent" { source = "aws-ia/bedrock/aws" version = "0.0.31" existing_kb = "kb-abc123" kb_state = "ENABLED" } ``` -------------------------------- ### Run Checkov Compliance Checks Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/CONTRIBUTING.md Utilizes Checkov to scan infrastructure code for security misconfigurations and compliance issues. The scan is guided by a specific configuration file. ```shell checkov --config-file ${PROJECT_PATH}/.config/.checkov.yml ``` -------------------------------- ### Create Prompt Management with Variants using Terraform Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Deploys a prompt management system with multiple variants for A/B testing and configuration management. This configuration specifies the source, version, and various parameters for creating a prompt, including its name, default variant, and a list of variants with their respective configurations for template type, model ID, inference, and template details. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_agent = false create_prompt = true create_prompt_version = true prompt_name = "playlist-generator" default_variant = "variant-example" prompt_version_description = "Initial prompt version for playlist generation" variants_list = [ { name = "variant-example" template_type = "TEXT" model_id = "amazon.titan-text-express-v1" inference_configuration = { text = { temperature = 1 top_p = 0.99 max_tokens = 300 stop_sequences = ["User:"] top_k = 250 } } template_configuration = { text = { input_variables = [ { name = "genre" }, { name = "number" } ] text = "Make me a {{genre}} playlist consisting of the following number of songs: {{number}}." } } } ] } ``` -------------------------------- ### Create Agent with OpenSearch Serverless Knowledge Base Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Deploys a Bedrock Agent with a Knowledge Base using OpenSearch Serverless for Retrieval Augmented Generation (RAG). The module automatically provisions the necessary OpenSearch collection and index. ```hcl provider "opensearch" { url = module.bedrock.default_collection.collection_endpoint healthcheck = false } module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_default_kb = true create_s3_data_source = true foundation_model = "anthropic.claude-v2" instruction = "You are an automotive assistant who can provide detailed information about cars to a customer." # Knowledge Base configuration kb_name = "automotive-knowledge-base" kb_description = "Knowledge base containing automotive documentation" } ``` -------------------------------- ### Create Prompt with Version in AWS Bedrock using Terraform Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/.header.md Creates a prompt with a specific version in AWS Bedrock using Terraform. It includes prompt name, default variant, and enables prompt creation and versioning with a description. This allows for managing and deploying specific prompt configurations. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_agent = false # Prompt Management prompt_name = "prompt" default_variant = "variant-example" create_prompt = true create_prompt_version = true prompt_version_description = "Example prompt version" variants_list = [ { name = "variant-example" template_type = "TEXT" model_id = "amazon.titan-text-express-v1" inference_configuration = { text = { temperature = 1 top_p = 0.9900000095367432 max_tokens = 300 stop_sequences = ["User:"] top_k = 250 } } template_configuration = { text = { input_variables = [ { name = "topic" } ] text = "Make me a {{genre}} playlist consisting of the following number of songs: {{number}}." } } } ] } ``` -------------------------------- ### Create a Basic Bedrock Agent Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Deploys a simple Bedrock Agent with a specified foundation model and instructions. This agent is capable of executing multistep tasks and interacting with users via natural language. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" foundation_model = "anthropic.claude-v2" instruction = "You are an automotive assistant who can provide detailed information about cars to a customer." } ``` -------------------------------- ### Terraform String Input for Data Source Description Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Provides a description for the data source. This is a string input, defaulting to null. ```terraform variable "data_source_description" { description = "Description of the data source." type = string default = null } ``` -------------------------------- ### Terraform String Input for Database Name Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Provides the name of the database. This is a string input, defaulting to null. ```terraform variable "database_name" { description = "Name of the database." type = string default = null } ``` -------------------------------- ### Configure Application Inference Profile Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Sets up input variables for an application inference profile. This includes specifying the profile name, source ARNs for model configuration, and optional tags. ```terraform variable "app_inference_profile_name" { description = "The name of your application inference profile." type = string default = "AppInferenceProfile" } variable "app_inference_profile_model_source" { description = "Source arns for a custom inference profile to copy its regional load balancing config from. This can either be a foundation model or predefined inference profile ARN." type = string default = null } variable "app_inference_profile_tags" { description = "A map of tag keys and values for application inference profile." type = list(map(string)) default = null } ``` -------------------------------- ### Create Agent with Application Inference Profile using Terraform Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Deploys an agent that uses an application inference profile for cost tracking. This configuration first sets up an application inference profile and then proceeds to create an agent, linking it to the inference profile for monitoring usage and costs. It specifies the foundation model and a basic instruction for the agent. ```hcl data "aws_caller_identity" "current" {} data "aws_region" "current" {} module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" # Create inference profile create_app_inference_profile = true app_inference_profile_model_source = "arn:aws:bedrock:${data.aws_region.current.name}::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0" # Use inference profile with agent use_app_inference_profile = true foundation_model = "anthropic.claude-3-sonnet-20240229-v1:0" instruction = "You are a helpful assistant." } ``` -------------------------------- ### Configure S3 Data Source (Terraform) Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Sets up the configuration for an S3 data source. This includes the bucket name, key path, and optional inclusion/exclusion patterns for files. It also supports specifying a prefix for document metadata. ```terraform s3_data_source_bucket_name = "my-data-bucket" s3_data_source_key_path = "data/documents/" s3_data_source_inclusion_patterns = ["*.txt", "*.csv"] s3_data_source_exclusion_patterns = ["*.tmp"] s3_data_source_document_metadata_prefix = "metadata/" ``` -------------------------------- ### Kendra Document Metadata Configurations (Terraform) Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines a list of document metadata configurations for AWS Kendra. Each configuration can include a name, type, search parameters (facetable, searchable, displayable, sortable), and relevance tuning (duration, freshness, importance, rank order, value importance items). ```terraform document_metadata_configurations = list(object({ name = optional(string) type = optional(string) search = optional(object({ facetable = optional(bool) searchable = optional(bool) displayable = optional(bool) sortable = optional(bool) })) relevance = optional(object({ duration = optional(string) freshness = optional(bool) importance = optional(number) rank_order = optional(string) value_importance_items = optional(list(object({ key = optional(string) value = optional(number) }))) })) })) ``` -------------------------------- ### Create a Vector Knowledge Base for Amazon Bedrock with Terraform Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md This configuration demonstrates how to create a vector knowledge base for Amazon Bedrock, enabling Retrieval Augmented Generation (RAG). It supports various vector store backends, with Amazon OpenSearch Serverless being the default. ```hcl # Example for OpenSearch Serverless (default) resource "aws_bedrock_knowledge_base" "default" { name = "my-default-kb" role_arn = aws_iam_role.bedrock_kb_execution_role.arn # This is the default, so no specific config needed unless overriding # create_default_kb = true } # Example for OpenSearch Managed Cluster resource "aws_bedrock_knowledge_base" "opensearch_managed" { name = "my-opensearch-kb" role_arn = aws_iam_role.bedrock_kb_execution_role.arn # Configuration for OpenSearch Managed Cluster opensearch_config { domain_endpoint = "https://my-domain.endpoint.com" index_name = "my-index" } create_opensearch_managed_config = true } # Example for Neptune Analytics resource "aws_bedrock_knowledge_base" "neptune_analytics" { name = "my-neptune-kb" role_arn = aws_iam_role.bedrock_kb_execution_role.arn # Configuration for Neptune Analytics neptune_analytics_config { vector_store_id = "my-neptune-vector-store-id" region = "us-east-1" } create_neptune_analytics_config = true } # Example for MongoDB Atlas resource "aws_bedrock_knowledge_base" "mongo_atlas" { name = "my-mongo-kb" role_arn = aws_iam_role.bedrock_kb_execution_role.arn # Configuration for MongoDB Atlas mongo_config { uri = "mongodb+srv://user:password@cluster.mongodb.net/" database_name = "my-database" collection_name = "my-collection" vector_index_name = "my-vector-index" } create_mongo_config = true } # Example for Pinecone resource "aws_bedrock_knowledge_base" "pinecone" { name = "my-pinecone-kb" role_arn = aws_iam_role.bedrock_kb_execution_role.arn # Configuration for Pinecone pinecone_config { connection_string = "YOUR_PINECONE_API_URL" namespace = "my-namespace" # API key should be stored in AWS Secrets Manager # secret_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:pinecone-api-key-xxxxxx" } create_pinecone_config = true } # Example for RDS Aurora PostgreSQL resource "aws_bedrock_knowledge_base" "rds" { name = "my-rds-kb" role_arn = aws_iam_role.bedrock_kb_execution_role.arn # Configuration for RDS Aurora PostgreSQL rds_config { resource_arn = "arn:aws:rds:us-east-1:123456789012:cluster:my-rds-cluster" secret_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:rds-credentials-xxxxxx" database_name = "mydatabase" schema = "public" table_name = "my_vectors_table" vector_column_name = "vector" } create_rds_config = true } # Example for S3 Vectors resource "aws_bedrock_knowledge_base" "s3_vectors" { name = "my-s3-vectors-kb" role_arn = aws_iam_role.bedrock_kb_execution_role.arn # Configuration for S3 Vectors s3_vectors_config { bucket_name = "my-s3-bucket" # prefix = "vectors/" } create_s3_vectors_config = true } # IAM Role for Bedrock Knowledge Base execution resource "aws_iam_role" "bedrock_kb_execution_role" { name = "BedrockKnowledgeBaseExecutionRole" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole" Effect = "Allow" Principal = { Service = "bedrock.amazonaws.com" } } ] }) } # Attach necessary policies to the role (example policies) resource "aws_iam_role_policy" "bedrock_kb_policy" { name = "BedrockKnowledgeBasePolicy" role = aws_iam_role.bedrock_kb_execution_role.id policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = [ "aoss:APISendRequest", "aoss:BatchGetCollectionItems", "aoss:CreateCollectionItems", "aoss:CreateSecurityConfig", "aoss:CreateSecurityPolicy", "aoss:DeleteCollectionItems", "aoss:DeleteSecurityConfig", "aoss:DeleteSecurityPolicy", "aoss:GetCollectionItems", "aoss:GetSecurityConfig", "aoss:GetSecurityPolicy", "aoss:ListCollections", "aoss:ListSecurityConfigs", "aoss:ListSecurityPolicies", "aoss:UpdateCollectionItems", "aoss:UpdateSecurityConfig", "aoss:UpdateSecurityPolicy" ] Effect = "Allow" Resource = "*" }, { Action = [ "es:ESHttpPost", "es:ESHttpPut", "es:ESHttpGet", "es:ESHttpDelete" ] Effect = "Allow" Resource = "arn:aws:es:*:*:domain/*" }, { Action = [ "neptune-db:ReadResourceData", "neptune-db:WriteResourceData" ] Effect = "Allow" Resource = "*" }, { Action = [ "mongodb:Read", "mongodb:Write" ] Effect = "Allow" Resource = "*" }, { Action = [ "pinecone:DescribeIndex", "pinecone:Query", "pinecone:Upsert" ] Effect = "Allow" Resource = "*" }, { Action = [ "rds:DescribeDBClusters", "rds:DescribeDBInstances", "rds:ModifyDBCluster", "rds:ModifyDBInstance" ] Effect = "Allow" Resource = "*" }, { Action = [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject" ] Effect = "Allow" Resource = "arn:aws:s3:::*" }, { Action = "secretsmanager:GetSecretValue" Effect = "Allow" Resource = "*" } ] }) } ``` -------------------------------- ### Attach Existing Knowledge Base to Bedrock Agent with Terraform Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Configures a Bedrock agent to utilize a pre-existing knowledge base. This snippet requires the knowledge base ID and its desired state (e.g., ENABLED). It specifies the foundation model and initial instruction for the agent. ```hcl module "bedrock_agent" { source = "aws-ia/bedrock/aws" version = "0.0.31" # Reference existing Knowledge Base existing_kb = "kb-abc123" kb_state = "ENABLED" foundation_model = "anthropic.claude-v2" instruction = "You are an assistant with access to company documentation." } ``` -------------------------------- ### Configure Prompt Variants for Bedrock Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines a list of prompt variants for AWS Bedrock, allowing customization of model parameters, metadata, and template configurations for both chat and text generation. Supports various settings like temperature, stop sequences, and S3 text locations. ```terraform variants_list = list({ name = optional(string) template_type = optional(string) model_id = optional(string) additional_model_request_fields = optional(string) metadata = optional(list(object({ key = optional(string) value = optional(string) }))) gen_ai_resource = optional(object({ agent = optional(object({ agent_identifier = optional(string) })) })) inference_configuration = optional(object({ text = optional(object({ max_tokens = optional(number) stop_sequences = optional(list(string)) temperature = optional(number) top_p = optional(number) top_k = optional(number) })) })) template_configuration = optional(object({ chat = optional(object({ input_variables = optional(list(object({ name = optional(string) }))) messages = optional(list(object({ content = optional(list(object({ cache_point = optional(object({ type = optional(string) })) text = optional(string) }))) role = optional(string) }))) system = optional(list(object({ cache_point = optional(object({ type = optional(string) })) text = optional(string) }))) tool_configuration = optional(object({ tool_choice = optional(object({ any = optional(string) auto = optional(string) tool = optional(object({ name = optional(string) })) })) tools = optional(list(object({ cache_point = optional(object({ type = optional(string) })) tool_spec = optional(object({ description = optional(string) input_schema = optional(object({ json = optional(string) })) name = optional(string) })) }))) })) })), text = optional(object({ input_variables = optional(list(object({ name = optional(string) }))) text = optional(string) cache_point = optional(object({ type = optional(string) })) text_s3_location = optional(object({ bucket = optional(string) key = optional(string) version = optional(string) })) })) })) }) ``` -------------------------------- ### Create Kendra Knowledge Base Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Deploys a Knowledge Base integrated with Amazon Kendra, leveraging its GenAI index for highly accurate information retrieval. This configuration disables agent creation by default. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_kendra_config = true create_kendra_s3_data_source = true create_agent = false # Kendra index configuration kendra_index_name = "kendra-genai-index" kendra_index_edition = "GEN_AI_ENTERPRISE_EDITION" } ``` -------------------------------- ### Generate Documentation with terraform-docs Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/CONTRIBUTING.md Generates documentation for Terraform modules using terraform-docs. This command is run from the repository root and uses a specific configuration file, disabling the lockfile. ```shell # from the root of the repository terraform-docs --config ${PROJECT_PATH}/.config/.terraform-docs.yaml --lockfile=false ./ ``` -------------------------------- ### Configure Custom Word Policies Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Provides a list of custom word configurations for word policies, allowing fine-grained control over input and output actions based on specific text. Each configuration includes optional enabled flags and text matching. ```terraform words_config = list({ input_action = optional(string) input_enabled = optional(bool) output_action = optional(string) output_enabled = optional(bool) text = optional(string) }) ``` -------------------------------- ### Create Knowledge Base with Neptune Analytics Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Configures a Knowledge Base utilizing Neptune Analytics for graph database integration, including advanced embedding model settings and supplemental data storage on S3. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" # Create Neptune Analytics knowledge base create_neptune_analytics_config = true graph_arn = "arn:aws:neptune-graph:us-east-1:123456789012:graph/my-graph" # Advanced embedding model configuration embedding_model_dimensions = 1024 embedding_data_type = "FLOAT32" # Supplemental data storage create_supplemental_data_storage = true supplemental_data_s3_uri = "s3://my-bucket/supplemental-data/" # Agent configuration foundation_model = "anthropic.claude-3-sonnet-20240229-v1:0" instruction = "You are a graph database expert who can analyze relationships in data." } ``` -------------------------------- ### Configure Chunking Strategy for Knowledge Base Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines how source data is split into chunks for a knowledge base. Options include NONE (manual pre-processing), maximum tokens per chunk, and overlap percentage between chunks. These settings are crucial for optimizing retrieval performance. ```terraform variable "chunking_strategy" { description = "Knowledge base can split your source data into chunks. A chunk refers to an excerpt from a data source that is returned when the knowledge base that it belongs to is queried. You have the following options for chunking your data. If you opt for NONE, then you may want to pre-process your files by splitting them up such that each file corresponds to a chunk." type = string default = null } variable "chunking_strategy_max_tokens" { description = "The maximum number of tokens to include in a chunk." type = number default = null } variable "chunking_strategy_overlap_percentage" { description = "The percentage of overlap between adjacent chunks of a data source." type = number default = null } ``` -------------------------------- ### Terraform Map Input for Custom Model Hyperparameters Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Configures parameters for tuning a custom model, such as batch size, epoch count, learning rate, and warmup steps. This is a map of strings input. ```terraform variable "custom_model_hyperparameters" { description = "Parameters related to tuning the custom model." type = map(string) default = { "batchSize" = "1" "epochCount" = "2" "learningRate" = "0.00001" "learningRateWarmupSteps" = "10" } } ``` -------------------------------- ### Configure Neptune Analytics Knowledge Base with Advanced Features (HCL) Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/.header.md This HCL configuration demonstrates setting up a Neptune Analytics knowledge base with advanced features in the AWS Bedrock Terraform module. It includes explicit configuration for Neptune, advanced embedding model settings, supplemental data storage, and agent instructions. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" # Create Neptune Analytics knowledge base create_neptune_analytics_config = true graph_arn = "arn:aws:neptune-graph:us-east-1:123456789012:graph/my-graph" # Advanced embedding model configuration embedding_model_dimensions = 1024 embedding_data_type = "FLOAT32" # Supplemental data storage create_supplemental_data_storage = true supplemental_data_s3_uri = "s3://my-bucket/supplemental-data/" # Agent configuration foundation_model = "anthropic.claude-3-sonnet-20240229-v1:0" instruction = "You are a graph database expert who can analyze relationships in data." } ``` -------------------------------- ### Configure Prompt Variants for Amazon Bedrock using HCL Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/.header.md Defines prompt variants for Amazon Bedrock, specifying template type, model ID, inference configuration, and template configuration with input variables. This allows for creating and testing different prompt versions for various use cases. ```hcl variants_list = [ { name = "variant-example" template_type = "TEXT" model_id = "amazon.titan-text-express-v1" inference_configuration = { text = { temperature = 1 top_p = 0.9900000095367432 max_tokens = 300 stop_sequences = ["User:"] top_k = 250 } } template_configuration = { text = { input_variables = [ { name = "topic" } ] text = "Make me a {{genre}} playlist consisting of the following number of songs: {{number}}." } } } ] ``` -------------------------------- ### Configure Redshift Query Generation (Terraform) Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines configurations for generating Redshift engine queries. This includes optional settings for query context such as curated natural language questions with their corresponding SQL answers, and table definitions with column details. It also allows setting an execution timeout in seconds. ```terraform query_generation_configuration = { generation_context = { curated_queries = [ { natural_language = "What is the total sales for last month?" sql = "SELECT SUM(amount) FROM sales WHERE date >= date_trunc('month', current_date - interval '1 month') AND date < date_trunc('month', current_date);" } ] tables = [ { columns = [ { description = "Unique identifier for the customer" inclusion = "INCLUDE" name = "customer_id" } ] description = "Customer information table" inclusion = "INCLUDE" name = "public.customers" } ] } execution_timeout_seconds = 60 } ``` -------------------------------- ### Configure Default OpenSearch Serverless Agent with Knowledge Base (HCL) Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/.header.md This configuration sets up a default OpenSearch Serverless agent for a knowledge base within the AWS Bedrock Terraform module. It requires the 'aws-ia/bedrock/aws' module and specifies the foundation model and an instruction prompt. ```hcl provider "opensearch" { url = module.bedrock.default_collection.collection_endpoint healthcheck = false } module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_default_kb = true create_s3_data_source = true foundation_model = "anthropic.claude-v2" instruction = "You are an automotive assistant who can provide detailed information about cars to a customer." } ``` -------------------------------- ### Create Kendra Knowledge Base with Terraform Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/.header.md This configuration demonstrates how to create a Kendra Knowledge Base using the AWS Bedrock Terraform module. It enables the creation of both the Kendra configuration and an S3 data source, while disabling agent creation. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_kendra_config = true create_kendra_s3_data_source = true create_agent = false } ``` -------------------------------- ### Terraform String Input for Custom Model Name Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Provides a name for the custom model. This is a string input, defaulting to 'custom-model'. ```terraform variable "custom_model_name" { description = "Name for the custom model." type = string default = "custom-model" } ``` -------------------------------- ### Create Bedrock Data Automation Project using Terraform Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Deploys a Bedrock Data Automation (BDA) project for extracting information from documents, images, videos, and audio using foundation models. This configuration enables BDA, sets a project name and description, and defines detailed output configurations for document and image processing, including bounding box extraction, generative fields, and output formats. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_agent = false create_bda = true bda_project_name = "document-extraction" bda_project_description = "Extract structured data from documents" bda_standard_output_configuration = { document = { extraction = { bounding_box = { state = "ENABLED" } granularity = { types = ["WORD", "PAGE"] } } generative_field = { state = "ENABLED" } output_format = { additional_file_format = { state = "ENABLED" } text_format = { types = ["PLAIN_TEXT"] } } } image = { extraction = { bounding_box = { state = "ENABLED" } category = { state = "ENABLED" types = ["TEXT_DETECTION", "LOGOS"] } } generative_field = { state = "ENABLED" types = ["IMAGE_SUMMARY"] } } } } ``` -------------------------------- ### Configure Provisioned Redshift Authentication in Terraform Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Sets up authentication configurations for a provisioned Redshift query engine. It supports defining the database user, authentication type, and the ARN for a username/password secret. ```Terraform provisioned_auth_configuration = { type = "USERNAME_PASSWORD" database_user = "admin" username_password_secret_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-redshift-creds-AbCdEf" } ``` -------------------------------- ### Create Multi-Agent Collaboration System with Terraform Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Sets up a multi-agent collaboration system using the AWS Bedrock Terraform module. This includes creating a supervisor agent and multiple collaborator agents that work together. The supervisor coordinates tasks, and collaborators handle specific functions like customer service or technical processing. Dependencies between agents are managed to ensure proper initialization order. ```hcl # Create the supervisor agent module "agent_supervisor" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_agent = false create_supervisor = true supervisor_model = "anthropic.claude-3-5-sonnet-20241022-v2:0" supervisor_instruction = "You are a supervisor who coordinates specialized agents to handle customer requests." } # Create first collaborator agent module "agent_collaborator1" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_agent_alias = true foundation_model = "anthropic.claude-v2" instruction = "You are a customer service specialist who handles inquiries." # Collaboration setup supervisor_id = module.agent_supervisor.supervisor_id create_collaborator = true collaborator_name = "CustomerServiceAgent" collaboration_instruction = "Handle customer inquiries and support requests" depends_on = [module.agent_supervisor] } # Create second collaborator agent module "agent_collaborator2" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_agent_alias = true foundation_model = "anthropic.claude-v2" instruction = "You are a technical specialist who processes backend tasks." # Collaboration setup supervisor_id = module.agent_supervisor.supervisor_id create_collaborator = true collaborator_name = "TechnicalAgent" collaboration_instruction = "Process backend tasks and technical operations" depends_on = [module.agent_supervisor, module.agent_collaborator1] } ``` -------------------------------- ### Run Markdown Lint Checks Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/CONTRIBUTING.md Applies Markdown Lint (mdl) to check Markdown files for style and formatting consistency. It targets specific files and directories, using a configuration file for rules. ```shell mdl --config ${PROJECT_PATH}/.config/.mdlrc .header.md examples/*/.header.md ``` -------------------------------- ### Terraform Map Input for Custom Model Tags Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Allows applying tags to the custom model, defined as a map of string key-value pairs. This input defaults to null. ```terraform variable "custom_model_tags" { description = "A map of tag keys and values for the custom model." type = map(string) default = null } ``` -------------------------------- ### Terraform String Input for Customization Type Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines the type of customization for the model. Valid values are 'FINE_TUNING' and 'CONTINUED_PRE_TRAINING'. This is a string input, defaulting to 'FINE_TUNING'. ```terraform variable "customization_type" { description = "The customization type. Valid values: FINE_TUNING, CONTINUED_PRE_TRAINING." type = string default = "FINE_TUNING" } ``` -------------------------------- ### Configure Bedrock Data Automation Standard Output Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines the standard output configuration for Bedrock Data Automation, allowing pre-defined extraction of information from various media types like documents, images, audio, and video. This includes specifying extraction categories, generative fields, and output formats. ```terraform object({ audio = optional(object({ extraction = optional(object({ category = optional(object({ state = optional(string) types = optional(list(string)) })) })) generative_field = optional(object({ state = optional(string) types = optional(list(string)) })) })) document = optional(object({ extraction = optional(object({ bounding_box = optional(object({ state = optional(string) })) granularity = optional(object({ types = optional(list(string)) })) })) generative_field = optional(object({ state = optional(string) })) output_format = optional(object({ additional_file_format = optional(object({ state = optional(string) })) text_format = optional(object({ types = optional(list(string)) })) })) })) image = optional(object({ extraction = optional(object({ category = optional(object({ state = optional(string) types = optional(list(string)) })) bounding_box = optional(object({ state = optional(string) })) })) generative_field = optional(object({ state = optional(string) types = optional(list(string)) })) })) video = optional(object({ extraction = optional(object({ category = optional(object({ state = optional(string) types = optional(list(string)) })) bounding_box = optional(object({ state = optional(string) })) })) generative_field = optional(object({ state = optional(string) types = optional(list(string)) })) })) }) ``` -------------------------------- ### Terraform String Input for Custom Action Control Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines custom control for action execution. This is a string input, defaulting to null. ```terraform variable "custom_control" { description = "Custom control of action execution." type = string default = null } ``` -------------------------------- ### Configure Confluence Data Source Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Sets up authentication for connecting to a Confluence instance. Requires the ARN of an AWS Secrets Manager secret containing the Confluence credentials. ```terraform variable "confluence_credentials_secret_arn" { description = "The ARN of an AWS Secrets Manager secret that stores your authentication credentials for your Confluence instance URL." type = string default = null } ``` -------------------------------- ### Configure Bedrock Data Automation Project Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines input variables for configuring a Bedrock Data Automation (BDA) project. This includes setting the project name, description, KMS key ID, encryption context, custom output configurations, and override states. ```terraform variable "bda_project_name" { description = "The name of the Bedrock data automation project." type = string default = "bda-project" } variable "bda_project_description" { description = "The description of the Bedrock data automation project." type = string default = null } variable "bda_kms_key_id" { description = "The KMS key ID for the Bedrock data automation project." type = string default = null } variable "bda_kms_encryption_context" { description = "The KMS encryption context for the Bedrock data automation project." type = map(string) default = null } variable "bda_custom_output_config" { description = "A list of the BDA custom output configuration blueprint(s)." type = list(object({ blueprint_arn = optional(string) blueprint_stage = optional(string) blueprint_version = optional(string) })) default = null } variable "bda_override_config_state" { description = "Configuration state for the BDA override." type = string default = null } ``` -------------------------------- ### Configure Automated Reasoning Policy Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Defines optional configuration for integrating Automated Reasoning policies with a guardrail. This includes setting a confidence threshold and specifying a list of policies. ```terraform variable "automated_reasoning_policy_config" { description = "Optional configuration for integrating Automated Reasoning policies with the guardrail." type = object({ confidence_threshold = optional(number) policies = optional(list(string)) }) default = null } ``` -------------------------------- ### Terraform String Input for Custom Model Training URI Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Specifies the S3 URI where the training data for the custom model is located. This is a string input, defaulting to null. ```terraform variable "custom_model_training_uri" { description = "The S3 URI where the training data is stored for custom model." type = string default = null } ``` -------------------------------- ### Create Agent with Alias for Production Deployment Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Creates an agent alias for production deployments, allowing applications to integrate via API calls. Aliases are essential for managing different versions of an agent in a production environment. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_agent_alias = true agent_alias_name = "production-v1" foundation_model = "anthropic.claude-v2" instruction = "You are an automotive assistant who can provide detailed information about cars to a customer." } ``` -------------------------------- ### Create Bedrock Agent with Guardrails using Terraform Source: https://context7.com/aws-ia/terraform-aws-bedrock/llms.txt Deploys a Bedrock agent with advanced guardrails for content safety, PII protection, and topic management. This configuration includes filters for text and image content, PII entity blocking and anonymization, custom regex patterns, a profanity filter, custom blocked words, and denied topics. ```hcl module "bedrock" { source = "aws-ia/bedrock/aws" version = "0.0.31" create_guardrail = true guardrail_name = "content-safety-guardrail" # Content filters for text and images filters_config = [ { input_strength = "MEDIUM" output_strength = "MEDIUM" type = "HATE" input_modalities = ["TEXT"] output_modalities = ["TEXT"] }, { input_strength = "HIGH" output_strength = "HIGH" type = "VIOLENCE" input_modalities = ["TEXT", "IMAGE"] output_modalities = ["TEXT", "IMAGE"] }, { input_strength = "HIGH" output_strength = "HIGH" type = "MISCONDUCT" input_modalities = ["IMAGE"] output_modalities = ["IMAGE"] } ] # PII entity protection pii_entities_config = [ { action = "BLOCK" type = "NAME" }, { action = "BLOCK" type = "DRIVER_ID" }, { action = "ANONYMIZE" type = "USERNAME" } ] # Custom regex patterns regexes_config = [{ action = "BLOCK" description = "Block SSN patterns" name = "ssn_pattern" pattern = "^\\d{3}-\\d{2}-\\d{4}$" }] # Profanity filter managed_word_lists_config = [{ type = "PROFANITY" }] # Custom blocked words words_config = [{ text = "HATE" }] # Denied topics topics_config = [{ name = "investment_topic" examples = ["Where should I invest my money?"] type = "DENY" definition = "Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns." }] foundation_model = "anthropic.claude-v2" instruction = "You are an automotive assistant who can provide detailed information about cars to a customer." } ``` -------------------------------- ### Set Base Prompt Template Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Specifies the base prompt template to be used, allowing for customization of the default prompt template. This variable accepts a string value. ```terraform variable "base_prompt_template" { description = "Defines the prompt template with which to replace the default prompt template." type = string default = null } ``` -------------------------------- ### Content Filter Configurations (Terraform) Source: https://github.com/aws-ia/terraform-aws-bedrock/blob/main/README.md Specifies a list of content filter configurations for a content policy. Supports both text and image filters. You can define input and output modalities (e.g., ['TEXT'], ['IMAGE'], or ['TEXT', 'IMAGE']) and filter types like HATE, INSULTS, MISCONDUCT, PROMPT_ATTACK, SEXUAL, VIOLENCE. Each filter can have an action, enabled status, and strength. ```terraform filters_config = list(object({ input_action = optional(string) input_enabled = optional(bool) input_modalities = optional(list(string)) input_strength = optional(string) output_action = optional(string) output_enabled = optional(bool) output_modalities = optional(list(string)) output_strength = optional(string) type = optional(string) })) ```