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.85k stars 9.2k forks source link

[Bug]: Bedrock Agent instruction is mandatory #40255

Open jeremychauvet opened 7 hours ago

jeremychauvet commented 7 hours ago

Terraform Core Version

1.9.8

AWS Provider Version

5.76.0

Affected Resource(s)

Expected Behavior

Following actual resource documentation, the following instructions are mandatory:

Actual Behavior

Trying to create the resource with this code result to an error:

resource "aws_bedrockagent_agent" "demo" {
  agent_name                     = "my-agent-name"
  agent_resource_role_arn  = aws_iam_role.example.arn
  foundation_model            = "anthropic.claude-v2"
}

Error:

│ Error: creating Agent
│
│   with aws_bedrockagent_agent.demo,
│   on agent.tf line 46, in resource "aws_bedrockagent_agent" "demo":
│   46: resource "aws_bedrockagent_agent" "demo" {
│
│ waiting for Bedrock Agent (3TTM4DCSXX) prepare: unexpected state 'FAILED', wanted target 'PREPARED'. last error: Exception: Agent Instruction cannot be null

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

data "aws_caller_identity" "current" {}

data "aws_partition" "current" {}

data "aws_region" "current" {}

data "aws_iam_policy_document" "example_agent_trust" {
  statement {
    actions = ["sts:AssumeRole"]
    principals {
      identifiers = ["bedrock.amazonaws.com"]
      type        = "Service"
    }
    condition {
      test     = "StringEquals"
      values   = [data.aws_caller_identity.current.account_id]
      variable = "aws:SourceAccount"
    }
    condition {
      test     = "ArnLike"
      values   = ["arn:${data.aws_partition.current.partition}:bedrock:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:agent/*"]
      variable = "AWS:SourceArn"
    }
  }
}

data "aws_iam_policy_document" "example_agent_permissions" {
  statement {
    actions = ["bedrock:InvokeModel"]
    resources = [
      "arn:${data.aws_partition.current.partition}:bedrock:${data.aws_region.current.name}::foundation-model/anthropic.claude-v2",
    ]
  }
}

resource "aws_iam_role" "example" {
  assume_role_policy = data.aws_iam_policy_document.example_agent_trust.json
  name_prefix        = "AmazonBedrockExecutionRoleForAgents_"
}

resource "aws_iam_role_policy" "example" {
  policy = data.aws_iam_policy_document.example_agent_permissions.json
  role   = aws_iam_role.example.id
}

resource "aws_bedrockagent_agent" "demo" {
  agent_name              = "my-agent-name"
  agent_resource_role_arn = aws_iam_role.example.arn
  foundation_model        = "anthropic.claude-v2"
}

Steps to Reproduce


1.  terraform init
2. terraform plan
3. terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

Yes

github-actions[bot] commented 7 hours ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue