Class AgentAgentCollaborator


  • public class AgentAgentCollaborator
    extends com.pulumi.resources.CustomResource
    Manages an AWS Bedrock Agents Agent Collaborator. ## Example Usage ### Basic Usage
     
     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 com.pulumi.aws.bedrock.AgentAgentCollaborator;
     import com.pulumi.aws.bedrock.AgentAgentCollaboratorArgs;
     import com.pulumi.aws.bedrock.inputs.AgentAgentCollaboratorAgentDescriptorArgs;
     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-3-5-sonnet-20241022-v2:0", currentGetPartition.partition(),currentGetRegion.region()))
                         .build(),
                     GetPolicyDocumentStatementArgs.builder()
                         .actions(                    
                             "bedrock:GetAgentAlias",
                             "bedrock:InvokeAgent")
                         .resources(                    
                             String.format("arn:%s:bedrock:%s:%s:agent/*", currentGetPartition.partition(),currentGetRegion.region(),current.accountId()),
                             String.format("arn:%s:bedrock:%s:%s:agent-alias/*", currentGetPartition.partition(),currentGetRegion.region(),current.accountId()))
                         .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 exampleCollaborator = new AgentAgent("exampleCollaborator", AgentAgentArgs.builder()
                 .agentName("my-agent-collaborator")
                 .agentResourceRoleArn(example.arn())
                 .idleSessionTtlInSeconds(500)
                 .foundationModel("anthropic.claude-3-5-sonnet-20241022-v2:0")
                 .instruction("You are a collaborator agent. Do what the supervisor tells you to do.")
                 .build());
     
             var exampleSupervisor = new AgentAgent("exampleSupervisor", AgentAgentArgs.builder()
                 .agentName("my-agent-supervisor")
                 .agentResourceRoleArn(example.arn())
                 .agentCollaboration("SUPERVISOR")
                 .idleSessionTtlInSeconds(500)
                 .foundationModel("anthropic.claude-3-5-sonnet-20241022-v2:0")
                 .instruction("You are a supervisor agent. Tell the sub agent what to do.")
                 .prepareAgent(false)
                 .build());
     
             var exampleAgentAgentAlias = new AgentAgentAlias("exampleAgentAgentAlias", AgentAgentAliasArgs.builder()
                 .agentAliasName("my-agent-alias")
                 .agentId(exampleCollaborator.agentId())
                 .description("Test Alias")
                 .build());
     
             var exampleAgentAgentCollaborator = new AgentAgentCollaborator("exampleAgentAgentCollaborator", AgentAgentCollaboratorArgs.builder()
                 .agentDescriptor(AgentAgentCollaboratorAgentDescriptorArgs.builder()
                     .aliasArn(exampleAgentAgentAlias.agentAliasArn())
                     .build())
                 .agentId(exampleSupervisor.agentId())
                 .collaborationInstruction("tell the other agent what to do")
                 .collaboratorName("my-collab-example")
                 .relayConversationHistory("TO_COLLABORATOR")
                 .build());
     
         }
     }
     
     
    ## Import Using `pulumi import`, import Bedrock Agents Agent Collaborator using a comma-delimited string combining `agentId`, `agentVersion`, and `collaboratorId`. For example: ```sh $ pulumi import aws:bedrock/agentAgentCollaborator:AgentAgentCollaborator example 9LSJO0BFI8,DRAFT,AG3TN4RQIY ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Detail

      • AgentAgentCollaborator

        public AgentAgentCollaborator​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • AgentAgentCollaborator

        public AgentAgentCollaborator​(java.lang.String name,
                                      AgentAgentCollaboratorArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • AgentAgentCollaborator

        public AgentAgentCollaborator​(java.lang.String name,
                                      AgentAgentCollaboratorArgs args,
                                      @Nullable
                                      com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • agentDescriptor

        public com.pulumi.core.Output<AgentAgentCollaboratorAgentDescriptor> agentDescriptor()
        Returns:
        Agent descriptor for the agent collaborator. See `agentDescriptor` Block for details.
      • agentId

        public com.pulumi.core.Output<java.lang.String> agentId()
        Returns:
        ID of the agent to associate the collaborator with.
      • agentVersion

        public com.pulumi.core.Output<java.lang.String> agentVersion()
        Returns:
        Version of the agent to associate the collaborator with. Defaults to `DRAFT`.
      • collaborationInstruction

        public com.pulumi.core.Output<java.lang.String> collaborationInstruction()
        Returns:
        Instruction to give the collaborator.
      • collaboratorId

        public com.pulumi.core.Output<java.lang.String> collaboratorId()
        Returns:
        ID of the Agent Collaborator.
      • collaboratorName

        public com.pulumi.core.Output<java.lang.String> collaboratorName()
        Returns:
        Name of this collaborator. The following arguments are optional:
      • prepareAgent

        public com.pulumi.core.Output<java.lang.Boolean> prepareAgent()
        Returns:
        Whether to prepare the agent after creation or modification. Defaults to `true`.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • relayConversationHistory

        public com.pulumi.core.Output<java.lang.String> relayConversationHistory()
        Returns:
        Configure relaying the history to the collaborator.
      • get

        public static AgentAgentCollaborator get​(java.lang.String name,
                                                 com.pulumi.core.Output<java.lang.String> id,
                                                 @Nullable
                                                 AgentAgentCollaboratorState state,
                                                 @Nullable
                                                 com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.