Configure cross-account access for Amazon Bedrock (Frontier)

Important

This feature is part of Frontier preview program. Frontier connects you directly with Microsoft’s latest AI innovations. Frontier previews are subject to the existing preview terms of your customer agreements. As these features are still in development, their availability and capabilities may change over time.

An Amazon Web Services (AWS) organization can contain multiple AWS accounts, each with its own identities and policies. To use a single set of credentials to access Amazon Bedrock resources across those accounts, create a role in each target account with trust relationship to allow a principal from the management account to assume this role. Grant the role the permissions required to synchronize Bedrock and Bedrock AgentCore resources. Assign appropriate permission policies to the role to access, perform actions on Bedrock objects in the AWS account.

You can configure cross-account access manually or use AWS CloudFormation StackSets to deploy the roles and policies.

Prerequisites

Before you begin, ensure that you have:

  • An AWS Organizations management account and the organization ID.
  • An IAM user in the management account whose access key is used for synchronization.
  • The ARN of the synchronization IAM user.
  • Permissions to create and attach IAM policies and roles in the management and target accounts.
  • Permissions to create and deploy AWS CloudFormation stacks and StackSets if you use the automated method.

Configure cross-account access manually

Complete the following steps in every AWS account that contains agents to synchronize.

  1. Sign in to the AWS Management Console for the target account.

  2. Go to Identity and Access Management (IAM) > Policies, and create a policy with the following permissions:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "bedrock:ListAgents",
            "bedrock:GetAgent",
            "bedrock:ListAgentAliases",
            "bedrock:GetAgentAlias",
            "bedrock:ListAgentVersions",
            "bedrock:GetAgentVersion",
            "bedrock:InvokeModel",
            "bedrock:InvokeAgent",
            "bedrock:InvokeInlineAgent",
            "bedrock:DeleteAgent",
            "bedrock-agentcore:ListHarnesses",
            "bedrock-agentcore:ListAgentRuntimes",
            "bedrock-agentcore:ListGateways",
            "bedrock-agentcore:ListGatewayTargets",
            "bedrock-agentcore:GetHarness",
            "bedrock-agentcore:GetAgentRuntime",
            "bedrock-agentcore:GetGateway",
            "bedrock-agentcore:GetGatewayTarget",
            "bedrock-agentcore:GetMemory",
            "bedrock-agentcore:DeleteHarness",
            "bedrock-agentcore:DeleteAgentRuntime",
            "bedrock-agentcore:DeleteWorkloadIdentity",
            "bedrock-agentcore:DeleteAgentRuntimeEndpoint",
            "bedrock-agentcore:DeleteGateway",
            "bedrock-agentcore:DeleteGatewayTarget",
            "bedrock-agentcore:DeleteMemory"
          ],
          "Resource": "*"
        }
      ]
    }
    
  3. Save the policy as MAC-AgentSync-Policy.

  4. Go to Identity and Access Management (IAM) > Roles, and create a role.

  5. For the trusted entity type, select Custom trust policy, and enter the following policy. Replace the placeholder values with the ARN of the synchronization IAM user and your AWS Organizations ID.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {
            "AWS": "<synchronization-IAM-user-ARN>"
          },
          "Action": "sts:AssumeRole",
          "Condition": {
            "StringEquals": {
              "aws:PrincipalOrgID": "<organization-ID>"
            }
          }
        }
      ]
    }
    
  6. Attach MAC-AgentSync-Policy to the role.

  7. Save the role as MAC-CrossAccountAgentSync-Role.

  8. Repeat these steps for each target AWS account. Use the same policy and role names in every account.

Next, grant the synchronization IAM user permission to discover accounts and assume the role.

  1. Sign in to the AWS Organizations management account.

  2. Go to Identity and Access Management (IAM) > Policies, and create the following policy:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "sts:AssumeRole",
          "Resource": "arn:aws:iam::*:role/MAC-CrossAccountAgentSync-Role"
        },
        {
          "Effect": "Allow",
          "Action": "organizations:ListAccounts",
          "Resource": "*"
        }
      ]
    }
    
  3. Save the policy as MAC-AssumeToSyncAccountAgentSync-Policy.

  4. Go to Identity and Access Management (IAM) > Users, and select the IAM user whose access key is used for synchronization.

  5. Attach MAC-AssumeToSyncAccountAgentSync-Policy to the user.

You can now use the IAM user's access key to synchronize Amazon Bedrock and Amazon Bedrock AgentCore agents with the Microsoft 365 agent registry. When you configure the connection, provide the access key, the cross-account role name MAC-CrossAccountAgentSync-Role, and, optionally, the AWS account IDs to exclude from synchronization.

Collect agent activity (optional)

Activity collection is turned on by default for new connections. Collecting activity is optional, but if you don't grant the required activity permissions, Agent 365 synchronizes agents without collecting their activity.

With an organization connection, Agent 365 reads each agent's activity from the account where the agent lives by using the cross-account role. Grant that role the following activity permissions in every target account:

  • AgentCore: Grant logs:StartQuery and logs:GetQueryResults. For custom endpoints, also grant logs:DescribeLogGroups. Enable Transaction Search in each account and AWS Region.
  • Agents Classic: Grant s3:ListBucket on the activity bucket and s3:GetObject on objects in that bucket. If the bucket uses a customer-managed key, also grant kms:Decrypt on that key.

For activity setup details, see Configure Amazon Bedrock Classic activity and Configure Amazon Bedrock AgentCore activity.

Configure cross-account access by using AWS CloudFormation

The following template supports three deployment modes:

  • Target creates the synchronization policy and role in a target account.
  • Management grants an existing IAM user in the management account permission to list accounts and assume the target-account role.
  • Combined creates both sets of resources when the management account also contains agents to synchronize.

Use the following CloudFormation template:

AWSTemplateFormatVersion: '2010-09-09'
Description: >-
  Creates the IAM resources required for Microsoft Agent 365 Amazon Bedrock
  agent synchronization.

Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
      - Label:
          default: Deployment configuration
        Parameters:
          - DeploymentMode
          - OrganizationId
          - SynchronizationUserArn
          - SynchronizationIamUserName
    ParameterLabels:
      DeploymentMode:
        default: Resources to deploy in this account
      OrganizationId:
        default: AWS Organizations ID
      SynchronizationUserArn:
        default: Synchronization IAM user ARN
      SynchronizationIamUserName:
        default: Synchronization IAM user name

Parameters:
  DeploymentMode:
    Type: String
    Default: Target
    AllowedValues:
      - Target
      - Management
      - Combined
    Description: >-
      Use Target for participating member accounts, Management for the AWS
      Organizations management account, or Combined for both.

  OrganizationId:
    Type: String
    AllowedPattern: '^$|^o-[a-z0-9]{10,32}$'
    ConstraintDescription: >-
      Enter a valid AWS Organizations ID, such as o-ab12cdefgh, or leave this
      value empty for Management mode.
    Description: >-
      AWS Organizations ID used to restrict assumption of the cross-account
      role. Required for Target and Combined modes.

  SynchronizationUserArn:
    Type: String
    AllowedPattern: '^$|^arn:(aws|aws-us-gov|aws-cn):iam::[0-9]{12}:(root|user/.+|role/.+)$'
    ConstraintDescription: Enter a valid IAM user, IAM role, or account root ARN.
    Description: >-
      ARN of the management-account IAM user whose credentials perform
      synchronization. Required for Target and Combined modes.

  SynchronizationIamUserName:
    Type: String
    Default: ''
    AllowedPattern: '^$|^[A-Za-z0-9+=,.@_-]{1,64}$'
    ConstraintDescription: Enter a valid existing IAM user name.
    Description: >-
      Existing IAM user that receives the assume-role policy. Required for
      Management and Combined modes.

Rules:
  ManagementModeRequiresIamUser:
    RuleCondition:
      Fn::Or:
        - Fn::Equals: [!Ref DeploymentMode, Management]
        - Fn::Equals: [!Ref DeploymentMode, Combined]
    Assertions:
      - Assert: !Not [!Equals [!Ref SynchronizationIamUserName, '']]
        AssertDescription: >-
          SynchronizationIamUserName is required for Management and Combined
          modes.

  TargetModeRequiresIamArn:
    RuleCondition:
      Fn::Or:
        - Fn::Equals: [!Ref DeploymentMode, Target]
        - Fn::Equals: [!Ref DeploymentMode, Combined]
    Assertions:
      - Assert: !Not [!Equals [!Ref SynchronizationUserArn, '']]
        AssertDescription: >-
          SynchronizationUserArn is required for Target and Combined modes.

  TargetModeRequiresOrganizationId:
    RuleCondition:
      Fn::Or:
        - Fn::Equals: [!Ref DeploymentMode, Target]
        - Fn::Equals: [!Ref DeploymentMode, Combined]
    Assertions:
      - Assert: !Not [!Equals [!Ref OrganizationId, '']]
        AssertDescription: >-
          OrganizationId is required for Target and Combined modes.

Conditions:
  DeployTargetResources: !Or
    - !Equals [!Ref DeploymentMode, Target]
    - !Equals [!Ref DeploymentMode, Combined]
  DeployManagementResources: !Or
    - !Equals [!Ref DeploymentMode, Management]
    - !Equals [!Ref DeploymentMode, Combined]

