Skip to content

bedrock-agentcore: custom execution role policy for runtime lacks proper permissions #35852

@go-to-k

Description

@go-to-k

Describe the bug

ECR permissions are attached even when the role is a custom role (or an imported role). (https://github.com/aws/aws-cdk/blob/v2.221.0/packages/%40aws-cdk/aws-bedrock-agentcore-alpha/agentcore/runtime/runtime-artifact.ts#L65)

However, the other required permissions are only granted to a policy for an auto-generated role. (https://github.com/aws/aws-cdk/blob/v2.221.0/packages/%40aws-cdk/aws-bedrock-agentcore-alpha/agentcore/runtime/runtime.ts#L252-L259)

In constructs of other common modules, permissions are attached even when a custom role is passed.

So we need to add the permissions to the custom role.

FYI: If you avoid to add the permissions to the custom role, you can use withoutPolicyUpdates() method for Role.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

The same permissions are attached to the custom role as to the auto-generated role.

Current Behavior

Permissions other than ECR are not granted to the custom role.

Reproduction Steps

Deploy the following CDK code:

const app = new cdk.App();
const stack = new cdk.Stack(app, 'stack');

const runtimeArtifact = agentcore.AgentRuntimeArtifact.fromAsset(
  path.join(__dirname, 'testArtifact'),
);

const role = new iam.Role(stack, 'ExecutionRole', {
  assumedBy: new iam.ServicePrincipal('bedrock-agentcore.amazonaws.com'),
});

const runtime = new agentcore.Runtime(stack, 'Runtime', {
  runtimeName: 'integ_test_runtime',
  agentRuntimeArtifact: runtimeArtifact,
  executionRole: role,
});

And then you can see the permissions in the console or cdk.out.

FYI: correct permissions: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-permissions.html#runtime-permissions-execution

Possible Solution

Add the same permissions to the custom role.

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

v2.221.0

AWS CDK CLI version

2.1030.0

Node.js Version

v22.14.0

OS

Mac

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-iamRelated to AWS Identity and Access ManagementbugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions