AgentAgentAlias class

Resource for managing an AWS Agents for Amazon Bedrock Agent Alias.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const current = aws.getCallerIdentity({});
const currentGetPartition = aws.getPartition({});
const currentGetRegion = aws.getRegion({});
const exampleAgentTrust = Promise.all([current, currentGetPartition, currentGetRegion]).then(([current, currentGetPartition, currentGetRegion]) => aws.iam.getPolicyDocument({
    statements: [{
        conditions: [
            {
                test: "StringEquals",
                values: [current.accountId],
                variable: "aws:SourceAccount",
            },
            {
                test: "ArnLike",
                values: [`arn:${currentGetPartition.partition}:bedrock:${currentGetRegion.region}:${current.accountId}:agent/*`],
                variable: "AWS:SourceArn",
            },
        ],
        principals: [{
            identifiers: ["bedrock.amazonaws.com"],
            type: "Service",
        }],
        actions: ["sts:AssumeRole"],
    }],
}));
const exampleAgentPermissions = Promise.all([currentGetPartition, currentGetRegion]).then(([currentGetPartition, currentGetRegion]) => aws.iam.getPolicyDocument({
    statements: [{
        actions: ["bedrock:InvokeModel"],
        resources: [`arn:${currentGetPartition.partition}:bedrock:${currentGetRegion.region}::foundation-model/anthropic.claude-v2`],
    }],
}));
const example = new aws.iam.Role("example", {
    assumeRolePolicy: exampleAgentTrust.then(exampleAgentTrust => exampleAgentTrust.json),
    namePrefix: "AmazonBedrockExecutionRoleForAgents_",
});
const exampleRolePolicy = new aws.iam.RolePolicy("example", {
    policy: exampleAgentPermissions.then(exampleAgentPermissions => exampleAgentPermissions.json),
    role: example.id,
});
const exampleAgentAgent = new aws.bedrock.AgentAgent("example", {
    agentName: "my-agent-name",
    agentResourceRoleArn: example.arn,
    idleTtl: 500,
    foundationModel: "anthropic.claude-v2",
});
const exampleAgentAgentAlias = new aws.bedrock.AgentAgentAlias("example", {
    agentAliasName: "my-agent-alias",
    agentId: exampleAgentAgent.agentId,
    description: "Test Alias",
});
import pulumi
import pulumi_aws as aws

current = aws.get_caller_identity()
current_get_partition = aws.get_partition()
current_get_region = aws.get_region()
example_agent_trust = aws.iam.get_policy_document(statements=[{
    "conditions": [
        {
            "test": "StringEquals",
            "values": [current.account_id],
            "variable": "aws:SourceAccount",
        },
        {
            "test": "ArnLike",
            "values": [f"arn:{current_get_partition.partition}:bedrock:{current_get_region.region}:{current.account_id}:agent/*"],
            "variable": "AWS:SourceArn",
        },
    ],
    "principals": [{
        "identifiers": ["bedrock.amazonaws.com"],
        "type": "Service",
    }],
    "actions": ["sts:AssumeRole"],
}])
example_agent_permissions = aws.iam.get_policy_document(statements=[{
    "actions": ["bedrock:InvokeModel"],
    "resources": [f"arn:{current_get_partition.partition}:bedrock:{current_get_region.region}::foundation-model/anthropic.claude-v2"],
}])
example = aws.iam.Role("example",
    assume_role_policy=example_agent_trust.json,
    name_prefix="AmazonBedrockExecutionRoleForAgents_")
example_role_policy = aws.iam.RolePolicy("example",
    policy=example_agent_permissions.json,
    role=example.id)
example_agent_agent = aws.bedrock.AgentAgent("example",
    agent_name="my-agent-name",
    agent_resource_role_arn=example.arn,
    idle_ttl=500,
    foundation_model="anthropic.claude-v2")
