hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
239 stars 107 forks source link

awscc_bedrock_agent: foundation model input accepts only name #1652

Open quixoticmonk opened 2 months ago

quixoticmonk commented 2 months ago

Community Note

Terraform CLI and Terraform AWS Cloud Control Provider Version

Affected Resource(s)

Terraform Configuration Files

The configuration below errors out on plan with foundation_model expecting a name than ARN/Name.

resource "awscc_bedrock_agent" "example" {
  agent_name              = "example-agent"
  description             = "Example agent configuration"
  agent_resource_role_arn = var.agent_role_arn
  foundation_model        = "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-v2:1"
  instruction             = "You are an office assistant in an insurance agency. You are friendly and polite. You help with managing insurance claims and coordinating pending paperwork."
  knowledge_bases = [{
    description       = "example knowledge base"
    knowledge_base_id = var.knowledge_base_id
  }]

  customer_encryption_key_arn = var.kms_key_arn
  idle_session_ttl_in_seconds = 600
  auto_prepare = true

  action_groups = [ {
    action_group_name = "example-action-group"
    description = "Example action group"
    action_group_executor = {
      lambda = var.lambda_arn
    }

  } ]

  tags = {
    "Modified By" = "AWSCC"
  }

}

Debug Output

Panic Output

Expected Behavior

Terraform apply should accept the ARN of the foundation model per the schema definitaion below.

"FoundationModel": {
      "type": "string",
      "maxLength": 2048,
      "minLength": 1,
      "pattern": "^arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}(([:][a-z0-9-]{1,63}){0,2})?/[a-z0-9]{12})|(:foundation-model/([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.]?[a-z0-9-]{1,63})([:][a-z0-9-]{1,63}){0,2})))|(([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.]?[a-z0-9-]{1,63})([:][a-z0-9-]{1,63}){0,2}))|(([0-9a-zA-Z][_-]?)+)$",
      "description": "ARN or name of a Bedrock model."
    }

Actual Behavior

The resource configuration fails with the below error message.

│ Error: AWS SDK Go Service Operation Incomplete
│
│   with awscc_bedrock_agent.example,
│   on main.tf line 1, in resource "awscc_bedrock_agent" "example":
│    1: resource "awscc_bedrock_agent" "example" {
│
│ Waiting for Cloud Control API service CreateResource operation completion returned: waiter state transitioned
│ to FAILED. StatusMessage: Foundation model is null or unsupported, try providing: [anthropic.claude-v2,
│ anthropic.claude-instant-v1, anthropic.claude-v2:1, amazon.titan-text-premier-v1:0,
│ anthropic.claude-3-sonnet-20240229-v1:0, anthropic.claude-3-haiku-20240307-v1:0] (Service: BedrockAgent, Status
│ Code: 400, Request ID: 246286c5-7321-4094-adaf-6965a0c5f116). ErrorCode: InvalidRequest

Model ARN from the AWS API

aws bedrock get-foundation-model --model-identifier anthropic.claude-v2:1
{
    "modelDetails": {
        "modelArn": "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-v2:1",
        "modelId": "anthropic.claude-v2:1",
        "modelName": "Claude",
        "providerName": "Anthropic",
        "inputModalities": [
            "TEXT"
        ],
        "outputModalities": [
            "TEXT"
        ],
        "responseStreamingSupported": true,
        "customizationsSupported": [],
        "inferenceTypesSupported": [
            "ON_DEMAND"
        ],
        "modelLifecycle": {
            "status": "ACTIVE"
        }
    }
}

When the name of the model is provided, the terraform apply doesn't error on the input validation.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

quixoticmonk commented 3 days ago

Opened a service ticket as the Cloudcontrol api create-resource operation is also getting the same error.