diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md index be41167d0beee..dd64d042cdcbe 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md @@ -2520,3 +2520,65 @@ const memory = new agentcore.Memory(this, "test-memory", { memory.addMemoryStrategy(agentcore.MemoryStrategy.usingBuiltInSummarization()); memory.addMemoryStrategy(agentcore.MemoryStrategy.usingBuiltInSemantic()); ``` + +### Memory with Stream Delivery + +You can configure stream delivery resources to enable real-time push-based streaming of memory record lifecycle events (created, updated, deleted) to Amazon Kinesis Data Streams. This allows you to react to memory changes in real-time, build event-driven architectures, or feed memory events into downstream analytics pipelines. + +```typescript fixture=default +// Create a Kinesis Data Stream +const stream = new kinesis.Stream(this, 'MemoryEventStream', { + streamName: 'memory-events', +}); + +// Create a memory with stream delivery (defaults to MEMORY_RECORDS + FULL_CONTENT) +const memory = new agentcore.Memory(this, 'MemoryWithStreamDelivery', { + memoryName: 'memory_with_stream', + description: 'Memory with Kinesis stream delivery', + expirationDuration: cdk.Duration.days(90), + streamDeliveryResources: [{ stream }], +}); +``` + +To customize the content level, specify `contentConfigurations` explicitly: + +```typescript fixture=default +const stream = new kinesis.Stream(this, 'MemoryEventStream'); + +const memory = new agentcore.Memory(this, 'MemoryWithStreamDelivery', { + memoryName: 'memory_with_stream', + streamDeliveryResources: [ + { + stream, + contentConfigurations: [ + { + type: agentcore.StreamDeliveryContentType.MEMORY_RECORDS, + level: agentcore.StreamDeliveryContentLevel.METADATA_ONLY, + }, + ], + }, + ], +}); +``` + +You can also add stream delivery resources after instantiation using the `addStreamDeliveryResource()` method: + +```typescript fixture=default +const memory = new agentcore.Memory(this, 'MyMemory', { + memoryName: 'my_memory', +}); + +const stream = new kinesis.Stream(this, 'EventStream'); + +memory.addStreamDeliveryResource({ + stream: stream, + contentConfigurations: [ + { + type: agentcore.StreamDeliveryContentType.MEMORY_RECORDS, + level: agentcore.StreamDeliveryContentLevel.METADATA_ONLY, + }, + ], +}); +``` + +The memory execution role is automatically granted write permissions (`kinesis:PutRecord`, `kinesis:PutRecords`, `kinesis:ListShards`, `kinesis:DescribeStream`) to each configured Kinesis stream. If the stream uses a customer-managed KMS key, encryption permissions are also granted automatically. diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/memory/memory.ts b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/memory/memory.ts index 02d1155bc5bf0..3c2bd83403407 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/memory/memory.ts +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/memory/memory.ts @@ -25,7 +25,10 @@ import { Stats, } from 'aws-cdk-lib/aws-cloudwatch'; import * as iam from 'aws-cdk-lib/aws-iam'; +import type * as kinesis from 'aws-cdk-lib/aws-kinesis'; import * as kms from 'aws-cdk-lib/aws-kms'; +import { ValidationError } from 'aws-cdk-lib/core/lib/errors'; +import { lit } from 'aws-cdk-lib/core/lib/helpers-internal'; import { addConstructMetadata, MethodMetadata } from 'aws-cdk-lib/core/lib/metadata-resource'; import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable'; import type { IConstruct, Construct } from 'constructs'; @@ -72,6 +75,66 @@ const MEMORY_EXPIRATION_DAYS_MIN = 7; */ const MEMORY_EXPIRATION_DAYS_MAX = 365; +/****************************************************************************** + * Stream Delivery Types + *****************************************************************************/ +/** + * Content type for stream delivery. + * Defines what kind of memory content is delivered to the Kinesis stream. + */ +export enum StreamDeliveryContentType { + /** Deliver memory record lifecycle events (created, updated, deleted) */ + MEMORY_RECORDS = 'MEMORY_RECORDS', +} + +/** + * Content detail level for stream delivery. + * Controls how much detail is included in each delivered record. + */ +export enum StreamDeliveryContentLevel { + /** Deliver only metadata (record ID, timestamps, event type) */ + METADATA_ONLY = 'METADATA_ONLY', + /** Deliver full content including the memory record body */ + FULL_CONTENT = 'FULL_CONTENT', +} + +/** + * Content configuration for a stream delivery resource. + * Defines what content type and detail level to deliver. + */ +export interface StreamDeliveryContentConfiguration { + /** + * The type of content to deliver. + */ + readonly type: StreamDeliveryContentType; + /** + * The level of content detail to deliver. + * + * @default StreamDeliveryContentLevel.FULL_CONTENT + */ + readonly level?: StreamDeliveryContentLevel; +} + +/** + * Configuration for a Kinesis stream delivery resource. + * Defines a Kinesis Data Stream target and what content to deliver to it. + * + * @see https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/memory-record-streaming.html + */ +export interface StreamDeliveryResource { + /** + * The Kinesis Data Stream to deliver memory record events to. + */ + readonly stream: kinesis.IStream; + /** + * Content configurations defining what to deliver. + * Currently only one configuration is supported. + * + * @default - [{ type: MEMORY_RECORDS, level: FULL_CONTENT }] + */ + readonly contentConfigurations?: StreamDeliveryContentConfiguration[]; +} + /****************************************************************************** * Interface *****************************************************************************/ @@ -519,6 +582,18 @@ export interface MemoryProps { * @default - no tags */ readonly tags?: { [key: string]: string }; + + /** + * Stream delivery resources for real-time push-based streaming of memory + * record lifecycle events (created, updated, deleted) to Amazon Kinesis Data Streams. + * + * The memory execution role will automatically be granted write permissions to each stream. + * Currently only one stream delivery resource is supported. + * + * @default - No stream delivery (events are not pushed to Kinesis) + * @see https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/memory-record-streaming.html + */ + readonly streamDeliveryResources?: StreamDeliveryResource[]; } /****************************************************************************** @@ -675,6 +750,11 @@ export class Memory extends MemoryBase { * @attribute */ public readonly memoryStrategies: IMemoryStrategy[] = []; + /** + * The stream delivery resources configured for this memory. + * @attribute + */ + public readonly streamDeliveryResources: StreamDeliveryResource[] = []; // ------------------------------------------------------ // Internal Only // ------------------------------------------------------ @@ -746,6 +826,10 @@ export class Memory extends MemoryBase { encryptionKeyArn: this.kmsKey?.keyArn, memoryExecutionRoleArn: this.executionRole?.roleArn, memoryStrategies: Lazy.any({ produce: () => this._renderMemoryStrategies() }, { omitEmptyArray: true }), + streamDeliveryResources: Lazy.any( + { produce: () => this._renderStreamDeliveryResources() }, + { omitEmptyArray: true }, + ), tags: this.tags, }; @@ -763,6 +847,9 @@ export class Memory extends MemoryBase { // Add memory strategies to the memory for (const strategy of props?.memoryStrategies ?? []) {this.addMemoryStrategy(strategy);} + + // Add stream delivery resources to the memory + for (const resource of props?.streamDeliveryResources ?? []) {this.addStreamDeliveryResource(resource);} } // ------------------------------------------------------ @@ -782,6 +869,46 @@ export class Memory extends MemoryBase { grant?.applyBefore(this.__resource); } + /** + * Add a stream delivery resource to the memory. + * Grants Kinesis write permissions to the execution role automatically. + * + * @param resource - The stream delivery resource configuration + * @see https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/memory-record-streaming.html + */ + @MethodMetadata() + public addStreamDeliveryResource(resource: StreamDeliveryResource): void { + // Validate current limit: at most 1 stream delivery resource + if (this.streamDeliveryResources.length >= 1) { + throw new ValidationError( + lit`TooManyStreamDeliveryResources`, + 'Memory currently supports at most one stream delivery resource', + this, + ); + } + + // Validate content configurations + throwIfInvalid(this._validateStreamDeliveryResource, resource); + + // Add to internal array + this.streamDeliveryResources.push(resource); + + // Grant Kinesis write permissions to the execution role + // stream.grantWrite() grants: kinesis:ListShards, kinesis:PutRecord, kinesis:PutRecords + // It also handles KMS encryption key permissions automatically if the stream is encrypted + const grant = resource.stream.grantWrite(this.executionRole as iam.IRole); + + // AgentCore also requires kinesis:DescribeStream which is not included in grantWrite() + const describeGrant = iam.Grant.addToPrincipal({ + grantee: this.executionRole as iam.IRole, + actions: ['kinesis:DescribeStream'], + resourceArns: [resource.stream.streamArn], + }); + + grant.applyBefore(this.__resource); + describeGrant.applyBefore(this.__resource); + } + /** * Creates execution role needed for the memory to access AWS services * @returns The created role @@ -880,6 +1007,25 @@ export class Memory extends MemoryBase { return errors; }; + /** + * Validates a stream delivery resource configuration. + * Currently CloudFormation limits contentConfigurations to exactly 1 entry + * and streamDeliveryResources to at most 1 entry. + */ + private _validateStreamDeliveryResource = (resource: StreamDeliveryResource): string[] => { + const errors: string[] = []; + + if (resource.contentConfigurations && resource.contentConfigurations.length === 0) { + errors.push('Stream delivery resource contentConfigurations must not be an empty array. Omit the property to use defaults, or provide at least one configuration'); + } + + if (resource.contentConfigurations && resource.contentConfigurations.length > 1) { + errors.push('Stream delivery resource currently supports at most one content configuration'); + } + + return errors; + }; + // ------------------------------------------------------ // RENDERERS // ------------------------------------------------------ @@ -897,4 +1043,32 @@ export class Memory extends MemoryBase { return this.memoryStrategies.map(ms => ms.render()); } + + /** + * Render the stream delivery resources into CloudFormation format. + * + * @returns StreamDeliveryResourcesProperty or undefined if no resources configured + * @internal This is an internal core function and should not be called directly. + */ + private _renderStreamDeliveryResources(): CfnMemory.StreamDeliveryResourcesProperty | undefined { + if (!this.streamDeliveryResources || this.streamDeliveryResources.length === 0) { + return undefined; + } + + const defaultContentConfigurations: StreamDeliveryContentConfiguration[] = [ + { type: StreamDeliveryContentType.MEMORY_RECORDS, level: StreamDeliveryContentLevel.FULL_CONTENT }, + ]; + + return { + resources: this.streamDeliveryResources.map(resource => ({ + kinesis: { + dataStreamArn: resource.stream.streamArn, + contentConfigurations: (resource.contentConfigurations ?? defaultContentConfigurations).map(config => ({ + type: config.type, + level: config.level, + })), + }, + })), + }; + } } diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/package.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/package.json index c9673a29e3f9b..d764732a7304d 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/package.json +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/package.json @@ -148,6 +148,7 @@ "prefer-ref-interface:@aws-cdk/aws-bedrock-agentcore-alpha.ITargetConfiguration.bind.gateway", "prefer-ref-interface:@aws-cdk/aws-bedrock-agentcore-alpha.MemoryProps.executionRole", "prefer-ref-interface:@aws-cdk/aws-bedrock-agentcore-alpha.MemoryProps.kmsKey", + "prefer-ref-interface:@aws-cdk/aws-bedrock-agentcore-alpha.StreamDeliveryResource.stream", "prefer-ref-interface:@aws-cdk/aws-bedrock-agentcore-alpha.AgentRuntimeAttributes.securityGroups", "prefer-ref-interface:@aws-cdk/aws-bedrock-agentcore-alpha.RuntimeProps.executionRole", "interface-extends-ref:@aws-cdk/aws-bedrock-agentcore-alpha.IBedrockAgentRuntime", diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/rosetta/default.ts-fixture index e73304b4e2ad3..a5e8ba7b6c14a 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/rosetta/default.ts-fixture +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/rosetta/default.ts-fixture @@ -8,6 +8,7 @@ import * as iam from 'aws-cdk-lib/aws-iam'; import * as s3 from 'aws-cdk-lib/aws-s3'; import * as sns from 'aws-cdk-lib/aws-sns'; import * as kms from 'aws-cdk-lib/aws-kms'; +import * as kinesis from 'aws-cdk-lib/aws-kinesis'; import * as ecr from 'aws-cdk-lib/aws-ecr'; import * as ec2 from 'aws-cdk-lib/aws-ec2'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.assets.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.assets.json index 2a921c7283da4..7cad55fca9422 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.assets.json +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.assets.json @@ -1,5 +1,5 @@ { - "version": "48.0.0", + "version": "53.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "displayName": "BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC Template", diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.metadata.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.metadata.json new file mode 100644 index 0000000000000..ce08e78785c24 --- /dev/null +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.metadata.json @@ -0,0 +1,14 @@ +{ + "/BedrockAgentCoreMemory/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/BedrockAgentCoreMemory/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.assets.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.assets.json index 203bb5b4db2ba..2f014db90fc50 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.assets.json +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.assets.json @@ -1,5 +1,5 @@ { - "version": "48.0.0", + "version": "53.0.0", "files": { "44e9c4d7a5d3fd2d677e1a7e416b2b56f6b0104bd5eff9cac5557b4c65a9dc61": { "displayName": "aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider Code", @@ -15,16 +15,16 @@ } } }, - "8fcac4b2ff5dc797f588c28fc2fd390666d6191922b9d5ca5129dbeaeb4e75ee": { + "e6b479d88ba23e0f8b246fb19424e4bacae68ef3d86d49604f68f6facac1393c": { "displayName": "aws-cdk-bedrock-agentcore-memory-1 Template", "source": { "path": "aws-cdk-bedrock-agentcore-memory-1.template.json", "packaging": "file" }, "destinations": { - "current_account-current_region-0a654903": { + "current_account-current_region-c988651d": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "8fcac4b2ff5dc797f588c28fc2fd390666d6191922b9d5ca5129dbeaeb4e75ee.json", + "objectKey": "e6b479d88ba23e0f8b246fb19424e4bacae68ef3d86d49604f68f6facac1393c.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.metadata.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.metadata.json new file mode 100644 index 0000000000000..c950ef0818b53 --- /dev/null +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.metadata.json @@ -0,0 +1,650 @@ +{ + "/aws-cdk-bedrock-agentcore-memory-1/Memory": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MyEncryptionKey": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "removalPolicy": "destroy", + "autoDeleteObjects": true + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider": [ + { + "type": "aws:cdk:is-custom-resource-handler-customResourceProvider", + "data": true + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryTopic": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryEventStream": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "encryption": "MANAGED", + "removalPolicy": "destroy" + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/Memory/ServiceRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + } + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/Memory/Memory": [ + { + "type": "aws:cdk:logicalId", + "data": "Memory3232ACAB" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MyEncryptionKey/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyEncryptionKeyD795679F" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + } + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachInlinePolicy": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachInlinePolicy": [ + "*" + ] + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/Memory": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithBuiltinStrategiesMemory25697FD7" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + } + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachInlinePolicy": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachInlinePolicy": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/Memory": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithCustomStrategiesMemoryFBD56D7A" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryBucket34BAD4CD" + }, + { + "type": "aws:cdk:analytics:mixin", + "data": { + "mixin": "aws-cdk-lib.aws_s3.mixins.BucketAutoDeleteObjects" + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Policy": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "bucket": "*" + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/AutoDeleteObjectsCustomResource": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Role": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryTopic/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryTopic5EB6DDE2" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + } + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachInlinePolicy": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachInlinePolicy": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/Memory": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithSelfManagedStrategyMemory927C030F" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/ServiceRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + } + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/Memory": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithBuiltinEpisodicExMemory4F42AC13" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryEventStream/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryEventStream982A05ED" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/ServiceRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + } + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachInlinePolicy": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachInlinePolicy": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToPrincipalPolicy": [ + {} + ] + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/Memory": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithStreamDeliveryMemoryE85ED633" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/Memory/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryServiceRoleC95D1642" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithBuiltinStrategiesServiceRole9D3D59C7" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/DefaultPolicy": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachToRole": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachToRole": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithCustomStrategiesServiceRole8BB48B33" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/DefaultPolicy": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachToRole": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachToRole": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Policy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryBucketPolicyE2E00A35" + }, + { + "type": "aws:cdk:analytics:mixin", + "data": { + "mixin": "aws-cdk-lib.aws_s3.mixins.BucketPolicyStatements" + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/AutoDeleteObjectsCustomResource/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryBucketAutoDeleteObjectsCustomResource24E6631C" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithSelfManagedStrategyServiceRole9A484437" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/DefaultPolicy": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachToRole": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachToRole": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithBuiltinEpisodicExServiceRoleB89EDF28" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithStreamDeliveryServiceRole890B7A55" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/ServiceRole/DefaultPolicy": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachToRole": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "attachToRole": [ + "*" + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addStatements": [ + {} + ] + } + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithBuiltinStrategiesServiceRoleDefaultPolicy99037030" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithCustomStrategiesServiceRoleDefaultPolicyB8522B1A" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithSelfManagedStrategyServiceRoleDefaultPolicy8649CA0E" + } + ], + "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MemoryWithStreamDeliveryServiceRoleDefaultPolicy0FFA2F76" + } + ] +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.template.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.template.json index 48426177c1825..fc06c20a9d770 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.template.json +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/aws-cdk-bedrock-agentcore-memory-1.template.json @@ -195,6 +195,25 @@ "bedrock:InvokeModel*" ], "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0" + ] + ] + } + }, + { + "Action": [ + "bedrock:GetInferenceProfile", + "bedrock:InvokeModel*" + ], + "Effect": "Allow", "Resource": { "Fn::Join": [ "", @@ -207,7 +226,11 @@ { "Ref": "AWS::Region" }, - "::foundation-model/anthropic.claude-3-5-sonnet-20240620-v1:0" + ":", + { + "Ref": "AWS::AccountId" + }, + ":inference-profile/us.anthropic.claude-sonnet-4-20250514-v1:0" ] ] } @@ -241,11 +264,11 @@ "SemanticOverride": { "Consolidation": { "AppendToPrompt": "Custom consolidation prompt for semantic memory", - "ModelId": "anthropic.claude-3-5-sonnet-20240620-v1:0" + "ModelId": "us.anthropic.claude-sonnet-4-20250514-v1:0" }, "Extraction": { "AppendToPrompt": "Custom extraction prompt for semantic memory", - "ModelId": "anthropic.claude-3-5-sonnet-20240620-v1:0" + "ModelId": "us.anthropic.claude-sonnet-4-20250514-v1:0" } } }, @@ -605,6 +628,104 @@ ], "Name": "memory_with_builtin_episodic_example" } + }, + "MemoryEventStream982A05ED": { + "Type": "AWS::Kinesis::Stream", + "Properties": { + "RetentionPeriodHours": 24, + "ShardCount": 1, + "StreamEncryption": { + "EncryptionType": "KMS", + "KeyId": "alias/aws/kinesis" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "MemoryWithStreamDeliveryServiceRole890B7A55": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "bedrock-agentcore.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "MemoryWithStreamDeliveryServiceRoleDefaultPolicy0FFA2F76": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "kinesis:DescribeStream", + "kinesis:ListShards", + "kinesis:PutRecord", + "kinesis:PutRecords" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "MemoryEventStream982A05ED", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "MemoryWithStreamDeliveryServiceRoleDefaultPolicy0FFA2F76", + "Roles": [ + { + "Ref": "MemoryWithStreamDeliveryServiceRole890B7A55" + } + ] + } + }, + "MemoryWithStreamDeliveryMemoryE85ED633": { + "Type": "AWS::BedrockAgentCore::Memory", + "Properties": { + "Description": "A memory with Kinesis stream delivery", + "EventExpiryDuration": 60, + "MemoryExecutionRoleArn": { + "Fn::GetAtt": [ + "MemoryWithStreamDeliveryServiceRole890B7A55", + "Arn" + ] + }, + "Name": "memory_with_stream_delivery", + "StreamDeliveryResources": { + "Resources": [ + { + "Kinesis": { + "ContentConfigurations": [ + { + "Level": "FULL_CONTENT", + "Type": "MEMORY_RECORDS" + } + ], + "DataStreamArn": { + "Fn::GetAtt": [ + "MemoryEventStream982A05ED", + "Arn" + ] + } + } + } + ] + } + }, + "DependsOn": [ + "MemoryWithStreamDeliveryServiceRoleDefaultPolicy0FFA2F76" + ] } }, "Parameters": { diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/cdk.out b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/cdk.out index 523a9aac37cbf..60aa68e157090 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"48.0.0"} \ No newline at end of file +{"version":"53.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/integ.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/integ.json index dee5c721586be..6eb6a4ab2c8b6 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "48.0.0", + "version": "53.0.0", "testCases": { "BedrockAgentCoreMemory/DefaultTest": { "stacks": [ @@ -25,5 +25,5 @@ "assertionStackName": "BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC" } }, - "minimumCliVersion": "2.1033.0" + "minimumCliVersion": "2.1108.0" } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/manifest.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/manifest.json index eb8a28f27cf87..76fea20c725c8 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "50.0.0", + "version": "53.0.0", "artifacts": { "aws-cdk-bedrock-agentcore-memory-1.assets": { "type": "cdk:asset-manifest", @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/8fcac4b2ff5dc797f588c28fc2fd390666d6191922b9d5ca5129dbeaeb4e75ee.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e6b479d88ba23e0f8b246fb19424e4bacae68ef3d86d49604f68f6facac1393c.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -33,488 +33,7 @@ "dependencies": [ "aws-cdk-bedrock-agentcore-memory-1.assets" ], - "metadata": { - "/aws-cdk-bedrock-agentcore-memory-1/Memory": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/Memory/ServiceRole": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "assumedBy": { - "principalAccount": "*", - "assumeRoleAction": "*" - } - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/Memory/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryServiceRoleC95D1642" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/Memory/Memory": [ - { - "type": "aws:cdk:logicalId", - "data": "Memory3232ACAB" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MyEncryptionKey": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MyEncryptionKey/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyEncryptionKeyD795679F" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": "*" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "assumedBy": { - "principalAccount": "*", - "assumeRoleAction": "*" - } - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addToPrincipalPolicy": [ - {} - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachInlinePolicy": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachInlinePolicy": [ - "*" - ] - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithBuiltinStrategiesServiceRole9D3D59C7" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/DefaultPolicy": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachToRole": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachToRole": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addStatements": [ - {} - ] - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/DefaultPolicy/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithBuiltinStrategiesServiceRoleDefaultPolicy99037030" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/Memory": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithBuiltinStrategiesMemory25697FD7" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": "*" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "assumedBy": { - "principalAccount": "*", - "assumeRoleAction": "*" - } - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addToPrincipalPolicy": [ - {} - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachInlinePolicy": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachInlinePolicy": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addToPrincipalPolicy": [ - {} - ] - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithCustomStrategiesServiceRole8BB48B33" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/DefaultPolicy": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachToRole": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachToRole": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addStatements": [ - {} - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addStatements": [ - {} - ] - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/DefaultPolicy/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithCustomStrategiesServiceRoleDefaultPolicyB8522B1A" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/Memory": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithCustomStrategiesMemoryFBD56D7A" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "removalPolicy": "destroy", - "autoDeleteObjects": true - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryBucket34BAD4CD" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Policy": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "bucket": "*" - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Policy/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryBucketPolicyE2E00A35" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/AutoDeleteObjectsCustomResource": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/AutoDeleteObjectsCustomResource/Default": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryBucketAutoDeleteObjectsCustomResource24E6631C" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider": [ - { - "type": "aws:cdk:is-custom-resource-handler-customResourceProvider", - "data": true - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Role": [ - { - "type": "aws:cdk:logicalId", - "data": "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler": [ - { - "type": "aws:cdk:logicalId", - "data": "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryTopic": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryTopic/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryTopic5EB6DDE2" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": "*" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "assumedBy": { - "principalAccount": "*", - "assumeRoleAction": "*" - } - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addToPrincipalPolicy": [ - {} - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachInlinePolicy": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachInlinePolicy": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addToPrincipalPolicy": [ - {} - ] - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithSelfManagedStrategyServiceRole9A484437" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/DefaultPolicy": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachToRole": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "attachToRole": [ - "*" - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addStatements": [ - {} - ] - } - }, - { - "type": "aws:cdk:analytics:method", - "data": { - "addStatements": [ - {} - ] - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/DefaultPolicy/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithSelfManagedStrategyServiceRoleDefaultPolicy8649CA0E" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/Memory": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithSelfManagedStrategyMemory927C030F" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx": [ - { - "type": "aws:cdk:analytics:construct", - "data": "*" - }, - { - "type": "aws:cdk:analytics:method", - "data": "*" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/ServiceRole": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "assumedBy": { - "principalAccount": "*", - "assumeRoleAction": "*" - } - } - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithBuiltinEpisodicExServiceRoleB89EDF28" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/Memory": [ - { - "type": "aws:cdk:logicalId", - "data": "MemoryWithBuiltinEpisodicExMemory4F42AC13" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/BootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "BootstrapVersion" - } - ], - "/aws-cdk-bedrock-agentcore-memory-1/CheckBootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "CheckBootstrapVersion" - } - ] - }, + "additionalMetadataFile": "aws-cdk-bedrock-agentcore-memory-1.metadata.json", "displayName": "aws-cdk-bedrock-agentcore-memory-1" }, "BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.assets": { @@ -549,20 +68,7 @@ "dependencies": [ "BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.assets" ], - "metadata": { - "/BedrockAgentCoreMemory/DefaultTest/DeployAssert/BootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "BootstrapVersion" - } - ], - "/BedrockAgentCoreMemory/DefaultTest/DeployAssert/CheckBootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "CheckBootstrapVersion" - } - ] - }, + "additionalMetadataFile": "BedrockAgentCoreMemoryDefaultTestDeployAssertCD60C6DC.metadata.json", "displayName": "BedrockAgentCoreMemory/DefaultTest/DeployAssert" }, "Tree": { @@ -863,6 +369,7 @@ "explanation": "When enabled, nodegroupName attribute of the provisioned EKS NodeGroup will not have the cluster name prefix." }, "@aws-cdk/aws-eks:useNativeOidcProvider": { + "userValue": true, "recommendedValue": true, "explanation": "When enabled, EKS V2 clusters will use the native OIDC provider resource AWS::IAM::OIDCProvider instead of creating the OIDCProvider with a custom resource (iam.OpenIDConnectProvider)." }, @@ -1060,12 +567,28 @@ "explanation": "When enabled, ECS patterns will generate unique target group IDs to prevent conflicts during load balancer replacement" }, "@aws-cdk/aws-route53-patterns:useDistribution": { + "userValue": true, "recommendedValue": true, "explanation": "Use the `Distribution` resource instead of `CloudFrontWebDistribution`" + }, + "@aws-cdk/aws-cloudfront:defaultFunctionRuntimeV2_0": { + "recommendedValue": true, + "explanation": "Use cloudfront-js-2.0 as the default runtime for CloudFront Functions" + }, + "@aws-cdk/aws-elasticloadbalancingv2:usePostQuantumTlsPolicy": { + "recommendedValue": true, + "explanation": "When enabled, HTTPS/TLS listeners use post-quantum TLS policy by default" + }, + "@aws-cdk/core:automaticL1Traits": { + "recommendedValue": true, + "explanation": "Automatically use the default L1 traits for L1 constructs`", + "unconfiguredBehavesLike": { + "v2": true + } } } } } }, - "minimumCliVersion": "2.1101.0" + "minimumCliVersion": "2.1108.0" } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/tree.json b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/tree.json index feb5ff4d06503..918da66486a9b 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.js.snapshot/tree.json @@ -1 +1 @@ -{"version":"tree-0.1","tree":{"id":"App","path":"","constructInfo":{"fqn":"aws-cdk-lib.App","version":"0.0.0"},"children":{"aws-cdk-bedrock-agentcore-memory-1":{"id":"aws-cdk-bedrock-agentcore-memory-1","path":"aws-cdk-bedrock-agentcore-memory-1","constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"},"children":{"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/Memory","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/Memory/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/Memory/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/Memory/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"eventExpiryDuration":90,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryServiceRoleC95D1642","Arn"]},"name":"memory"}}}}},"MyEncryptionKey":{"id":"MyEncryptionKey","path":"aws-cdk-bedrock-agentcore-memory-1/MyEncryptionKey","constructInfo":{"fqn":"aws-cdk-lib.aws_kms.Key","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MyEncryptionKey/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_kms.CfnKey","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::KMS::Key","aws:cdk:cloudformation:props":{"keyPolicy":{"Statement":[{"Action":"kms:*","Effect":"Allow","Principal":{"AWS":{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":iam::",{"Ref":"AWS::AccountId"},":root"]]}},"Resource":"*"}],"Version":"2012-10-17"}}}}}},"MemoryWithBuiltinStrategies":{"id":"MemoryWithBuiltinStrategies","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}},"DefaultPolicy":{"id":"DefaultPolicy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/DefaultPolicy","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Policy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/DefaultPolicy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Policy","aws:cdk:cloudformation:props":{"policyDocument":{"Statement":[{"Action":["kms:CreateGrant","kms:Decrypt","kms:DescribeKey","kms:GenerateDataKey","kms:GenerateDataKeyWithoutPlaintext","kms:ReEncrypt*"],"Effect":"Allow","Resource":{"Fn::GetAtt":["MyEncryptionKeyD795679F","Arn"]}}],"Version":"2012-10-17"},"policyName":"MemoryWithBuiltinStrategiesServiceRoleDefaultPolicy99037030","roles":[{"Ref":"MemoryWithBuiltinStrategiesServiceRole9D3D59C7"}]}}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A test memory with built-in strategies","encryptionKeyArn":{"Fn::GetAtt":["MyEncryptionKeyD795679F","Arn"]},"eventExpiryDuration":60,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithBuiltinStrategiesServiceRole9D3D59C7","Arn"]},"memoryStrategies":[{"summaryMemoryStrategy":{"name":"summary_builtin_cdkGen0001","description":"Summarize interactions to preserve critical context and key insights","namespaces":["/strategies/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}"],"type":"SUMMARIZATION"}},{"semanticMemoryStrategy":{"name":"semantic_builtin_cdkGen0001","description":"Extract general factual knowledge, concepts and meanings from raw conversations in a context-independent format.","namespaces":["/strategies/{memoryStrategyId}/actors/{actorId}"],"type":"SEMANTIC"}},{"userPreferenceMemoryStrategy":{"name":"preference_builtin_cdkGen0001","description":"Capture individual preferences, interaction patterns, and personalized settings to enhance future experiences.","namespaces":["/strategies/{memoryStrategyId}/actors/{actorId}"],"type":"USER_PREFERENCE"}}],"name":"memory_with_builtin_strategies"}}}}},"MemoryWithCustomStrategies":{"id":"MemoryWithCustomStrategies","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}},"DefaultPolicy":{"id":"DefaultPolicy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/DefaultPolicy","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Policy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/DefaultPolicy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Policy","aws:cdk:cloudformation:props":{"policyDocument":{"Statement":[{"Action":["bedrock:GetFoundationModel","bedrock:InvokeModel*"],"Effect":"Allow","Resource":{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":bedrock:",{"Ref":"AWS::Region"},"::foundation-model/anthropic.claude-3-5-sonnet-20240620-v1:0"]]}}],"Version":"2012-10-17"},"policyName":"MemoryWithCustomStrategiesServiceRoleDefaultPolicyB8522B1A","roles":[{"Ref":"MemoryWithCustomStrategiesServiceRole8BB48B33"}]}}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A long term memory with consolidation","eventExpiryDuration":60,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithCustomStrategiesServiceRole8BB48B33","Arn"]},"memoryStrategies":[{"customMemoryStrategy":{"name":"customSemanticStrategy","description":"Custom semantic memory strategy","namespaces":["/custom/strategies/{memoryStrategyId}/actors/{actorId}"],"type":"SEMANTIC","configuration":{"semanticOverride":{"consolidation":{"modelId":"anthropic.claude-3-5-sonnet-20240620-v1:0","appendToPrompt":"Custom consolidation prompt for semantic memory"},"extraction":{"modelId":"anthropic.claude-3-5-sonnet-20240620-v1:0","appendToPrompt":"Custom extraction prompt for semantic memory"}}}}}],"name":"memory_with_custom_strategies"}}}}},"MemoryBucket":{"id":"MemoryBucket","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket","constructInfo":{"fqn":"aws-cdk-lib.aws_s3.Bucket","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_s3.CfnBucket","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::S3::Bucket","aws:cdk:cloudformation:props":{"tags":[{"key":"aws-cdk:auto-delete-objects","value":"true"}]}}},"Policy":{"id":"Policy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Policy","constructInfo":{"fqn":"aws-cdk-lib.aws_s3.BucketPolicy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Policy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_s3.CfnBucketPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::S3::BucketPolicy","aws:cdk:cloudformation:props":{"bucket":{"Ref":"MemoryBucket34BAD4CD"},"policyDocument":{"Statement":[{"Action":["s3:DeleteObject*","s3:GetBucket*","s3:List*","s3:PutBucketPolicy"],"Effect":"Allow","Principal":{"AWS":{"Fn::GetAtt":["CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092","Arn"]}},"Resource":[{"Fn::GetAtt":["MemoryBucket34BAD4CD","Arn"]},{"Fn::Join":["",[{"Fn::GetAtt":["MemoryBucket34BAD4CD","Arn"]},"/*"]]}]}],"Version":"2012-10-17"}}}}}},"AutoDeleteObjectsCustomResource":{"id":"AutoDeleteObjectsCustomResource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/AutoDeleteObjectsCustomResource","constructInfo":{"fqn":"aws-cdk-lib.CustomResource","version":"0.0.0"},"children":{"Default":{"id":"Default","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/AutoDeleteObjectsCustomResource/Default","constructInfo":{"fqn":"aws-cdk-lib.CfnResource","version":"0.0.0"}}}}}},"Custom::S3AutoDeleteObjectsCustomResourceProvider":{"id":"Custom::S3AutoDeleteObjectsCustomResourceProvider","path":"aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider","constructInfo":{"fqn":"aws-cdk-lib.CustomResourceProviderBase","version":"0.0.0"},"children":{"Staging":{"id":"Staging","path":"aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Staging","constructInfo":{"fqn":"aws-cdk-lib.AssetStaging","version":"0.0.0"}},"Role":{"id":"Role","path":"aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Role","constructInfo":{"fqn":"aws-cdk-lib.CfnResource","version":"0.0.0"}},"Handler":{"id":"Handler","path":"aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler","constructInfo":{"fqn":"aws-cdk-lib.CfnResource","version":"0.0.0"}}}},"MemoryTopic":{"id":"MemoryTopic","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryTopic","constructInfo":{"fqn":"aws-cdk-lib.aws_sns.Topic","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryTopic/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_sns.CfnTopic","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::SNS::Topic","aws:cdk:cloudformation:props":{}}}}},"MemoryWithSelfManagedStrategy":{"id":"MemoryWithSelfManagedStrategy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}},"DefaultPolicy":{"id":"DefaultPolicy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/DefaultPolicy","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Policy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/DefaultPolicy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Policy","aws:cdk:cloudformation:props":{"policyDocument":{"Statement":[{"Action":["sns:GetTopicAttributes","sns:Publish"],"Effect":"Allow","Resource":{"Ref":"MemoryTopic5EB6DDE2"}},{"Action":["s3:GetBucketLocation","s3:PutObject"],"Effect":"Allow","Resource":[{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":s3:::",{"Ref":"MemoryBucket34BAD4CD"},"/*"]]},{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":s3:::",{"Ref":"MemoryBucket34BAD4CD"}]]}]}],"Version":"2012-10-17"},"policyName":"MemoryWithSelfManagedStrategyServiceRoleDefaultPolicy8649CA0E","roles":[{"Ref":"MemoryWithSelfManagedStrategyServiceRole9A484437"}]}}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A test memory with a self managed strategy","eventExpiryDuration":60,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithSelfManagedStrategyServiceRole9A484437","Arn"]},"memoryStrategies":[{"summaryMemoryStrategy":{"name":"summary_builtin_cdkGen0001","description":"Summarize interactions to preserve critical context and key insights","namespaces":["/strategies/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}"],"type":"SUMMARIZATION"}},{"customMemoryStrategy":{"name":"selfManagedStrategy","description":"Self managed memory strategy","type":"CUSTOM","configuration":{"selfManagedConfiguration":{"historicalContextWindowSize":4,"invocationConfiguration":{"topicArn":{"Ref":"MemoryTopic5EB6DDE2"},"payloadDeliveryBucketName":{"Ref":"MemoryBucket34BAD4CD"}},"triggerConditions":[{"messageBasedTrigger":{"messageCount":1}},{"timeBasedTrigger":{"idleSessionTimeout":10}},{"tokenBasedTrigger":{"tokenCount":100}}]}}}}],"name":"memory_with_self_managed_strategy"}}}}},"MemoryWithBuiltinEpisodicEx":{"id":"MemoryWithBuiltinEpisodicEx","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A test memory with built-in episodic strategy","eventExpiryDuration":90,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithBuiltinEpisodicExServiceRoleB89EDF28","Arn"]},"memoryStrategies":[{"episodicMemoryStrategy":{"name":"episodic_builtin_cdkGen0001","description":"Captures meaningful slices of user and system interactions.","namespaces":["/strategy/{memoryStrategyId}/actor/{actorId}/session/{sessionId}"],"type":"EPISODIC","reflectionConfiguration":{"namespaces":["/strategy/{memoryStrategyId}/actor/{actorId}"]}}}],"name":"memory_with_builtin_episodic_example"}}}}},"BootstrapVersion":{"id":"BootstrapVersion","path":"aws-cdk-bedrock-agentcore-memory-1/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"aws-cdk-bedrock-agentcore-memory-1/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}}},"BedrockAgentCoreMemory":{"id":"BedrockAgentCoreMemory","path":"BedrockAgentCoreMemory","constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTest","version":"0.0.0"},"children":{"DefaultTest":{"id":"DefaultTest","path":"BedrockAgentCoreMemory/DefaultTest","constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTestCase","version":"0.0.0"},"children":{"Default":{"id":"Default","path":"BedrockAgentCoreMemory/DefaultTest/Default","constructInfo":{"fqn":"constructs.Construct","version":"10.4.5"}},"DeployAssert":{"id":"DeployAssert","path":"BedrockAgentCoreMemory/DefaultTest/DeployAssert","constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"},"children":{"BootstrapVersion":{"id":"BootstrapVersion","path":"BedrockAgentCoreMemory/DefaultTest/DeployAssert/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"BedrockAgentCoreMemory/DefaultTest/DeployAssert/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}}}}}}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.4.5"}}}}} \ No newline at end of file +{"version":"tree-0.1","tree":{"id":"App","path":"","constructInfo":{"fqn":"aws-cdk-lib.App","version":"0.0.0"},"children":{"aws-cdk-bedrock-agentcore-memory-1":{"id":"aws-cdk-bedrock-agentcore-memory-1","path":"aws-cdk-bedrock-agentcore-memory-1","constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"},"children":{"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/Memory","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/Memory/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/Memory/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/Memory/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"eventExpiryDuration":90,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryServiceRoleC95D1642","Arn"]},"name":"memory"}}}}},"MyEncryptionKey":{"id":"MyEncryptionKey","path":"aws-cdk-bedrock-agentcore-memory-1/MyEncryptionKey","constructInfo":{"fqn":"aws-cdk-lib.aws_kms.Key","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MyEncryptionKey/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_kms.CfnKey","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::KMS::Key","aws:cdk:cloudformation:props":{"keyPolicy":{"Statement":[{"Action":"kms:*","Effect":"Allow","Principal":{"AWS":{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":iam::",{"Ref":"AWS::AccountId"},":root"]]}},"Resource":"*"}],"Version":"2012-10-17"}}}}}},"MemoryWithBuiltinStrategies":{"id":"MemoryWithBuiltinStrategies","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}},"DefaultPolicy":{"id":"DefaultPolicy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/DefaultPolicy","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Policy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/ServiceRole/DefaultPolicy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Policy","aws:cdk:cloudformation:props":{"policyDocument":{"Statement":[{"Action":["kms:CreateGrant","kms:Decrypt","kms:DescribeKey","kms:GenerateDataKey","kms:GenerateDataKeyWithoutPlaintext","kms:ReEncrypt*"],"Effect":"Allow","Resource":{"Fn::GetAtt":["MyEncryptionKeyD795679F","Arn"]}}],"Version":"2012-10-17"},"policyName":"MemoryWithBuiltinStrategiesServiceRoleDefaultPolicy99037030","roles":[{"Ref":"MemoryWithBuiltinStrategiesServiceRole9D3D59C7"}]}}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinStrategies/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A test memory with built-in strategies","encryptionKeyArn":{"Fn::GetAtt":["MyEncryptionKeyD795679F","Arn"]},"eventExpiryDuration":60,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithBuiltinStrategiesServiceRole9D3D59C7","Arn"]},"memoryStrategies":[{"summaryMemoryStrategy":{"name":"summary_builtin_cdkGen0001","description":"Summarize interactions to preserve critical context and key insights","namespaces":["/strategies/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}"],"type":"SUMMARIZATION"}},{"semanticMemoryStrategy":{"name":"semantic_builtin_cdkGen0001","description":"Extract general factual knowledge, concepts and meanings from raw conversations in a context-independent format.","namespaces":["/strategies/{memoryStrategyId}/actors/{actorId}"],"type":"SEMANTIC"}},{"userPreferenceMemoryStrategy":{"name":"preference_builtin_cdkGen0001","description":"Capture individual preferences, interaction patterns, and personalized settings to enhance future experiences.","namespaces":["/strategies/{memoryStrategyId}/actors/{actorId}"],"type":"USER_PREFERENCE"}}],"name":"memory_with_builtin_strategies"}}}}},"MemoryWithCustomStrategies":{"id":"MemoryWithCustomStrategies","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}},"DefaultPolicy":{"id":"DefaultPolicy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/DefaultPolicy","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Policy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/ServiceRole/DefaultPolicy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Policy","aws:cdk:cloudformation:props":{"policyDocument":{"Statement":[{"Action":["bedrock:GetFoundationModel","bedrock:InvokeModel*"],"Effect":"Allow","Resource":{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0"]]}},{"Action":["bedrock:GetInferenceProfile","bedrock:InvokeModel*"],"Effect":"Allow","Resource":{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":bedrock:",{"Ref":"AWS::Region"},":",{"Ref":"AWS::AccountId"},":inference-profile/us.anthropic.claude-sonnet-4-20250514-v1:0"]]}}],"Version":"2012-10-17"},"policyName":"MemoryWithCustomStrategiesServiceRoleDefaultPolicyB8522B1A","roles":[{"Ref":"MemoryWithCustomStrategiesServiceRole8BB48B33"}]}}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithCustomStrategies/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A long term memory with consolidation","eventExpiryDuration":60,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithCustomStrategiesServiceRole8BB48B33","Arn"]},"memoryStrategies":[{"customMemoryStrategy":{"name":"customSemanticStrategy","description":"Custom semantic memory strategy","namespaces":["/custom/strategies/{memoryStrategyId}/actors/{actorId}"],"type":"SEMANTIC","configuration":{"semanticOverride":{"consolidation":{"modelId":"us.anthropic.claude-sonnet-4-20250514-v1:0","appendToPrompt":"Custom consolidation prompt for semantic memory"},"extraction":{"modelId":"us.anthropic.claude-sonnet-4-20250514-v1:0","appendToPrompt":"Custom extraction prompt for semantic memory"}}}}}],"name":"memory_with_custom_strategies"}}}}},"MemoryBucket":{"id":"MemoryBucket","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket","constructInfo":{"fqn":"aws-cdk-lib.aws_s3.Bucket","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_s3.CfnBucket","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::S3::Bucket","aws:cdk:cloudformation:props":{"tags":[{"key":"aws-cdk:auto-delete-objects","value":"true"}]}}},"Policy":{"id":"Policy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Policy","constructInfo":{"fqn":"aws-cdk-lib.aws_s3.BucketPolicy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/Policy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_s3.CfnBucketPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::S3::BucketPolicy","aws:cdk:cloudformation:props":{"bucket":{"Ref":"MemoryBucket34BAD4CD"},"policyDocument":{"Statement":[{"Action":["s3:DeleteObject*","s3:GetBucket*","s3:List*","s3:PutBucketPolicy"],"Effect":"Allow","Principal":{"AWS":{"Fn::GetAtt":["CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092","Arn"]}},"Resource":[{"Fn::GetAtt":["MemoryBucket34BAD4CD","Arn"]},{"Fn::Join":["",[{"Fn::GetAtt":["MemoryBucket34BAD4CD","Arn"]},"/*"]]}]}],"Version":"2012-10-17"}}}}}},"AutoDeleteObjectsCustomResource":{"id":"AutoDeleteObjectsCustomResource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/AutoDeleteObjectsCustomResource","constructInfo":{"fqn":"aws-cdk-lib.CustomResource","version":"0.0.0"},"children":{"Default":{"id":"Default","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryBucket/AutoDeleteObjectsCustomResource/Default","constructInfo":{"fqn":"aws-cdk-lib.CfnResource","version":"0.0.0"}}}}}},"Custom::S3AutoDeleteObjectsCustomResourceProvider":{"id":"Custom::S3AutoDeleteObjectsCustomResourceProvider","path":"aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider","constructInfo":{"fqn":"aws-cdk-lib.CustomResourceProviderBase","version":"0.0.0"},"children":{"Staging":{"id":"Staging","path":"aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Staging","constructInfo":{"fqn":"aws-cdk-lib.AssetStaging","version":"0.0.0"}},"Role":{"id":"Role","path":"aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Role","constructInfo":{"fqn":"aws-cdk-lib.CfnResource","version":"0.0.0"}},"Handler":{"id":"Handler","path":"aws-cdk-bedrock-agentcore-memory-1/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler","constructInfo":{"fqn":"aws-cdk-lib.CfnResource","version":"0.0.0"}}}},"MemoryTopic":{"id":"MemoryTopic","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryTopic","constructInfo":{"fqn":"aws-cdk-lib.aws_sns.Topic","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryTopic/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_sns.CfnTopic","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::SNS::Topic","aws:cdk:cloudformation:props":{}}}}},"MemoryWithSelfManagedStrategy":{"id":"MemoryWithSelfManagedStrategy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}},"DefaultPolicy":{"id":"DefaultPolicy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/DefaultPolicy","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Policy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/ServiceRole/DefaultPolicy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Policy","aws:cdk:cloudformation:props":{"policyDocument":{"Statement":[{"Action":["sns:GetTopicAttributes","sns:Publish"],"Effect":"Allow","Resource":{"Ref":"MemoryTopic5EB6DDE2"}},{"Action":["s3:GetBucketLocation","s3:PutObject"],"Effect":"Allow","Resource":[{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":s3:::",{"Ref":"MemoryBucket34BAD4CD"},"/*"]]},{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":s3:::",{"Ref":"MemoryBucket34BAD4CD"}]]}]}],"Version":"2012-10-17"},"policyName":"MemoryWithSelfManagedStrategyServiceRoleDefaultPolicy8649CA0E","roles":[{"Ref":"MemoryWithSelfManagedStrategyServiceRole9A484437"}]}}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithSelfManagedStrategy/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A test memory with a self managed strategy","eventExpiryDuration":60,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithSelfManagedStrategyServiceRole9A484437","Arn"]},"memoryStrategies":[{"summaryMemoryStrategy":{"name":"summary_builtin_cdkGen0001","description":"Summarize interactions to preserve critical context and key insights","namespaces":["/strategies/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}"],"type":"SUMMARIZATION"}},{"customMemoryStrategy":{"name":"selfManagedStrategy","description":"Self managed memory strategy","type":"CUSTOM","configuration":{"selfManagedConfiguration":{"historicalContextWindowSize":4,"invocationConfiguration":{"topicArn":{"Ref":"MemoryTopic5EB6DDE2"},"payloadDeliveryBucketName":{"Ref":"MemoryBucket34BAD4CD"}},"triggerConditions":[{"messageBasedTrigger":{"messageCount":1}},{"timeBasedTrigger":{"idleSessionTimeout":10}},{"tokenBasedTrigger":{"tokenCount":100}}]}}}}],"name":"memory_with_self_managed_strategy"}}}}},"MemoryWithBuiltinEpisodicEx":{"id":"MemoryWithBuiltinEpisodicEx","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithBuiltinEpisodicEx/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A test memory with built-in episodic strategy","eventExpiryDuration":90,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithBuiltinEpisodicExServiceRoleB89EDF28","Arn"]},"memoryStrategies":[{"episodicMemoryStrategy":{"name":"episodic_builtin_cdkGen0001","description":"Captures meaningful slices of user and system interactions.","namespaces":["/strategy/{memoryStrategyId}/actor/{actorId}/session/{sessionId}"],"type":"EPISODIC","reflectionConfiguration":{"namespaces":["/strategy/{memoryStrategyId}/actor/{actorId}"]}}}],"name":"memory_with_builtin_episodic_example"}}}}},"MemoryEventStream":{"id":"MemoryEventStream","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryEventStream","constructInfo":{"fqn":"aws-cdk-lib.aws_kinesis.Stream","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryEventStream/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_kinesis.CfnStream","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::Kinesis::Stream","aws:cdk:cloudformation:props":{"retentionPeriodHours":24,"shardCount":1,"streamEncryption":{"encryptionType":"KMS","keyId":"alias/aws/kinesis"}}}}}},"MemoryWithStreamDelivery":{"id":"MemoryWithStreamDelivery","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery","constructInfo":{"fqn":"@aws-cdk/aws-bedrock-agentcore-alpha.Memory","version":"0.0.0"},"children":{"ServiceRole":{"id":"ServiceRole","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/ServiceRole","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Role","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/ServiceRole/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnRole","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Role","aws:cdk:cloudformation:props":{"assumeRolePolicyDocument":{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"Service":"bedrock-agentcore.amazonaws.com"}}],"Version":"2012-10-17"}}}},"DefaultPolicy":{"id":"DefaultPolicy","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/ServiceRole/DefaultPolicy","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.Policy","version":"0.0.0"},"children":{"Resource":{"id":"Resource","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/ServiceRole/DefaultPolicy/Resource","constructInfo":{"fqn":"aws-cdk-lib.aws_iam.CfnPolicy","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::IAM::Policy","aws:cdk:cloudformation:props":{"policyDocument":{"Statement":[{"Action":["kinesis:DescribeStream","kinesis:ListShards","kinesis:PutRecord","kinesis:PutRecords"],"Effect":"Allow","Resource":{"Fn::GetAtt":["MemoryEventStream982A05ED","Arn"]}}],"Version":"2012-10-17"},"policyName":"MemoryWithStreamDeliveryServiceRoleDefaultPolicy0FFA2F76","roles":[{"Ref":"MemoryWithStreamDeliveryServiceRole890B7A55"}]}}}}}}},"Memory":{"id":"Memory","path":"aws-cdk-bedrock-agentcore-memory-1/MemoryWithStreamDelivery/Memory","constructInfo":{"fqn":"aws-cdk-lib.aws_bedrockagentcore.CfnMemory","version":"0.0.0"},"attributes":{"aws:cdk:cloudformation:type":"AWS::BedrockAgentCore::Memory","aws:cdk:cloudformation:props":{"description":"A memory with Kinesis stream delivery","eventExpiryDuration":60,"memoryExecutionRoleArn":{"Fn::GetAtt":["MemoryWithStreamDeliveryServiceRole890B7A55","Arn"]},"name":"memory_with_stream_delivery","streamDeliveryResources":{"resources":[{"kinesis":{"dataStreamArn":{"Fn::GetAtt":["MemoryEventStream982A05ED","Arn"]},"contentConfigurations":[{"type":"MEMORY_RECORDS","level":"FULL_CONTENT"}]}}]}}}}}},"BootstrapVersion":{"id":"BootstrapVersion","path":"aws-cdk-bedrock-agentcore-memory-1/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"aws-cdk-bedrock-agentcore-memory-1/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}}},"BedrockAgentCoreMemory":{"id":"BedrockAgentCoreMemory","path":"BedrockAgentCoreMemory","constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTest","version":"0.0.0"},"children":{"DefaultTest":{"id":"DefaultTest","path":"BedrockAgentCoreMemory/DefaultTest","constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTestCase","version":"0.0.0"},"children":{"Default":{"id":"Default","path":"BedrockAgentCoreMemory/DefaultTest/Default","constructInfo":{"fqn":"constructs.Construct","version":"10.5.1"}},"DeployAssert":{"id":"DeployAssert","path":"BedrockAgentCoreMemory/DefaultTest/DeployAssert","constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"},"children":{"BootstrapVersion":{"id":"BootstrapVersion","path":"BedrockAgentCoreMemory/DefaultTest/DeployAssert/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"BedrockAgentCoreMemory/DefaultTest/DeployAssert/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}}}}}}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.5.1"}}}}} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.ts b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.ts index 783a468b5f082..551765fbd2cab 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.ts +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/integ.memory.ts @@ -7,6 +7,7 @@ import * as bedrock from '@aws-cdk/aws-bedrock-alpha'; import * as integ from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; +import * as kinesis from 'aws-cdk-lib/aws-kinesis'; import * as kms from 'aws-cdk-lib/aws-kms'; import * as s3 from 'aws-cdk-lib/aws-s3'; import * as sns from 'aws-cdk-lib/aws-sns'; @@ -37,6 +38,12 @@ new agentcore.Memory(stack, 'MemoryWithBuiltinStrategies', { }); // Create a memory with LTM strategies (custom) +// Create a cross-region inference profile for the custom strategy model +const customStrategyModel = bedrock.CrossRegionInferenceProfile.fromConfig({ + geoRegion: bedrock.CrossRegionInferenceProfileRegion.US, + model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_SONNET_4_V1_0, +}); + new agentcore.Memory(stack, 'MemoryWithCustomStrategies', { memoryName: 'memory_with_custom_strategies', description: 'A long term memory with consolidation', @@ -47,11 +54,11 @@ new agentcore.Memory(stack, 'MemoryWithCustomStrategies', { description: 'Custom semantic memory strategy', namespaces: ['/custom/strategies/{memoryStrategyId}/actors/{actorId}'], customConsolidation: { - model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0, + model: customStrategyModel, appendToPrompt: 'Custom consolidation prompt for semantic memory', }, customExtraction: { - model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0, + model: customStrategyModel, appendToPrompt: 'Custom extraction prompt for semantic memory', }, }), @@ -96,6 +103,19 @@ new agentcore.Memory(stack, 'MemoryWithBuiltinEpisodicEx', { ], }); +// Create a memory with Kinesis stream delivery +const memoryEventStream = new kinesis.Stream(stack, 'MemoryEventStream', { + encryption: kinesis.StreamEncryption.MANAGED, + removalPolicy: cdk.RemovalPolicy.DESTROY, +}); + +new agentcore.Memory(stack, 'MemoryWithStreamDelivery', { + memoryName: 'memory_with_stream_delivery', + description: 'A memory with Kinesis stream delivery', + expirationDuration: cdk.Duration.days(60), + streamDeliveryResources: [{ stream: memoryEventStream }], +}); + new integ.IntegTest(app, 'BedrockAgentCoreMemory', { testCases: [stack], regions: ['us-east-1', 'us-east-2', 'us-west-2', 'ca-central-1', 'eu-central-1', 'eu-north-1', 'eu-west-1', 'eu-west-2', 'eu-west-3', 'ap-northeast-1', 'ap-northeast-2', 'ap-south-1', 'ap-southeast-1', 'ap-southeast-2'], // Bedrock Agent Core is only available in these regions diff --git a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/memory.test.ts b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/memory.test.ts index d846164803781..30c899d29fe46 100644 --- a/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/memory.test.ts +++ b/packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/memory/memory.test.ts @@ -3,11 +3,14 @@ import * as cdk from 'aws-cdk-lib'; import { Duration } from 'aws-cdk-lib'; import { Template, Match } from 'aws-cdk-lib/assertions'; import * as iam from 'aws-cdk-lib/aws-iam'; +import * as kinesis from 'aws-cdk-lib/aws-kinesis'; import * as kms from 'aws-cdk-lib/aws-kms'; import * as s3 from 'aws-cdk-lib/aws-s3'; import * as sns from 'aws-cdk-lib/aws-sns'; import { Memory, + StreamDeliveryContentType, + StreamDeliveryContentLevel, } from '../../../lib/memory/memory'; import { MemoryStrategy } from '../../../lib/memory/memory-strategy'; @@ -2498,3 +2501,377 @@ describe('Episodic strategy validation edge cases tests', () => { }).toThrow('Namespace with templates should contain valid variables: /journey/{badVariable}/episodes'); }); }); + +describe('Memory with stream delivery resource tests', () => { + let template: Template; + let app: cdk.App; + let stack: cdk.Stack; + let memory: Memory; + + beforeAll(() => { + app = new cdk.App(); + stack = new cdk.Stack(app, 'test-stack', { + env: { + account: '123456789012', + region: 'us-east-1', + }, + }); + + const stream = new kinesis.Stream(stack, 'MemoryEventStream'); + + memory = new Memory(stack, 'test-memory', { + memoryName: 'test_memory_with_stream', + description: 'A test memory with stream delivery', + expirationDuration: Duration.days(30), + streamDeliveryResources: [ + { + stream, + contentConfigurations: [ + { + type: StreamDeliveryContentType.MEMORY_RECORDS, + level: StreamDeliveryContentLevel.FULL_CONTENT, + }, + ], + }, + ], + }); + + app.synth(); + template = Template.fromStack(stack); + }); + + test('Should have the correct resources', () => { + template.resourceCountIs('AWS::BedrockAgentCore::Memory', 1); + template.resourceCountIs('AWS::Kinesis::Stream', 1); + template.resourceCountIs('AWS::IAM::Role', 1); + }); + + test('Should have Memory resource with StreamDeliveryResources', () => { + template.hasResourceProperties('AWS::BedrockAgentCore::Memory', { + Name: 'test_memory_with_stream', + StreamDeliveryResources: { + Resources: [ + { + Kinesis: { + DataStreamArn: { 'Fn::GetAtt': [Match.stringLikeRegexp('MemoryEventStream*'), 'Arn'] }, + ContentConfigurations: [ + { + Type: 'MEMORY_RECORDS', + Level: 'FULL_CONTENT', + }, + ], + }, + }, + ], + }, + }); + }); + + test('Should grant Kinesis write permissions to execution role', () => { + template.hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: Match.arrayWith([ + Match.objectLike({ + Effect: 'Allow', + Action: Match.arrayWith([ + 'kinesis:PutRecord', + 'kinesis:PutRecords', + ]), + Resource: { 'Fn::GetAtt': [Match.stringLikeRegexp('MemoryEventStream*'), 'Arn'] }, + }), + Match.objectLike({ + Effect: 'Allow', + Action: 'kinesis:DescribeStream', + Resource: { 'Fn::GetAtt': [Match.stringLikeRegexp('MemoryEventStream*'), 'Arn'] }, + }), + ]), + }, + }); + }); + + test('Should have stream delivery resource in construct property', () => { + expect(memory.streamDeliveryResources).toHaveLength(1); + }); +}); + +describe('Memory with addStreamDeliveryResource method tests', () => { + let template: Template; + let app: cdk.App; + let stack: cdk.Stack; + let memory: Memory; + + beforeAll(() => { + app = new cdk.App(); + stack = new cdk.Stack(app, 'test-stack', { + env: { + account: '123456789012', + region: 'us-east-1', + }, + }); + + const stream = new kinesis.Stream(stack, 'AddedStream'); + + memory = new Memory(stack, 'test-memory', { + memoryName: 'test_memory_add_stream', + }); + + memory.addStreamDeliveryResource({ + stream, + contentConfigurations: [ + { + type: StreamDeliveryContentType.MEMORY_RECORDS, + level: StreamDeliveryContentLevel.METADATA_ONLY, + }, + ], + }); + + app.synth(); + template = Template.fromStack(stack); + }); + + test('Should have Memory resource with StreamDeliveryResources added via method', () => { + template.hasResourceProperties('AWS::BedrockAgentCore::Memory', { + StreamDeliveryResources: { + Resources: [ + { + Kinesis: { + DataStreamArn: { 'Fn::GetAtt': [Match.stringLikeRegexp('AddedStream*'), 'Arn'] }, + ContentConfigurations: [ + { + Type: 'MEMORY_RECORDS', + Level: 'METADATA_ONLY', + }, + ], + }, + }, + ], + }, + }); + }); + + test('Should grant Kinesis write permissions via addStreamDeliveryResource', () => { + template.hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: Match.arrayWith([ + Match.objectLike({ + Effect: 'Allow', + Action: Match.arrayWith([ + 'kinesis:PutRecord', + 'kinesis:PutRecords', + ]), + }), + ]), + }, + }); + }); + + test('Should have stream delivery resources in construct property', () => { + expect(memory.streamDeliveryResources).toHaveLength(1); + }); +}); + +describe('Memory stream delivery validation tests', () => { + let app: cdk.App; + let stack: cdk.Stack; + + beforeEach(() => { + app = new cdk.App(); + stack = new cdk.Stack(app, 'test-stack', { + env: { + account: '123456789012', + region: 'us-east-1', + }, + }); + }); + + test('Should use default contentConfigurations when not specified', () => { + const stream = new kinesis.Stream(stack, 'DefaultConfigStream'); + + new Memory(stack, 'default-config-memory', { + memoryName: 'default_config_memory', + streamDeliveryResources: [{ stream }], + }); + + app.synth(); + const template = Template.fromStack(stack); + + template.hasResourceProperties('AWS::BedrockAgentCore::Memory', { + StreamDeliveryResources: { + Resources: [ + { + Kinesis: { + ContentConfigurations: [ + { + Type: 'MEMORY_RECORDS', + Level: 'FULL_CONTENT', + }, + ], + }, + }, + ], + }, + }); + }); + + test('Should throw error for more than one content configuration', () => { + const stream = new kinesis.Stream(stack, 'TooManyConfigStream'); + + expect(() => { + new Memory(stack, 'invalid-memory', { + memoryName: 'invalid_stream_memory', + streamDeliveryResources: [ + { + stream, + contentConfigurations: [ + { type: StreamDeliveryContentType.MEMORY_RECORDS, level: StreamDeliveryContentLevel.FULL_CONTENT }, + { type: StreamDeliveryContentType.MEMORY_RECORDS, level: StreamDeliveryContentLevel.METADATA_ONLY }, + ], + }, + ], + }); + }).toThrow('Stream delivery resource currently supports at most one content configuration'); + }); + + test('Should throw error for empty content configurations array', () => { + const stream = new kinesis.Stream(stack, 'EmptyConfigStream'); + + expect(() => { + new Memory(stack, 'empty-config-memory', { + memoryName: 'empty_config_memory', + streamDeliveryResources: [ + { + stream, + contentConfigurations: [], + }, + ], + }); + }).toThrow('Stream delivery resource contentConfigurations must not be an empty array'); + }); + + test('Should throw error when adding more than one stream delivery resource', () => { + const stream1 = new kinesis.Stream(stack, 'Stream1'); + const stream2 = new kinesis.Stream(stack, 'Stream2'); + + const memory = new Memory(stack, 'test-memory', { + memoryName: 'test_memory', + streamDeliveryResources: [ + { + stream: stream1, + contentConfigurations: [ + { type: StreamDeliveryContentType.MEMORY_RECORDS }, + ], + }, + ], + }); + + expect(() => { + memory.addStreamDeliveryResource({ + stream: stream2, + contentConfigurations: [ + { type: StreamDeliveryContentType.MEMORY_RECORDS }, + ], + }); + }).toThrow('Memory currently supports at most one stream delivery resource'); + }); + + test('Should not include StreamDeliveryResources when not configured', () => { + new Memory(stack, 'no-stream-memory', { + memoryName: 'no_stream_memory', + }); + + app.synth(); + const template = Template.fromStack(stack); + + const memoryResources = template.findResources('AWS::BedrockAgentCore::Memory'); + const memoryResource = Object.values(memoryResources)[0]; + expect(memoryResource.Properties.StreamDeliveryResources).toBeUndefined(); + }); + + test('Should handle content configuration without level (optional)', () => { + const stream = new kinesis.Stream(stack, 'NoLevelStream'); + + new Memory(stack, 'no-level-memory', { + memoryName: 'no_level_memory', + streamDeliveryResources: [ + { + stream, + contentConfigurations: [ + { type: StreamDeliveryContentType.MEMORY_RECORDS }, + ], + }, + ], + }); + + app.synth(); + const template = Template.fromStack(stack); + + template.hasResourceProperties('AWS::BedrockAgentCore::Memory', { + StreamDeliveryResources: { + Resources: [ + { + Kinesis: { + ContentConfigurations: [ + { + Type: 'MEMORY_RECORDS', + }, + ], + }, + }, + ], + }, + }); + }); +}); + +describe('Memory with KMS-encrypted Kinesis stream tests', () => { + let template: Template; + let app: cdk.App; + let stack: cdk.Stack; + + beforeAll(() => { + app = new cdk.App(); + stack = new cdk.Stack(app, 'test-stack', { + env: { + account: '123456789012', + region: 'us-east-1', + }, + }); + + const kmsKey = new kms.Key(stack, 'StreamEncryptionKey'); + const stream = new kinesis.Stream(stack, 'EncryptedStream', { + encryptionKey: kmsKey, + }); + + new Memory(stack, 'test-memory', { + memoryName: 'test_memory_kms_stream', + streamDeliveryResources: [ + { + stream, + contentConfigurations: [ + { type: StreamDeliveryContentType.MEMORY_RECORDS, level: StreamDeliveryContentLevel.FULL_CONTENT }, + ], + }, + ], + }); + + app.synth(); + template = Template.fromStack(stack); + }); + + test('Should grant KMS permissions when stream uses customer-managed key', () => { + template.hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: Match.arrayWith([ + Match.objectLike({ + Effect: 'Allow', + Action: Match.arrayWith([ + 'kms:Encrypt', + 'kms:ReEncrypt*', + 'kms:GenerateDataKey*', + ]), + }), + ]), + }, + }); + }); +});