Skip to content
Open
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
9605217
feat(agentcore): added runtime and endpoint
Sep 29, 2025
356c42d
feat(runtime): added integ test
Sep 29, 2025
b124520
feat(runtime): added integ test
Sep 29, 2025
cfad025
feat(runtime): updated integ test and readme
Sep 29, 2025
a4cd8b7
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Sep 29, 2025
910cf05
feat(runtime): adding integ snapshot and documentation
Sep 30, 2025
7a306af
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Sep 30, 2025
778e5b0
feat(runtime): updated doc to fix rosetta build issue
Sep 30, 2025
bae6962
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Sep 30, 2025
e301efd
feat(runtime): updated docs for auth and fix issue in runtime
Sep 30, 2025
150b222
feat(runtime): updated docs for auth and fix issue in runtime
Sep 30, 2025
ea39263
feat(runtime): review comments implemented
Oct 6, 2025
a4a2ccf
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Oct 6, 2025
0062054
feat(runtime): updated docs
Oct 6, 2025
d20e5a3
Merge branch 'main' into agentcore-runtime
dineshSajwan Oct 6, 2025
4b87383
feat(runtime): removed unwanted method
Oct 7, 2025
8b227b8
Merge branch 'main' into agentcore-runtime
dineshSajwan Oct 7, 2025
f48b7bf
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Oct 9, 2025
3c058da
feat(runtime): added review comments and fixed integ test
Oct 9, 2025
13ffd1d
feat(agentcore): removed unwanted params from oauth
Oct 9, 2025
a74054f
feat(agentcore): updated runtime
Oct 9, 2025
7f541d5
feat(agentcore): updated runtime with connection object
Oct 9, 2025
2e18add
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Oct 10, 2025
2bd3112
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Oct 10, 2025
f724588
feat(runtime): updated test cases
Oct 10, 2025
bab3f14
feat(agenctcore): added vpcconfig for runtime
Oct 10, 2025
028bbaa
Merge branch 'main' into agentcore-runtime
dineshSajwan Oct 10, 2025
8f1e9bb
feat(agenctcore): updated test with test account
Oct 10, 2025
7a69a05
Merge branch 'agentcore-runtime' of https://github.com/dineshSajwan/a…
Oct 10, 2025
3ac39ab
feat(agenctcore): runtime review comment and new policy
Oct 14, 2025
59548d1
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Oct 14, 2025
400f950
Merge branch 'main' into agentcore-runtime
dineshSajwan Oct 14, 2025
78e18c1
feat(agenctcore): updated docs
Oct 15, 2025
4ed2f90
Merge branch 'agentcore-runtime' of https://github.com/dineshSajwan/a…
Oct 15, 2025
aeabbb7
feat(runtime): new snapshots
Oct 15, 2025
ee3a551
feat(runtime): updated runtime versioning
Oct 15, 2025
d0f8593
Merge branch 'aws:main' into agentcore-runtime
dineshSajwan Oct 15, 2025
a1d0028
Merge branch 'agentcore-runtime' of https://github.com/dineshSajwan/a…
Oct 15, 2025
0be30ac
feat(agentcore): added gateway and target
Oct 17, 2025
7422eb5
Merge branch 'aws:main' into agentcore-gateway
dineshSajwan Oct 17, 2025
220c92a
feat(agentcore): added gatewy and target integ test
Oct 17, 2025
cf415e0
feat(agentcore): mreged the code for gateway
Oct 17, 2025
b9307cf
Merge branch 'main' into agentcore-gateway
dineshSajwan Oct 17, 2025
f307d28
Merge branch 'aws:main' into agentcore-gateway
dineshSajwan Oct 20, 2025
48b815e
Merge branch 'aws:main' into agentcore-gateway
dineshSajwan Oct 21, 2025
8025c75
feat(agentcore): added permission to gateway
Oct 21, 2025
5fd0dae
Merge branch 'main' into agentcore-gateway
dineshSajwan Oct 21, 2025
f162585
feat(agentcore): merge with main
Oct 21, 2025
0bccf0e
Merge branch 'main' into agentcore-gateway
dineshSajwan Oct 22, 2025
2e586c7
feat(agentcore): updated gateway docs and kms permission
Oct 22, 2025
07d6e91
Merge branch 'agentcore-gateway' of https://github.com/dineshSajwan/a…
Oct 22, 2025
f1955ba
feat(agentcore): gateway rfc review comments
Oct 27, 2025
4701e39
feat(agentcore): gateway merge with main
Oct 28, 2025
08f1095
feat(agentcore): added validation for openapi schema gateway
Oct 29, 2025
08d9a42
Merge branch 'main' into agentcore-gateway
dineshSajwan Oct 29, 2025
4cd4d17
feat(agentcore): updated naming for apischema
Oct 29, 2025
9e329f7
chore(gateway): removed vulnerability
Oct 31, 2025
c5dcc8e
chore(gateway): updated readme, target config
Nov 3, 2025
eba7935
Merge branch 'aws:main' into agentcore-gateway
dineshSajwan Nov 3, 2025
3494acb
Merge branch 'agentcore-gateway' of https://github.com/dineshSajwan/a…
Nov 3, 2025
ec8526f
chore(gateway): updated readme
Nov 3, 2025
61600d9
chor(gateway): updated jsdocs
Nov 5, 2025
6cc7adc
Merge branch 'aws:main' into agentcore-gateway
dineshSajwan Nov 5, 2025
34e308c
Merge branch 'agentcore-gateway' of https://github.com/dineshSajwan/a…
Nov 5, 2025
7ffebdf
chore(gateway): removed marker interfaces
Nov 7, 2025
ab59ad0
Merge branch 'aws:main' into agentcore-gateway
dineshSajwan Nov 7, 2025
53e4f05
chore(gateway): removed marker interfaces
Nov 7, 2025
68744a3
chore(gateway): fixed integ test
Nov 7, 2025
039c4aa
Merge branch 'aws:main' into agentcore-gateway
dineshSajwan Nov 12, 2025
fae1b1a
Merge branch 'aws:main' into agentcore-gateway
dineshSajwan Nov 12, 2025
5ef288d
chore(agentcore): impleemented review comments for gateway
Nov 12, 2025
f5defab
Merge branch 'agentcore-gateway' of https://github.com/dineshSajwan/a…
Nov 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
663 changes: 663 additions & 0 deletions packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import { IUserPoolClient, IUserPool } from 'aws-cdk-lib/aws-cognito';
import { ValidationError } from '../validation-helpers';

/******************************************************************************
* Authorizer Configuration
*****************************************************************************/

/**
* Gateway authorizer type
*/
export enum GatewayAuthorizerType {
/** Custom JWT authorizer type */
CUSTOM_JWT = 'CUSTOM_JWT',
/** AWS IAM authorizer type */
AWS_IAM = 'AWS_IAM',
}

/**
* Abstract interface for gateway authorizer configuration
*/
export interface IGatewayAuthorizerConfig {
/**
* The authorizer type
*/
readonly authorizerType: GatewayAuthorizerType;

/**
* The authorizer configuration in CFN format
* @internal
*/
_render(): any;
}

/******************************************************************************
* Custom JWT
*****************************************************************************/
/**
* Custom JWT authorizer configuration
*/
export interface CustomJwtConfiguration {
/**
* This URL is used to fetch OpenID Connect configuration or authorization server metadata
* for validating incoming tokens.
*
* Pattern: .+/\.well-known/openid-configuration
* Required: Yes
*/
readonly discoveryUrl: string;

/**
* Represents individual audience values that are validated in the incoming JWT token validation process. *
* @default - No audience validation
*/
readonly allowedAudience?: string[];

/**
* Represents individual client IDs that are validated in the incoming JWT token validation process. *
* @default - No client ID validation
*/
readonly allowedClients?: string[];
}

/**
* Custom JWT authorizer configuration implementation
*/
export class CustomJwtAuthorizer implements IGatewayAuthorizerConfig {
/**
* Create a JWT authorizer from Cognito User Pool
* @param props - The Cognito configuration
* @returns CustomJwtAuthorizer configured for Cognito
*/
public static fromCognito(props: CognitoAuthorizerProps) {
// Construct the discovery URL from the User Pool properties
const discoveryUrl = `https://cognito-idp.${props.userPool.env.region}.amazonaws.com/${props.userPool.userPoolId}/.well-known/openid-configuration`;

return new CustomJwtAuthorizer({
discoveryUrl: discoveryUrl,
allowedClients: props.allowedClients?.flatMap((client) => client.userPoolClientId),
allowedAudience: props.allowedAudiences,
});
}

public readonly authorizerType = GatewayAuthorizerType.CUSTOM_JWT;
private readonly discoveryUrl: string;
private readonly allowedAudience?: string[];
private readonly allowedClients?: string[];

constructor(config: CustomJwtConfiguration) {
this.discoveryUrl = config.discoveryUrl;
this.allowedAudience = config.allowedAudience;
this.allowedClients = config.allowedClients;
}

/**
* @internal
*/
public _render(): any {
return {
customJwtAuthorizer: {
discoveryUrl: this.discoveryUrl,
...(this.allowedAudience && { allowedAudience: this.allowedAudience }),
...(this.allowedClients && { allowedClients: this.allowedClients }),
},
};
}
}

/******************************************************************************
* AWS IAM
*****************************************************************************/

/**
* AWS IAM authorizer configuration implementation
*
*/
export class IamAuthorizer implements IGatewayAuthorizerConfig {
public readonly authorizerType = GatewayAuthorizerType.AWS_IAM;

/**
* @internal
*/
_render(): any {
// AWS IAM authorizer doesn't need additional configuration
// Return null or undefined to indicate no configuration needed
return undefined;
}
}

/******************************************************************************
* Factory
*****************************************************************************/

export interface CognitoAuthorizerProps {
/**
* The Cognito User Pool to use for authentication
*/
readonly userPool: IUserPool;
/**
* The allowed User Pool clients
* @default - All clients are allowed
*/
readonly allowedClients?: IUserPoolClient[];
/**
* The allowed audiences for JWT validation
* @default - No audience validation
*/
readonly allowedAudiences?: string[];
}
/**
* Factory class for creating Gateway Authorizers
*/
export abstract class GatewayAuthorizer {
/**
* AWS IAM authorizer instance
*/
public static awsIam = new IamAuthorizer();

/**
* Create a custom JWT authorizer
* @param configuration - The JWT configuration
* @returns IGatewayAuthorizerConfig configured for custom JWT
*/
public static usingCustomJwt(configuration: CustomJwtConfiguration): IGatewayAuthorizerConfig {
// At least one of allowedAudience or allowedClients must be defined for CUSTOM_JWT authorizer
if (!configuration.allowedAudience && !configuration.allowedClients) {
throw new ValidationError('At least one of allowedAudience or allowedClients must be defined for CUSTOM_JWT authorizer');
}
return new CustomJwtAuthorizer(configuration);
}

/**
* Static method for creating a Cognito authorizer
*/
public static usingCognito(props: CognitoAuthorizerProps): IGatewayAuthorizerConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we need to redirect call from one public static function to another. We can directly use the this one and shift the logic here to ensure consistency in code design

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. Didn't updated the old code. removed fromCognito and directly using usingCognito

return CustomJwtAuthorizer.fromCognito(props);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import { Grant, IRole, PolicyStatement } from 'aws-cdk-lib/aws-iam';
import { CredentialProviderType, ICredentialProvider } from './credential-provider';
import { GatewayPerms } from '../perms';

/******************************************************************************
* API KEY
*****************************************************************************/
/**
* API Key additional configuration
*/
export interface ApiKeyAdditionalConfiguration {

/**
* The name of the credential parameter for the API key.
* This parameter name is used when sending the API key to the target endpoint.
*
* Length Constraints: Minimum length of 1. Maximum length of 64.
* @default - 'Authorization' for HEADER, 'api_key' for QUERY_PARAMETER
*/
readonly credentialParameterName?: string;

/**
* The prefix for the API key credential.
* This prefix is added to the API key when sending it to the target endpoint.
*
* Length Constraints: Minimum length of 1. Maximum length of 64.
* @default - 'Bearer ' for HEADER, no prefix for QUERY_PARAMETER
*/
readonly credentialPrefix?: string;
}

/**
* API Key credential location type
* @internal
*/
export enum ApiKeyCredentialLocationType {
HEADER = 'HEADER',
QUERY_PARAMETER = 'QUERY_PARAMETER',
}

/**
* API Key location within the request
*/
export class ApiKeyCredentialLocation {
/**
* Create a header-based API key credential location
* @param config - Optional configuration for the credential location
* @returns ApiKeyCredentialLocation configured for header placement
*/
public static header(config?: ApiKeyAdditionalConfiguration) {
return new ApiKeyCredentialLocation(
ApiKeyCredentialLocationType.HEADER,
config?.credentialParameterName ?? 'Authorization',
config?.credentialPrefix ?? 'Bearer ',
);
}

/**
* Create a query parameter-based API key credential location
* @param config - Optional configuration for the credential location
* @returns ApiKeyCredentialLocation configured for query parameter placement
*/
public static queryParameter(config?: ApiKeyAdditionalConfiguration) {
return new ApiKeyCredentialLocation(
ApiKeyCredentialLocationType.QUERY_PARAMETER,
config?.credentialParameterName ?? 'api_key',
config?.credentialPrefix,
);
}

/**
* The name of the credential parameter
*/
public readonly credentialParameterName: string;
/**
* The prefix for the credential value
*/
public readonly credentialPrefix?: string;
/**
* The type of credential location (HEADER or QUERY_PARAMETER)
*/
public readonly credentialLocationType: string;

private constructor(
credentialLocationType: string,
credentialParameterName: string,
credentialPrefix?: string,
) {
this.credentialLocationType = credentialLocationType;
this.credentialParameterName = credentialParameterName;
this.credentialPrefix = credentialPrefix;
}
}

/**
* API Key configuration
*/
export interface ApiKeyCredentialProviderProps {
/**
* The API key credential provider ARN.
* This is returned when creating the API key credential provider via Console or API.
* Format: arn:aws:bedrock-agentcore:region:account:token-vault/id/apikeycredentialprovider/name
*/
readonly providerArn: string;

/**
* The ARN of the Secrets Manager secret containing the API key.
* This is returned when creating the API key credential provider via Console or API.
* Format: arn:aws:secretsmanager:region:account:secret:name
*/
readonly secretArn: string;

/**
* The location of the API key credential.
* This field specifies where in the request the API key should be placed.
*
* @default - HEADER
*/
readonly credentialLocation?: ApiKeyCredentialLocation;
}

/**
* API Key credential provider configuration implementation
* Can be used with OpenAPI targets
*/
export class ApiKeyCredentialProviderConfiguration implements ICredentialProvider {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is just a configuration or is it a credential provider ?

If it is provider then let's not add config to the class names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a configuration hence updating the interface ICredentialProvider to ICredentialProviderConfig

public readonly credentialProviderType = CredentialProviderType.API_KEY;
/**
* The ARN of the API key provider
*/
public readonly providerArn: string;
/**
* The ARN of the Secrets Manager secret
*/
public readonly secretArn: string;
/**
* The location configuration for the API key credential
*/
public readonly credentialLocation: ApiKeyCredentialLocation;

constructor(configuration: ApiKeyCredentialProviderProps) {
this.providerArn = configuration.providerArn;
this.secretArn = configuration.secretArn;
this.credentialLocation = configuration.credentialLocation ?? ApiKeyCredentialLocation.header();
}

/**
* Grant the needed permissions to the role for API key authentication
*/
grantNeededPermissionsToRole(role: IRole): Grant | undefined {
const statements = [
new PolicyStatement({
actions: [
...GatewayPerms.GATEWAY_API_KEY_PERMS,
...GatewayPerms.GATEWAY_WORKLOAD_IDENTITY_PERMS,
],
resources: [this.providerArn],
}),
new PolicyStatement({
actions: GatewayPerms.SECRETS_PERMS,
resources: [this.secretArn],
}),
];

return Grant.addToPrincipal({
grantee: role,
actions: statements.flatMap(s => s.actions),
resourceArns: statements.flatMap(s => s.resources),
});
}

/**
* @internal
*/
_render(): any {
return {
credentialProviderType: this.credentialProviderType,
credentialProvider: {
apiKeyCredentialProvider: {
providerArn: this.providerArn,
credentialLocation: this.credentialLocation.credentialLocationType,
credentialParameterName: this.credentialLocation.credentialParameterName,
credentialPrefix: this.credentialLocation.credentialPrefix,
},
},
};
}
}
Loading
Loading