Resources:
  MacAgentSyncPolicy:
    Type: AWS::IAM::ManagedPolicy
    Condition: DeployTargetResources
    Properties:
      ManagedPolicyName: MAC-AgentSync-Policy
      Description: >-
        Allows Microsoft Agent 365 synchronization of Amazon Bedrock agents.
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Sid: SynchronizeBedrockAgents
            Effect: Allow
            Action:
              - bedrock:ListAgents
              - bedrock:GetAgent
              - bedrock:ListAgentAliases
              - bedrock:GetAgentAlias
              - bedrock:ListAgentVersions
              - bedrock:GetAgentVersion
              - bedrock:InvokeModel
              - bedrock:InvokeAgent
              - bedrock:InvokeInlineAgent
              - bedrock:DeleteAgent
              - bedrock-agentcore:ListHarnesses
              - bedrock-agentcore:ListAgentRuntimes
              - bedrock-agentcore:ListGateways
              - bedrock-agentcore:ListGatewayTargets
              - bedrock-agentcore:GetHarness
              - bedrock-agentcore:GetAgentRuntime
              - bedrock-agentcore:GetGateway
              - bedrock-agentcore:GetGatewayTarget
              - bedrock-agentcore:GetMemory
              - bedrock-agentcore:DeleteHarness
              - bedrock-agentcore:DeleteAgentRuntime
              - bedrock-agentcore:DeleteWorkloadIdentity
              - bedrock-agentcore:DeleteAgentRuntimeEndpoint
              - bedrock-agentcore:DeleteGateway
              - bedrock-agentcore:DeleteGatewayTarget
              - bedrock-agentcore:DeleteMemory
            Resource: '*'

  MacCrossAccountAgentSyncRole:
    Type: AWS::IAM::Role
    Condition: DeployTargetResources
    Properties:
      RoleName: MAC-CrossAccountAgentSync-Role
      Description: >-
        Role assumed to synchronize Amazon Bedrock agents with Microsoft
        Agent 365.
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Sid: AllowSynchronizationUser
            Effect: Allow
            Principal:
              AWS: !Ref SynchronizationUserArn
            Action: sts:AssumeRole
            Condition:
              StringEquals:
                aws:PrincipalOrgID: !Ref OrganizationId
      ManagedPolicyArns:
        - !Ref MacAgentSyncPolicy

  MacAssumeToSyncAccountAgentSyncPolicy:
    Type: AWS::IAM::ManagedPolicy
    Condition: DeployManagementResources
    Properties:
      ManagedPolicyName: MAC-AssumeToSyncAccountAgentSync-Policy
      Description: >-
        Allows the synchronization IAM user to assume target-account roles.
      Users:
        - !Ref SynchronizationIamUserName
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Sid: AssumeAgentSyncRoles
            Effect: Allow
            Action: sts:AssumeRole
            Resource: !Sub >-
              arn:${AWS::Partition}:iam::*:role/MAC-CrossAccountAgentSync-Role
          - Sid: ListOrganizationAccounts
            Effect: Allow
            Action: organizations:ListAccounts
            Resource: '*'

Outputs:
  DeploymentMode:
    Description: Resource mode deployed by this stack instance.
    Value: !Ref DeploymentMode

  AgentSyncPolicyArn:
    Condition: DeployTargetResources
    Description: ARN of MAC-AgentSync-Policy.
    Value: !Ref MacAgentSyncPolicy

  CrossAccountAgentSyncRoleArn:
    Condition: DeployTargetResources
    Description: ARN of MAC-CrossAccountAgentSync-Role.
    Value: !GetAtt MacCrossAccountAgentSyncRole.Arn

  ManagementAssumeRolePolicyArn:
    Condition: DeployManagementResources
    Description: ARN of MAC-AssumeToSyncAccountAgentSync-Policy.
    Value: !Ref MacAssumeToSyncAccountAgentSyncPolicy

Deploy the management account resources

  1. Save the template as a YAML file.
  2. In the AWS Organizations management account, create an AWS CloudFormation stack from the template.
  3. Set DeploymentMode to Management.
  4. Set SynchronizationIamUserName to the existing IAM user whose access key is used for synchronization.
  5. Acknowledge that the template creates IAM resources with custom names, and then create the stack.

If the management account also contains agents to synchronize, use Combined mode and provide all three configuration values instead.

Deploy the target account resources

  1. In the management account, open AWS CloudFormation > StackSets, and create a StackSet from the template.
  2. Use service-managed permissions or self-managed permissions according to your organization's CloudFormation configuration.
  3. Set DeploymentMode to Target.
  4. Set OrganizationId to your AWS Organizations ID.
  5. Set SynchronizationUserArn to the ARN of the IAM user whose access key is used for synchronization.
  6. Deploy the StackSet to the accounts or organizational units that contain agents to synchronize. Choose each AWS Region in which you manage the IAM stack. IAM resources are global within an AWS account, so deploy only one stack instance per target account.
  7. Review the StackSet operation and verify that each stack instance reaches the CURRENT status.

After deployment, configure the Amazon Bedrock connection in the Microsoft 365 admin center with the synchronization IAM user's access key and the role name MAC-CrossAccountAgentSync-Role.

Create the organization connection

After you configure cross-account access manually or deploy the CloudFormation template, create the Amazon Bedrock connection in the Microsoft 365 admin center.

  1. Under Connect to, select Entire organization.
  2. Select every Region used across the organization. The selected Regions apply to all accounts.
  3. Enter the synchronization user's access key and secret.
  4. Validate the credentials.
  5. Save the connection.

Note

  • Validation only confirms that the credentials can list the accounts in the organization. If the role is missing or lacks permissions in a particular account, this condition appears in the synchronization results, such as FailedToAssumeRoleInAccount or FailedToListAgentCoreHarnesses.
  • The first synchronization can take some time for large organizations.