hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.74k stars 9.1k forks source link

[New Resource]: aws_bedrockagent_prompt #38583

Open kxzk opened 1 month ago

kxzk commented 1 month ago

Description

Description:

The Prompt Management feature streamlines the creation, evaluation, deployment, and sharing of prompts. This feature helps developers and business users obtain the best responses from FMs for their specific use cases.

Key benefits of Prompt Management include the following:

Rapid prompt creation and iteration – Create your prompts and variations with the built-in prompt builder on the Amazon Bedrock console or with the CreatePrompt Incorporate dynamic information using inputs for building your prompt templates.

Seamless testing and deployment – Quickly test individual prompts, set variables and their test values. Create prompt versions stored in the built-in prompt library for cataloging and management using the Amazon Bedrock console or the GetPrompt, ListPrompts, and CreatePromptVersion.

Features:

Requested Resource(s) and/or Data Source(s)

Potential Terraform Configuration

# Provider configuration
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }
}

provider "aws" {
  region = var.aws_region
}

# Variables
variable "aws_region" {
  description = "The AWS region to create resources in"
  default     = "us-west-2"
}

variable "prompt_name" {
  description = "Name of the BedrockAgent Prompt"
  default     = "my_bedrockagent_prompt"
}

variable "prompt_description" {
  description = "Description of the BedrockAgent Prompt"
  default     = "Example BedrockAgent prompt for agent"
}

variable "specialization" {
  description = "Specialization of the AI assistant"
  default     = "customer service"
}

variable "tone" {
  description = "Tone of the AI assistant's responses"
  default     = "professional"
}

# BedrockAgent Prompt Resource
resource "aws_bedrockagent_prompt" "example" {
  name        = var.prompt_name
  description = var.prompt_description

  prompt_template = <<EOF
You are an AI assistant specialized in ${var.specialization}.
User query: {{user_input}}
Consider the following context: {{context}}
Respond in a ${var.tone} tone.
EOF

  input_parameter {
    name        = "user_input"
    description = "The user's query or input"
  }

  input_parameter {
    name        = "context"
    description = "Additional context for the prompt"
  }

  tags = {
    Environment = "Production"
    Project     = "AI Assistant"
  }
}

# Prompt Version Resource
resource "aws_bedrockagent_prompt_version" "example_version" {
  prompt_id = aws_bedrockagent_prompt.example.id
  version   = "1.0"
}

# Data source to get information about a specific prompt
data "aws_bedrockagent_prompt" "example" {
  prompt_id = aws_bedrockagent_prompt.example.id
}

# Data source to list all prompts
data "aws_bedrockagent_prompts" "all_prompts" {
  depends_on = [aws_bedrockagent_prompt.example]
}

# Outputs
output "prompt_id" {
  description = "The ID of the created BedrockAgent Prompt"
  value       = aws_bedrockagent_prompt.example.id
}

output "prompt_version" {
  description = "The version of the created BedrockAgent Prompt"
  value       = aws_bedrockagent_prompt_version.example_version.version
}

output "prompt_details" {
  description = "Details of the created BedrockAgent Prompt"
  value       = data.aws_bedrockagent_prompt.example
}

output "all_prompts" {
  description = "List of all BedrockAgent Prompts"
  value       = data.aws_bedrockagent_prompts.all_prompts.prompts
}

References

Would you like to implement a fix?

No

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue