Skip to content

bedrock-agentcore: use IUserPool and IUserPoolClient interfaces instead of string identifiers #35854

@mazyu36

Description

@mazyu36

Describe the feature

The current RuntimeAuthorizerConfiguration.usingCognito() method in agentcore requires string identifiers (User Pool ID and Client ID) to be passed as parameters.

AWS CDK best practices emphasize passing construct interfaces rather than string identifiers, which provides better type safety and a more intuitive developer experience.

Additionally, the region parameter is redundant since it can be automatically derived from the stack's environment (env.region).

Current Implementation:

authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingCognito(
  "us-west-2_ABC123",  // User Pool ID (string)
  "client123",         // Client ID (string)
  "us-west-2"         // Region (optional, string) - redundant!
)

Use Case

When use AgentCore Runtime with Cognito UserPool and UserPoolClient.

Proposed Solution

Modify RuntimeAuthorizerConfiguration.usingCognito() to:

  1. Accept IUserPool and IUserPoolClient interfaces instead of strings for better type safety and DX
  2. Remove the region parameter entirely and automatically use the stack's env.region

Proposed Implementation:

import * as cognito from 'aws-cdk-lib/aws-cognito';

declare const userPool: new cognito.UserPool;
declare const userPoolClient: cognito.UserPoolClient;

const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
  runtimeName: "myAgent",
  agentRuntimeArtifact: agentRuntimeArtifact,
  authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingCognito(
    userPool,  // IUserPool interface
    userClient     // IUserPoolClient interface
    // region automatically resolved from stack.env.region
  ),
});

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS CDK Library version (aws-cdk-lib)

2.221.0

AWS CDK CLI version

all

Environment details (OS name and version, etc.)

all

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cognitoRelated to Amazon Cognitoeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions