Using service-linked roles for Amazon Bedrock AgentCore - Amazon Bedrock AgentCore

Amazon Bedrock AgentCore is in preview release and is subject to change.

Using service-linked roles for Amazon Bedrock AgentCore

Amazon Bedrock AgentCore uses AWS Identity and Access Management (IAM) service-linked roles. A service-linked role is a unique type of IAM role that is linked directly to AgentCore. Service-linked roles are predefined by AgentCore and include all the permissions that the service requires to call other AWS services on your behalf.

A service-linked role makes using AgentCore easier because you don't have to manually add the necessary permissions. AgentCore defines the permissions of its service-linked roles, and unless defined otherwise, only AgentCore can assume its roles. The defined permissions include the trust policy and the permissions policy, and that permissions policy cannot be attached to any other IAM entity.

You can delete the roles only after first deleting their related resources. This protects your AgentCore resources because you can't inadvertently remove permission to access the resources.

AgentCore service-linked role permissions

AgentCore uses the service-linked role named AWSServiceRoleForBedrockAgentCoreNetwork to allow AgentCore to create and manage network interfaces in your VPC on your behalf.

The AWSServiceRoleForBedrockAgentCoreNetwork service-linked role trusts the following services to assume the role:

  • network.bedrock-agentcore.amazonaws.com

The role permissions policy allows AgentCore to complete the following actions on the specified resources:

You can view the complete policy at BedrockAgentCoreNetworkServiceRolePolicy. For more information about this policy, see BedrockAgentCoreNetworkServiceRolePolicy.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowCreateEniInAnySubnet", "Effect": "Allow", "Action": "ec2:CreateNetworkInterface", "Resource": "arn:aws:ec2:*:*:subnet/*" }, { "Sid": "AllowCreateEniWithSecurityGroups", "Effect": "Allow", "Action": "ec2:CreateNetworkInterface", "Resource": "arn:aws:ec2:*:*:security-group/*" }, { "Sid": "AllowCreateEniWithBedrockManagedRequestTag", "Effect": "Allow", "Action": "ec2:CreateNetworkInterface", "Resource": "arn:aws:ec2:*:*:network-interface/*", "Condition": { "ForAllValues:StringEquals": { "aws:TagKeys": [ "AmazonBedrockAgentCoreManaged" ] }, "StringEquals": { "aws:RequestTag/AmazonBedrockAgentCoreManaged": "true" } } }, { "Sid": "AllowTagEniOnCreate", "Effect": "Allow", "Action": "ec2:CreateTags", "Resource": "arn:aws:ec2:*:*:network-interface/*", "Condition": { "StringEquals": { "ec2:CreateAction": "CreateNetworkInterface" } } }, { "Sid": "AllowManageEniWhenBedrockManaged", "Effect": "Allow", "Action": [ "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses", "ec2:CreateNetworkInterfacePermission" ], "Resource": "arn:aws:ec2:*:*:network-interface/*", "Condition": { "StringEquals": { "aws:ResourceTag/AmazonBedrockAgentCoreManaged": "true" } } }, { "Sid": "AllowGetSecurityGroupsForVpc", "Effect": "Allow", "Action": [ "ec2:GetSecurityGroupsForVPC" ], "Resource": "arn:aws:ec2:*:*:vpc/*" }, { "Sid": "AllowDescribeNetworkingResources", "Effect": "Allow", "Action": [ "ec2:DescribeNetworkInterfaces", "ec2:DescribeSecurityGroups", "ec2:DescribeSubnets", "ec2:DescribeVpcs" ], "Resource": "*" } ] }

Creating a service-linked role for AgentCore

You don't need to manually create a service-linked role. When you create an AgentCore Runtime, Code Interpreter, or Browser resources with VPC configuration, AgentCore creates the service-linked role for you automatically.

If you delete this service-linked role and then need to create it again, you can use the same process to re-create the role in your account. When you create an AgentCore Runtime, Code Interpreter, or Browser resources with VPC configuration, AgentCore creates the service-linked role for you again.

Permissions required to create a service-linked role

You must configure permissions to allow an IAM entity (such as a user, group, or role) to create, edit, or delete a service-linked role. The IAM entity needs to have the following permission:

{ "Action": "iam:CreateServiceLinkedRole", "Effect": "Allow", "Resource": "arn:aws:iam::*:role/aws-service-role/network.bedrock-agentcore.amazonaws.com/AWSServiceRoleForBedrockAgentCoreNetwork", "Condition": { "StringLike": { "iam:AWSServiceName": "network.bedrock-agentcore.amazonaws.com" } } }

This permission is already included in the AWS managed policy BedrockAgentCoreFullAccess.

Editing a service-linked role for AgentCore

AgentCore does not allow you to edit the AWSServiceRoleForBedrockAgentCoreNetwork service-linked role. After you create a service-linked role, you cannot change the name of the role because various entities might reference the role. However, you can edit the description of the role using IAM. For more information, see Editing a service-linked role.

Deleting a service-linked role for AgentCore

If you no longer need to use a feature or service that requires a service-linked role, we recommend that you delete that role. That way you don't have an unused entity that is not actively monitored or maintained. However, you must delete all your AgentCore Runtime, Code Interpreter, and Browser resources with VPC configuration before you can delete the service-linked role.

Cleaning up a service-linked role

Before you can use IAM to delete a service-linked role, you must first confirm that the role has no active sessions and remove any resources used by the role.

To check whether the service-linked role has an active session in the IAM console

  1. Sign in to the and open the IAM console at https://console.aws.amazon.com/iam/.

  2. In the navigation pane of the IAM console, choose Roles, and then choose the name (not the check box) of the AWSServiceRoleForBedrockAgentCoreNetwork role.

  3. On the Summary page for the selected role, choose the Access Advisor tab.

  4. On the Access Advisor tab, review the recent activity for the service-linked role.

Note

If you are unsure whether AgentCore is using the AWSServiceRoleForBedrockAgentCoreNetwork role, you can try to delete the role. If the service is using the role, then the deletion fails and you can view the Regions where the role is being used. If the role is being used, then you must wait for the session to end before you can delete the role. You cannot revoke the session for a service-linked role.

If you want to remove the AWSServiceRoleForBedrockAgentCoreNetwork role, you must first delete all your AgentCore Runtime, Code Interpreter, and Browser resources with VPC configuration.

Manually delete the service-linked role

Use the IAM console, the AWS CLI, or the IAM API to delete the AWSServiceRoleForBedrockAgentCoreNetwork service-linked role. For more information, see Deleting a service-linked role.