example_agent_agent_alias = aws.bedrock.AgentAgentAlias("example",
    agent_alias_name="my-agent-alias",
    agent_id=example_agent_agent.agent_id,
    description="Test Alias")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var current = Aws.GetCallerIdentity.Invoke();

    var currentGetPartition = Aws.GetPartition.Invoke();

    var currentGetRegion = Aws.GetRegion.Invoke();

    var exampleAgentTrust = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Conditions = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "StringEquals",
                        Values = new[]
                        {
                            current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId),
                        },
                        Variable = "aws:SourceAccount",
                    },
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "ArnLike",
                        Values = new[]
                        {
                            $"arn:{currentGetPartition.Apply(getPartitionResult => getPartitionResult.Partition)}:bedrock:{currentGetRegion.Apply(getRegionResult => getRegionResult.Region)}:{current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:agent/*",
                        },
                        Variable = "AWS:SourceArn",
                    },
                },
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Identifiers = new[]
                        {
                            "bedrock.amazonaws.com",
                        },
                        Type = "Service",
                    },
                },
                Actions = new[]
                {
                    "sts:AssumeRole",
                },
            },
        },
    });

    var exampleAgentPermissions = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Actions = new[]
                {
                    "bedrock:InvokeModel",
                },
                Resources = new[]
                {
                    $"arn:{currentGetPartition.Apply(getPartitionResult => getPartitionResult.Partition)}:bedrock:{currentGetRegion.Apply(getRegionResult => getRegionResult.Region)}::foundation-model/anthropic.claude-v2",
                },
            },
        },
    });

    var example = new Aws.Iam.Role("example", new()
    {
        AssumeRolePolicy = exampleAgentTrust.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        NamePrefix = "AmazonBedrockExecutionRoleForAgents_",
    });

    var exampleRolePolicy = new Aws.Iam.RolePolicy("example", new()
    {
        Policy = exampleAgentPermissions.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        Role = example.Id,
    });

    var exampleAgentAgent = new Aws.Bedrock.AgentAgent("example", new()
    {
        AgentName = "my-agent-name",
        AgentResourceRoleArn = example.Arn,
        IdleTtl = 500,
        FoundationModel = "anthropic.claude-v2",
    });

    var exampleAgentAgentAlias = new Aws.Bedrock.AgentAgentAlias("example", new()
    {
        AgentAliasName = "my-agent-alias",
        AgentId = exampleAgentAgent.AgentId,
        Description = "Test Alias",
    });

});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/bedrock"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		current, err := aws.GetCallerIdentity(ctx, &aws.GetCallerIdentityArgs{}, nil)
		if err != nil {
			return err
		}
		currentGetPartition, err := aws.GetPartition(ctx, &aws.GetPartitionArgs{}, nil)
		if err != nil {
			return err
		}
		currentGetRegion, err := aws.GetRegion(ctx, &aws.GetRegionArgs{}, nil)
		if err != nil {
			return err
		}
		exampleAgentTrust, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Conditions: []iam.GetPolicyDocumentStatementCondition{
						{
							Test: "StringEquals",
							Values: pulumi.StringArray{
								current.AccountId,
							},
							Variable: "aws:SourceAccount",
						},
						{
							Test: "ArnLike",
							Values: []string{
								fmt.Sprintf("arn:%v:bedrock:%v:%v:agent/*", currentGetPartition.Partition, currentGetRegion.Region, current.AccountId),
							},
							Variable: "AWS:SourceArn",
						},
					},
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Identifiers: []string{
								"bedrock.amazonaws.com",
							},
							Type: "Service",
						},
					},
					Actions: []string{
						"sts:AssumeRole",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		exampleAgentPermissions, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Actions: []string{
						"bedrock:InvokeModel",
					},
					Resources: []string{
						fmt.Sprintf("arn:%v:bedrock:%v::foundation-model/anthropic.claude-v2", currentGetPartition.Partition, currentGetRegion.Region),
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		example, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
			AssumeRolePolicy: pulumi.String(exampleAgentTrust.Json),
			NamePrefix:       pulumi.String("AmazonBedrockExecutionRoleForAgents_"),
		})
		if err != nil {
			return err
		}
		_, err = iam.NewRolePolicy(ctx, "example", &iam.RolePolicyArgs{
			Policy: pulumi.String(exampleAgentPermissions.Json),
			Role:   example.ID().ToIDOutput().ToStringOutput(),
		})
		if err != nil {
			return err
		}
		exampleAgentAgent, err := bedrock.NewAgentAgent(ctx, "example", &bedrock.AgentAgentArgs{
			AgentName:            pulumi.String("my-agent-name"),
			AgentResourceRoleArn: example.Arn,
			IdleTtl:              500,
			FoundationModel:      pulumi.String("anthropic.claude-v2"),
		})
		if err != nil {
			return err
		}
		_, err = bedrock.NewAgentAgentAlias(ctx, "example", &bedrock.AgentAgentAliasArgs{
			AgentAliasName: pulumi.String("my-agent-alias"),
			AgentId:        exampleAgentAgent.AgentId,
			Description:    pulumi.String("Test Alias"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_getcalleridentity" "current" {
}
data "aws_getpartition" "currentGetPartition" {
}
data "aws_getregion" "currentGetRegion" {
}
data "aws_iam_getpolicydocument" "exampleAgentTrust" {
  statements {
    conditions {
      test     = "StringEquals"
      values   = [data.aws_getcalleridentity.current.account_id]
      variable = "aws:SourceAccount"
    }
    conditions {
      test     = "ArnLike"
      values   = ["arn:${data.aws_getpartition.currentGetPartition.partition}:bedrock:${data.aws_getregion.currentGetRegion.region}:${data.aws_getcalleridentity.current.account_id}:agent/*"]
      variable = "AWS:SourceArn"
    }
    principals {
      identifiers = ["bedrock.amazonaws.com"]
      type        = "Service"
    }
    actions = ["sts:AssumeRole"]
  }
}
data "aws_iam_getpolicydocument" "exampleAgentPermissions" {
  statements {
    actions   = ["bedrock:InvokeModel"]
    resources = ["arn:${data.aws_getpartition.currentGetPartition.partition}:bedrock:${data.aws_getregion.currentGetRegion.region}::foundation-model/anthropic.claude-v2"]
  }
}

resource "aws_iam_role" "example" {
  assume_role_policy = data.aws_iam_getpolicydocument.exampleAgentTrust.json
  name_prefix        = "AmazonBedrockExecutionRoleForAgents_"
}
resource "aws_iam_rolepolicy" "example" {
  policy = data.aws_iam_getpolicydocument.exampleAgentPermissions.json
  role   = aws_iam_role.example.id
}
resource "aws_bedrock_agentagent" "example" {
  agent_name              = "my-agent-name"
  agent_resource_role_arn = aws_iam_role.example.arn
  idle_ttl                = 500
  foundation_model        = "anthropic.claude-v2"
}
resource "aws_bedrock_agentagentalias" "example" {
  agent_alias_name = "my-agent-alias"
  agent_id         = aws_bedrock_agentagent.example.agent_id
  description      = "Test Alias"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetCallerIdentityArgs;
import com.pulumi.aws.inputs.GetPartitionArgs;
import com.pulumi.aws.inputs.GetRegionArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementConditionArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.RolePolicy;
import com.pulumi.aws.iam.RolePolicyArgs;
import com.pulumi.aws.bedrock.AgentAgent;
import com.pulumi.aws.bedrock.AgentAgentArgs;
import com.pulumi.aws.bedrock.AgentAgentAlias;
import com.pulumi.aws.bedrock.AgentAgentAliasArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var current = AwsFunctions.getCallerIdentity(GetCallerIdentityArgs.builder()
            .build());

        final var currentGetPartition = AwsFunctions.getPartition(GetPartitionArgs.builder()
            .build());

        final var currentGetRegion = AwsFunctions.getRegion(GetRegionArgs.builder()
            .build());

        final var exampleAgentTrust = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .conditions(
                    GetPolicyDocumentStatementConditionArgs.builder()
                        .test("StringEquals")
                        .values(current.accountId())
                        .variable("aws:SourceAccount")
                        .build(),
                    GetPolicyDocumentStatementConditionArgs.builder()
                        .test("ArnLike")
                        .values(String.format("arn:%s:bedrock:%s:%s:agent/*", currentGetPartition.partition(),currentGetRegion.region(),current.accountId()))
                        .variable("AWS:SourceArn")
                        .build())
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .identifiers("bedrock.amazonaws.com")
                    .type("Service")
                    .build())
                .actions("sts:AssumeRole")
                .build())
            .build());

        final var exampleAgentPermissions = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .actions("bedrock:InvokeModel")
                .resources(String.format("arn:%s:bedrock:%s::foundation-model/anthropic.claude-v2", currentGetPartition.partition(),currentGetRegion.region()))
                .build())
            .build());

        var example = new Role("example", RoleArgs.builder()
            .assumeRolePolicy(exampleAgentTrust.json())
            .namePrefix("AmazonBedrockExecutionRoleForAgents_")
            .build());

        var exampleRolePolicy = new RolePolicy("exampleRolePolicy", RolePolicyArgs.builder()
            .policy(exampleAgentPermissions.json())
            .role(example.id())
            .build());

        var exampleAgentAgent = new AgentAgent("exampleAgentAgent", AgentAgentArgs.builder()
            .agentName("my-agent-name")
            .agentResourceRoleArn(example.arn())
            .idleTtl(500)
            .foundationModel("anthropic.claude-v2")
            .build());

        var exampleAgentAgentAlias = new AgentAgentAlias("exampleAgentAgentAlias", AgentAgentAliasArgs.builder()
            .agentAliasName("my-agent-alias")
            .agentId(exampleAgentAgent.agentId())
            .description("Test Alias")
            .build());

    }
}
resources:
  example:
    type: aws:iam:Role
    properties:
      assumeRolePolicy: ${exampleAgentTrust.json}
      namePrefix: AmazonBedrockExecutionRoleForAgents_
  exampleRolePolicy:
    type: aws:iam:RolePolicy
    name: example
    properties:
      policy: ${exampleAgentPermissions.json}
      role: ${example.id}
  exampleAgentAgent:
    type: aws:bedrock:AgentAgent
    name: example
    properties:
      agentName: my-agent-name
      agentResourceRoleArn: ${example.arn}
      idleTtl: 500
      foundationModel: anthropic.claude-v2
  exampleAgentAgentAlias:
    type: aws:bedrock:AgentAgentAlias
    name: example
    properties:
      agentAliasName: my-agent-alias
      agentId: ${exampleAgentAgent.agentId}
      description: Test Alias
