Resource: aws_bedrockagent_agent_alias

Terraform resource for managing an AWS Agents for Amazon Bedrock Agent Alias.

Example Usage

Basic Usage

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

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:aws: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:aws:bedrock:${data.aws_region.current.name}::foundation-model/anthropic.claude-v2",
    ]
  }
}

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

data "aws_caller_identity" "current" {}

data "aws_region" "current" {}

resource "aws_bedrockagent_agent" "test" {
  agent_name              = "my-agent-name"
  agent_resource_role_arn = aws_iam_role.example.arn
  idle_ttl                = 500
  foundation_model        = "anthropic.claude-v2"
}
resource "aws_bedrockagent_agent_alias" "example" {
  agent_alias_name = "my-agent-alias"
  agent_id         = aws_bedrockagent_agent.test.agent_id
  description      = "Test ALias"
}

Argument Reference

The following arguments are required:

The following arguments are optional:

routing_configuration

This argument is processed in attribute-as-blocks mode.

The following arguments are required:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import Agents for Amazon Bedrock Agent Alias using the ABCDE12345,FGHIJ67890. For example:

import {
  to = aws_bedrockagent_agent_alias.example
  id = "ABCDE12345,FGHIJ67890"
}

Using terraform import, import Agents for Amazon Bedrock Agent Alias using the AGENT_ID,ALIAS_ID. For example:

% terraform import aws_bedrockagent_agent_alias.example AGENT_ID,ALIAS_ID