variables:
  current:
    fn::invoke:
      function: aws:getCallerIdentity
      arguments: {}
  currentGetPartition:
    fn::invoke:
      function: aws:getPartition
      arguments: {}
  currentGetRegion:
    fn::invoke:
      function: aws:getRegion
      arguments: {}
  exampleAgentTrust:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - conditions:
              - test: StringEquals
                values:
                  - ${current.accountId}
                variable: aws:SourceAccount
              - test: ArnLike
                values:
                  - arn:${currentGetPartition.partition}:bedrock:${currentGetRegion.region}:${current.accountId}:agent/*
                variable: AWS:SourceArn
            principals:
              - identifiers:
                  - bedrock.amazonaws.com
                type: Service
            actions:
              - sts:AssumeRole
  exampleAgentPermissions:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - actions:
              - bedrock:InvokeModel
            resources:
              - arn:${currentGetPartition.partition}:bedrock:${currentGetRegion.region}::foundation-model/anthropic.claude-v2

Import

Using pulumi import, import Agents for Amazon Bedrock Agent Alias using the alias ID and the agent ID separated by ,. For example:

$ pulumi import aws:bedrock/agentAgentAlias:AgentAgentAlias example 66IVY0GUTF,GGRRAED6JP

Constructors

AgentAgentAlias(String name, {AgentAgentAliasArgs? args, CustomResourceOptions? options})
Creates a new AgentAgentAlias. name The Pulumi resource name. args Arguments used to configure this AgentAgentAlias. The set of arguments for AgentAgentAlias. options Resource options controlling this resource's behavior.
AgentAgentAlias.reference(String urn)
Creates a typed reference to an existing AgentAgentAlias resource.

Properties

agentAliasArn ↔ Output<String>
ARN of the alias.
latefinal
agentAliasId ↔ Output<String>
Unique identifier of the alias.
latefinal
agentAliasName ↔ Output<String>
Name of the alias.
latefinal
agentId ↔ Output<String>
Identifier of the agent to create an alias for.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
description ↔ Output<String?>
Description of the alias.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
routingConfigurations ↔ Output<List<AgentAgentAliasRoutingConfiguration>>
Details about the routing configuration of the alias. See routingConfiguration Block for details.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tags ↔ Output<Map<String, String>?>
Map of tags assigned to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
timeouts ↔ Output<AgentAgentAliasTimeouts?>
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {AgentAgentAliasState? state, CustomResourceOptions? options}) → AgentAgentAlias
Gets an existing AgentAgentAlias resource's state with the given name and id.