aws-solutions-constructs.aws-lambda-bedrockinferenceprofile 2.84.0__tar.gz

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 (16) hide show
  1. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/LICENSE +73 -0
  2. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/MANIFEST.in +1 -0
  3. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/PKG-INFO +144 -0
  4. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/README.md +117 -0
  5. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/pyproject.toml +9 -0
  6. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/setup.cfg +4 -0
  7. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/setup.py +64 -0
  8. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/__init__.py +478 -0
  9. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/__init__.py +46 -0
  10. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/aws-lambda-bedrockinferenceprofile@2.84.0.jsii.tgz +0 -0
  11. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/py.typed +1 -0
  12. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/PKG-INFO +144 -0
  13. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/SOURCES.txt +14 -0
  14. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/dependency_links.txt +1 -0
  15. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/requires.txt +6 -0
  16. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.84.0/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/top_level.txt +1 -0
@@ -0,0 +1,73 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
42
+
43
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ APPENDIX: How to apply the Apache License to your work.
58
+
59
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
+
61
+ Copyright [yyyy] [name of copyright owner]
62
+
63
+ Licensed under the Apache License, Version 2.0 (the "License");
64
+ you may not use this file except in compliance with the License.
65
+ You may obtain a copy of the License at
66
+
67
+ http://www.apache.org/licenses/LICENSE-2.0
68
+
69
+ Unless required by applicable law or agreed to in writing, software
70
+ distributed under the License is distributed on an "AS IS" BASIS,
71
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72
+ See the License for the specific language governing permissions and
73
+ limitations under the License.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.1
2
+ Name: aws-solutions-constructs.aws-lambda-bedrockinferenceprofile
3
+ Version: 2.84.0
4
+ Summary: CDK constructs for defining an interaction between an AWS Lambda function and an Amazon Bedrock inference profile.
5
+ Home-page: https://github.com/awslabs/aws-solutions-constructs.git
6
+ Author: Amazon Web Services
7
+ License: Apache-2.0
8
+ Project-URL: Source, https://github.com/awslabs/aws-solutions-constructs.git
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: JavaScript
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Typing :: Typed
17
+ Classifier: License :: OSI Approved
18
+ Requires-Python: ~=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: aws-cdk-lib<3.0.0,>=2.190.0
22
+ Requires-Dist: aws-solutions-constructs.core==2.84.0
23
+ Requires-Dist: constructs<11.0.0,>=10.0.0
24
+ Requires-Dist: jsii<2.0.0,>=1.110.0
25
+ Requires-Dist: publication>=0.0.3
26
+ Requires-Dist: typeguard<4.3.0,>=2.13.3
27
+
28
+ # aws-lambda-bedrockinferenceprofile module
29
+
30
+ <!--BEGIN STABILITY BANNER-->---
31
+
32
+
33
+ ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
34
+
35
+ > All classes are under active development and subject to non-backward compatible changes or removal in any
36
+ > future version. These are not subject to the [Semantic Versioning](https://semver.org/) model.
37
+ > This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
38
+
39
+ ---
40
+ <!--END STABILITY BANNER-->
41
+
42
+ | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
43
+ |:-------------|:-------------|
44
+
45
+ <div style="height:8px"></div>
46
+
47
+ | **Language** | **Package** |
48
+ |:-------------|-----------------|
49
+ |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_lambda_bedrockinferenceprofile`|
50
+ |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile`|
51
+ |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.lambdabedrockinferenceprofile`|
52
+
53
+ ## Overview
54
+
55
+ This AWS Solutions Construct implements a Lambda function granted access to a new Bedrock Inference Profile. [Inference profiles](https://aws.amazon.com/blogs/machine-learning/getting-started-with-cross-region-inference-in-amazon-bedrock/) allow:
56
+
57
+ * Greater scalability of applications by distributing Bedrock Invoke calls across multiple regions
58
+ * Cost management by adding Cost Allocation Tags to an inference to track costs for specific applications.
59
+
60
+ Here is a minimal deployable pattern definition:
61
+
62
+ Typescript
63
+
64
+ ```python
65
+ import { Construct } from 'constructs';
66
+ import { Stack, StackProps } from 'aws-cdk-lib';
67
+ import { LambdaToBedrockInferenceProfile } from "@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile";
68
+ import * as lambda from 'aws-cdk-lib/aws-lambda';
69
+
70
+ new LambdaToBedrockInferenceProfile(this, 'LambdaToBedrockPattern', {
71
+ lambdaFunctionProps: {
72
+ runtime: lambda.Runtime.NODEJS_20_X,
73
+ handler: 'index.handler',
74
+ code: lambda.Code.fromAsset(`lambda`)
75
+ },
76
+ model: "amazon.nova-lite-v1:0"
77
+ });
78
+ ```
79
+
80
+ Python
81
+
82
+ ```python
83
+ # TBD
84
+ ```
85
+
86
+ Java
87
+
88
+ ```java
89
+ // TBD
90
+ ```
91
+
92
+ ## Pattern Construct Props
93
+
94
+ | **Name** | **Type** | **Description** |
95
+ |:-------------|:----------------|-----------------|
96
+ |existingLambdaObj?|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html)|Existing instance of Lambda Function object, providing both this and `lambdaFunctionProps` will cause an error.|
97
+ |lambdaFunctionProps?|[`lambda.FunctionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.FunctionProps.html)|Optional user provided props to override the default props for the Lambda function.|
98
+ |existingVpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html)|An optional, existing VPC into which this pattern should be deployed. When deployed in a VPC, the Lambda function will use ENIs in the VPC to access network resources and an Interface Endpoint will be created in the VPC for Amazon Bedrock and Bedrock-Runtime. If an existing VPC is provided, the `deployVpc` property cannot be `true`. This uses `ec2.IVpc` to allow clients to supply VPCs that exist outside the stack using the [`ec2.Vpc.fromLookup()`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Vpc.html#static-fromwbrlookupscope-id-options) method.|
99
+ |vpcProps?|[`ec2.VpcProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.VpcProps.html)|Optional user provided properties to override the default properties for the new VPC. `enableDnsHostnames`, `enableDnsSupport`, `natGateways` and `subnetConfiguration` are set by the pattern, so any values for those properties supplied here will be overridden. If `deployVpc` is not `true` then this property will be ignored.|
100
+ |deployVpc?|`boolean`|Whether to create a new VPC based on `vpcProps` into which to deploy this pattern. Setting this to true will deploy the minimal, most private VPC to run the pattern:<ul><li> One isolated subnet in each Availability Zone used by the CDK program</li><li>`enableDnsHostnames` and `enableDnsSupport` will both be set to true</li></ul>If this property is `true` then `existingVpc` cannot be specified. Defaults to `false`.|
101
+ |bedrockModelId|`string`|The foundation model to use with the inference profile. Depending on whether the deployment is cross region or single region, he construct will create the correct inference profile name and and assign IAM permissions to the Lambda function allowing access to the foundation model in all appropriate regions. For all of this to occur, the model must be specified here and *not* in `inferenceProfileProps`. Be certain that the account is granted access to the foundation model in [all the regions covered by the cross-region inference profile](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html).|
102
+ |inferenceProfileProps?|[`bedrock.CfnApplicationInferenceProfileProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnApplicationInferenceProfileProps.html)|This is where you set tags required for tracking inference calls. Do not populate the copyFrom attribute - the construct will populate this based upon the model sent in bedrockModelId (this allows the construct to correctly create all the other dependencies like the required IAM policies). If the copyFrom attribute is supplied here the construct will throw an error. The construct will also set a unique, stack specific inferenceProfileName - you may override that name here, but it is not recommended.
103
+ |deployCrossRegionProfile|boolean| Whether to deploy a cross-region inference profile that will automatically distribute Invoke calls across multiple regions. Note that at the time of this writing, cross-region profiles are only available in [US, EMEA and APAC](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html). Single region profiles are available in every region supporting Bedrock models. Defaults to `true`|
104
+ |foundationModelEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the Model name. Defaults to BEDROCK_MODEL|
105
+ |inferenceProfileEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the inference profile arn. Defaults to BEDROCK_PROFILE|
106
+
107
+ ## Pattern Properties
108
+
109
+ | **Name** | **Type** | **Description** |
110
+ |:-------------|:----------------|-----------------|
111
+ |lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html)|Returns an instance of the Lambda function created by the pattern.|
112
+ |inferenceProfile|[`CfnApplicationInferenceProfile`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnApplicationInferenceProfile.html)|The inference profile created by the construct.|
113
+ |vpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html)|Returns an interface on the VPC used by the pattern (if any). This may be a VPC created by the pattern or the VPC supplied to the pattern constructor.|
114
+
115
+ ## Default settings
116
+
117
+ Out of the box implementation of the Construct without any override will set the following defaults:
118
+
119
+ ### AWS Lambda Function
120
+
121
+ * Configure limited privilege access IAM role for Lambda function, granting Invoke privileges for:
122
+
123
+ * The new inference profile
124
+ * The appropriate foundation model in all regions in the geographic area. For single region inference profiles, access is only granted to model in the current region.
125
+ * Enable reusing connections with Keep-Alive for NodeJs Lambda function
126
+ * Enable X-Ray Tracing
127
+ * Set Environment Variables
128
+
129
+ * (default) BEDROCK_PROFILE
130
+ * (default) BEDROCK_MODEL
131
+
132
+ ### Amazon Bedrock Inference Profile
133
+
134
+ * Cross-region inference profile for provided model by default
135
+ * Geographic area prefix in arn defaults to value appropriate for deployment region (e.g. would us 'us' for us-east-1 deployment)
136
+
137
+ ## Architecture
138
+
139
+ ![Architecture Diagram](architecture.png)
140
+
141
+ ---
142
+
143
+
144
+ © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -0,0 +1,117 @@
1
+ # aws-lambda-bedrockinferenceprofile module
2
+
3
+ <!--BEGIN STABILITY BANNER-->---
4
+
5
+
6
+ ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
7
+
8
+ > All classes are under active development and subject to non-backward compatible changes or removal in any
9
+ > future version. These are not subject to the [Semantic Versioning](https://semver.org/) model.
10
+ > This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
11
+
12
+ ---
13
+ <!--END STABILITY BANNER-->
14
+
15
+ | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
16
+ |:-------------|:-------------|
17
+
18
+ <div style="height:8px"></div>
19
+
20
+ | **Language** | **Package** |
21
+ |:-------------|-----------------|
22
+ |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_lambda_bedrockinferenceprofile`|
23
+ |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile`|
24
+ |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.lambdabedrockinferenceprofile`|
25
+
26
+ ## Overview
27
+
28
+ This AWS Solutions Construct implements a Lambda function granted access to a new Bedrock Inference Profile. [Inference profiles](https://aws.amazon.com/blogs/machine-learning/getting-started-with-cross-region-inference-in-amazon-bedrock/) allow:
29
+
30
+ * Greater scalability of applications by distributing Bedrock Invoke calls across multiple regions
31
+ * Cost management by adding Cost Allocation Tags to an inference to track costs for specific applications.
32
+
33
+ Here is a minimal deployable pattern definition:
34
+
35
+ Typescript
36
+
37
+ ```python
38
+ import { Construct } from 'constructs';
39
+ import { Stack, StackProps } from 'aws-cdk-lib';
40
+ import { LambdaToBedrockInferenceProfile } from "@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile";
41
+ import * as lambda from 'aws-cdk-lib/aws-lambda';
42
+
43
+ new LambdaToBedrockInferenceProfile(this, 'LambdaToBedrockPattern', {
44
+ lambdaFunctionProps: {
45
+ runtime: lambda.Runtime.NODEJS_20_X,
46
+ handler: 'index.handler',
47
+ code: lambda.Code.fromAsset(`lambda`)
48
+ },
49
+ model: "amazon.nova-lite-v1:0"
50
+ });
51
+ ```
52
+
53
+ Python
54
+
55
+ ```python
56
+ # TBD
57
+ ```
58
+
59
+ Java
60
+
61
+ ```java
62
+ // TBD
63
+ ```
64
+
65
+ ## Pattern Construct Props
66
+
67
+ | **Name** | **Type** | **Description** |
68
+ |:-------------|:----------------|-----------------|
69
+ |existingLambdaObj?|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html)|Existing instance of Lambda Function object, providing both this and `lambdaFunctionProps` will cause an error.|
70
+ |lambdaFunctionProps?|[`lambda.FunctionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.FunctionProps.html)|Optional user provided props to override the default props for the Lambda function.|
71
+ |existingVpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html)|An optional, existing VPC into which this pattern should be deployed. When deployed in a VPC, the Lambda function will use ENIs in the VPC to access network resources and an Interface Endpoint will be created in the VPC for Amazon Bedrock and Bedrock-Runtime. If an existing VPC is provided, the `deployVpc` property cannot be `true`. This uses `ec2.IVpc` to allow clients to supply VPCs that exist outside the stack using the [`ec2.Vpc.fromLookup()`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Vpc.html#static-fromwbrlookupscope-id-options) method.|
72
+ |vpcProps?|[`ec2.VpcProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.VpcProps.html)|Optional user provided properties to override the default properties for the new VPC. `enableDnsHostnames`, `enableDnsSupport`, `natGateways` and `subnetConfiguration` are set by the pattern, so any values for those properties supplied here will be overridden. If `deployVpc` is not `true` then this property will be ignored.|
73
+ |deployVpc?|`boolean`|Whether to create a new VPC based on `vpcProps` into which to deploy this pattern. Setting this to true will deploy the minimal, most private VPC to run the pattern:<ul><li> One isolated subnet in each Availability Zone used by the CDK program</li><li>`enableDnsHostnames` and `enableDnsSupport` will both be set to true</li></ul>If this property is `true` then `existingVpc` cannot be specified. Defaults to `false`.|
74
+ |bedrockModelId|`string`|The foundation model to use with the inference profile. Depending on whether the deployment is cross region or single region, he construct will create the correct inference profile name and and assign IAM permissions to the Lambda function allowing access to the foundation model in all appropriate regions. For all of this to occur, the model must be specified here and *not* in `inferenceProfileProps`. Be certain that the account is granted access to the foundation model in [all the regions covered by the cross-region inference profile](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html).|
75
+ |inferenceProfileProps?|[`bedrock.CfnApplicationInferenceProfileProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnApplicationInferenceProfileProps.html)|This is where you set tags required for tracking inference calls. Do not populate the copyFrom attribute - the construct will populate this based upon the model sent in bedrockModelId (this allows the construct to correctly create all the other dependencies like the required IAM policies). If the copyFrom attribute is supplied here the construct will throw an error. The construct will also set a unique, stack specific inferenceProfileName - you may override that name here, but it is not recommended.
76
+ |deployCrossRegionProfile|boolean| Whether to deploy a cross-region inference profile that will automatically distribute Invoke calls across multiple regions. Note that at the time of this writing, cross-region profiles are only available in [US, EMEA and APAC](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html). Single region profiles are available in every region supporting Bedrock models. Defaults to `true`|
77
+ |foundationModelEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the Model name. Defaults to BEDROCK_MODEL|
78
+ |inferenceProfileEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the inference profile arn. Defaults to BEDROCK_PROFILE|
79
+
80
+ ## Pattern Properties
81
+
82
+ | **Name** | **Type** | **Description** |
83
+ |:-------------|:----------------|-----------------|
84
+ |lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html)|Returns an instance of the Lambda function created by the pattern.|
85
+ |inferenceProfile|[`CfnApplicationInferenceProfile`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnApplicationInferenceProfile.html)|The inference profile created by the construct.|
86
+ |vpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html)|Returns an interface on the VPC used by the pattern (if any). This may be a VPC created by the pattern or the VPC supplied to the pattern constructor.|
87
+
88
+ ## Default settings
89
+
90
+ Out of the box implementation of the Construct without any override will set the following defaults:
91
+
92
+ ### AWS Lambda Function
93
+
94
+ * Configure limited privilege access IAM role for Lambda function, granting Invoke privileges for:
95
+
96
+ * The new inference profile
97
+ * The appropriate foundation model in all regions in the geographic area. For single region inference profiles, access is only granted to model in the current region.
98
+ * Enable reusing connections with Keep-Alive for NodeJs Lambda function
99
+ * Enable X-Ray Tracing
100
+ * Set Environment Variables
101
+
102
+ * (default) BEDROCK_PROFILE
103
+ * (default) BEDROCK_MODEL
104
+
105
+ ### Amazon Bedrock Inference Profile
106
+
107
+ * Cross-region inference profile for provided model by default
108
+ * Geographic area prefix in arn defaults to value appropriate for deployment region (e.g. would us 'us' for us-east-1 deployment)
109
+
110
+ ## Architecture
111
+
112
+ ![Architecture Diagram](architecture.png)
113
+
114
+ ---
115
+
116
+
117
+ © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -0,0 +1,9 @@
1
+ [build-system]
2
+ requires = ["setuptools~=75.3.2", "wheel~=0.42"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.pyright]
6
+ defineConstant = { DEBUG = true }
7
+ pythonVersion = "3.9"
8
+ pythonPlatform = "All"
9
+ reportSelfClsParameterName = false
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,64 @@
1
+ import json
2
+ import setuptools
3
+
4
+ kwargs = json.loads(
5
+ """
6
+ {
7
+ "name": "aws-solutions-constructs.aws-lambda-bedrockinferenceprofile",
8
+ "version": "2.84.0",
9
+ "description": "CDK constructs for defining an interaction between an AWS Lambda function and an Amazon Bedrock inference profile.",
10
+ "license": "Apache-2.0",
11
+ "url": "https://github.com/awslabs/aws-solutions-constructs.git",
12
+ "long_description_content_type": "text/markdown",
13
+ "author": "Amazon Web Services",
14
+ "bdist_wheel": {
15
+ "universal": true
16
+ },
17
+ "project_urls": {
18
+ "Source": "https://github.com/awslabs/aws-solutions-constructs.git"
19
+ },
20
+ "package_dir": {
21
+ "": "src"
22
+ },
23
+ "packages": [
24
+ "aws_solutions_constructs.aws_lambda_bedrockinferenceprofile",
25
+ "aws_solutions_constructs.aws_lambda_bedrockinferenceprofile._jsii"
26
+ ],
27
+ "package_data": {
28
+ "aws_solutions_constructs.aws_lambda_bedrockinferenceprofile._jsii": [
29
+ "aws-lambda-bedrockinferenceprofile@2.84.0.jsii.tgz"
30
+ ],
31
+ "aws_solutions_constructs.aws_lambda_bedrockinferenceprofile": [
32
+ "py.typed"
33
+ ]
34
+ },
35
+ "python_requires": "~=3.9",
36
+ "install_requires": [
37
+ "aws-cdk-lib>=2.190.0, <3.0.0",
38
+ "aws-solutions-constructs.core==2.84.0",
39
+ "constructs>=10.0.0, <11.0.0",
40
+ "jsii>=1.110.0, <2.0.0",
41
+ "publication>=0.0.3",
42
+ "typeguard>=2.13.3,<4.3.0"
43
+ ],
44
+ "classifiers": [
45
+ "Intended Audience :: Developers",
46
+ "Operating System :: OS Independent",
47
+ "Programming Language :: JavaScript",
48
+ "Programming Language :: Python :: 3 :: Only",
49
+ "Programming Language :: Python :: 3.9",
50
+ "Programming Language :: Python :: 3.10",
51
+ "Programming Language :: Python :: 3.11",
52
+ "Typing :: Typed",
53
+ "License :: OSI Approved"
54
+ ],
55
+ "scripts": []
56
+ }
57
+ """
58
+ )
59
+
60
+ with open("README.md", encoding="utf8") as fp:
61
+ kwargs["long_description"] = fp.read()
62
+
63
+
64
+ setuptools.setup(**kwargs)
@@ -0,0 +1,478 @@
1
+ r'''
2
+ # aws-lambda-bedrockinferenceprofile module
3
+
4
+ <!--BEGIN STABILITY BANNER-->---
5
+
6
+
7
+ ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
8
+
9
+ > All classes are under active development and subject to non-backward compatible changes or removal in any
10
+ > future version. These are not subject to the [Semantic Versioning](https://semver.org/) model.
11
+ > This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
12
+
13
+ ---
14
+ <!--END STABILITY BANNER-->
15
+
16
+ | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
17
+ |:-------------|:-------------|
18
+
19
+ <div style="height:8px"></div>
20
+
21
+ | **Language** | **Package** |
22
+ |:-------------|-----------------|
23
+ |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_lambda_bedrockinferenceprofile`|
24
+ |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile`|
25
+ |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.lambdabedrockinferenceprofile`|
26
+
27
+ ## Overview
28
+
29
+ This AWS Solutions Construct implements a Lambda function granted access to a new Bedrock Inference Profile. [Inference profiles](https://aws.amazon.com/blogs/machine-learning/getting-started-with-cross-region-inference-in-amazon-bedrock/) allow:
30
+
31
+ * Greater scalability of applications by distributing Bedrock Invoke calls across multiple regions
32
+ * Cost management by adding Cost Allocation Tags to an inference to track costs for specific applications.
33
+
34
+ Here is a minimal deployable pattern definition:
35
+
36
+ Typescript
37
+
38
+ ```python
39
+ import { Construct } from 'constructs';
40
+ import { Stack, StackProps } from 'aws-cdk-lib';
41
+ import { LambdaToBedrockInferenceProfile } from "@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile";
42
+ import * as lambda from 'aws-cdk-lib/aws-lambda';
43
+
44
+ new LambdaToBedrockInferenceProfile(this, 'LambdaToBedrockPattern', {
45
+ lambdaFunctionProps: {
46
+ runtime: lambda.Runtime.NODEJS_20_X,
47
+ handler: 'index.handler',
48
+ code: lambda.Code.fromAsset(`lambda`)
49
+ },
50
+ model: "amazon.nova-lite-v1:0"
51
+ });
52
+ ```
53
+
54
+ Python
55
+
56
+ ```python
57
+ # TBD
58
+ ```
59
+
60
+ Java
61
+
62
+ ```java
63
+ // TBD
64
+ ```
65
+
66
+ ## Pattern Construct Props
67
+
68
+ | **Name** | **Type** | **Description** |
69
+ |:-------------|:----------------|-----------------|
70
+ |existingLambdaObj?|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html)|Existing instance of Lambda Function object, providing both this and `lambdaFunctionProps` will cause an error.|
71
+ |lambdaFunctionProps?|[`lambda.FunctionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.FunctionProps.html)|Optional user provided props to override the default props for the Lambda function.|
72
+ |existingVpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html)|An optional, existing VPC into which this pattern should be deployed. When deployed in a VPC, the Lambda function will use ENIs in the VPC to access network resources and an Interface Endpoint will be created in the VPC for Amazon Bedrock and Bedrock-Runtime. If an existing VPC is provided, the `deployVpc` property cannot be `true`. This uses `ec2.IVpc` to allow clients to supply VPCs that exist outside the stack using the [`ec2.Vpc.fromLookup()`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Vpc.html#static-fromwbrlookupscope-id-options) method.|
73
+ |vpcProps?|[`ec2.VpcProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.VpcProps.html)|Optional user provided properties to override the default properties for the new VPC. `enableDnsHostnames`, `enableDnsSupport`, `natGateways` and `subnetConfiguration` are set by the pattern, so any values for those properties supplied here will be overridden. If `deployVpc` is not `true` then this property will be ignored.|
74
+ |deployVpc?|`boolean`|Whether to create a new VPC based on `vpcProps` into which to deploy this pattern. Setting this to true will deploy the minimal, most private VPC to run the pattern:<ul><li> One isolated subnet in each Availability Zone used by the CDK program</li><li>`enableDnsHostnames` and `enableDnsSupport` will both be set to true</li></ul>If this property is `true` then `existingVpc` cannot be specified. Defaults to `false`.|
75
+ |bedrockModelId|`string`|The foundation model to use with the inference profile. Depending on whether the deployment is cross region or single region, he construct will create the correct inference profile name and and assign IAM permissions to the Lambda function allowing access to the foundation model in all appropriate regions. For all of this to occur, the model must be specified here and *not* in `inferenceProfileProps`. Be certain that the account is granted access to the foundation model in [all the regions covered by the cross-region inference profile](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html).|
76
+ |inferenceProfileProps?|[`bedrock.CfnApplicationInferenceProfileProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnApplicationInferenceProfileProps.html)|This is where you set tags required for tracking inference calls. Do not populate the copyFrom attribute - the construct will populate this based upon the model sent in bedrockModelId (this allows the construct to correctly create all the other dependencies like the required IAM policies). If the copyFrom attribute is supplied here the construct will throw an error. The construct will also set a unique, stack specific inferenceProfileName - you may override that name here, but it is not recommended.
77
+ |deployCrossRegionProfile|boolean| Whether to deploy a cross-region inference profile that will automatically distribute Invoke calls across multiple regions. Note that at the time of this writing, cross-region profiles are only available in [US, EMEA and APAC](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html). Single region profiles are available in every region supporting Bedrock models. Defaults to `true`|
78
+ |foundationModelEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the Model name. Defaults to BEDROCK_MODEL|
79
+ |inferenceProfileEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the inference profile arn. Defaults to BEDROCK_PROFILE|
80
+
81
+ ## Pattern Properties
82
+
83
+ | **Name** | **Type** | **Description** |
84
+ |:-------------|:----------------|-----------------|
85
+ |lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html)|Returns an instance of the Lambda function created by the pattern.|
86
+ |inferenceProfile|[`CfnApplicationInferenceProfile`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnApplicationInferenceProfile.html)|The inference profile created by the construct.|
87
+ |vpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html)|Returns an interface on the VPC used by the pattern (if any). This may be a VPC created by the pattern or the VPC supplied to the pattern constructor.|
88
+
89
+ ## Default settings
90
+
91
+ Out of the box implementation of the Construct without any override will set the following defaults:
92
+
93
+ ### AWS Lambda Function
94
+
95
+ * Configure limited privilege access IAM role for Lambda function, granting Invoke privileges for:
96
+
97
+ * The new inference profile
98
+ * The appropriate foundation model in all regions in the geographic area. For single region inference profiles, access is only granted to model in the current region.
99
+ * Enable reusing connections with Keep-Alive for NodeJs Lambda function
100
+ * Enable X-Ray Tracing
101
+ * Set Environment Variables
102
+
103
+ * (default) BEDROCK_PROFILE
104
+ * (default) BEDROCK_MODEL
105
+
106
+ ### Amazon Bedrock Inference Profile
107
+
108
+ * Cross-region inference profile for provided model by default
109
+ * Geographic area prefix in arn defaults to value appropriate for deployment region (e.g. would us 'us' for us-east-1 deployment)
110
+
111
+ ## Architecture
112
+
113
+ ![Architecture Diagram](architecture.png)
114
+
115
+ ---
116
+
117
+
118
+ © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
119
+ '''
120
+ from pkgutil import extend_path
121
+ __path__ = extend_path(__path__, __name__)
122
+
123
+ import abc
124
+ import builtins
125
+ import datetime
126
+ import enum
127
+ import typing
128
+
129
+ import jsii
130
+ import publication
131
+ import typing_extensions
132
+
133
+ import typeguard
134
+ from importlib.metadata import version as _metadata_package_version
135
+ TYPEGUARD_MAJOR_VERSION = int(_metadata_package_version('typeguard').split('.')[0])
136
+
137
+ def check_type(argname: str, value: object, expected_type: typing.Any) -> typing.Any:
138
+ if TYPEGUARD_MAJOR_VERSION <= 2:
139
+ return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore
140
+ else:
141
+ if isinstance(value, jsii._reference_map.InterfaceDynamicProxy): # pyright: ignore [reportAttributeAccessIssue]
142
+ pass
143
+ else:
144
+ if TYPEGUARD_MAJOR_VERSION == 3:
145
+ typeguard.config.collection_check_strategy = typeguard.CollectionCheckStrategy.ALL_ITEMS # type:ignore
146
+ typeguard.check_type(value=value, expected_type=expected_type) # type:ignore
147
+ else:
148
+ typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore
149
+
150
+ from ._jsii import *
151
+
152
+ import aws_cdk.aws_bedrock as _aws_cdk_aws_bedrock_ceddda9d
153
+ import aws_cdk.aws_ec2 as _aws_cdk_aws_ec2_ceddda9d
154
+ import aws_cdk.aws_lambda as _aws_cdk_aws_lambda_ceddda9d
155
+ import constructs as _constructs_77d1e7e8
156
+
157
+
158
+ class LambdaToBedrockinferenceprofile(
159
+ _constructs_77d1e7e8.Construct,
160
+ metaclass=jsii.JSIIMeta,
161
+ jsii_type="@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile.LambdaToBedrockinferenceprofile",
162
+ ):
163
+ '''
164
+ :summary: The LambdaToBedrockinferenceprofile class.
165
+ '''
166
+
167
+ def __init__(
168
+ self,
169
+ scope: _constructs_77d1e7e8.Construct,
170
+ id: builtins.str,
171
+ *,
172
+ bedrock_model_id: builtins.str,
173
+ deploy_cross_region_profile: typing.Optional[builtins.bool] = None,
174
+ deploy_vpc: typing.Optional[builtins.bool] = None,
175
+ existing_lambda_obj: typing.Optional[_aws_cdk_aws_lambda_ceddda9d.Function] = None,
176
+ existing_vpc: typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc] = None,
177
+ foundation_model_environment_variable_name: typing.Optional[builtins.str] = None,
178
+ inference_profile_environment_variable_name: typing.Optional[builtins.str] = None,
179
+ inference_profile_props: typing.Optional[typing.Union[_aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfileProps, typing.Dict[builtins.str, typing.Any]]] = None,
180
+ lambda_function_props: typing.Optional[typing.Union[_aws_cdk_aws_lambda_ceddda9d.FunctionProps, typing.Dict[builtins.str, typing.Any]]] = None,
181
+ vpc_props: typing.Optional[typing.Union[_aws_cdk_aws_ec2_ceddda9d.VpcProps, typing.Dict[builtins.str, typing.Any]]] = None,
182
+ ) -> None:
183
+ '''
184
+ :param scope: - represents the scope for all the resources.
185
+ :param id: - this is a a scope-unique id.
186
+ :param bedrock_model_id: The foundation model to use with the inference profile. The construct will validate the model name, create the correct inference profile name based on the region and remind the developer in which regions the model must be available for this profile. Be certain that the account is granted access to the foundation model in all the regions covered by cross-region inference profile
187
+ :param deploy_cross_region_profile: Whether to deploy a cross-region inference profile that will automatically distribute Invoke calls across multiple regions. Default: - true
188
+ :param deploy_vpc: Whether to deploy a new VPC. Default: - false
189
+ :param existing_lambda_obj: Existing instance of Lambda Function object, providing both this and ``lambdaFunctionProps`` will cause an error. Default: - None
190
+ :param existing_vpc: An existing VPC for the construct to use (construct will NOT create a new VPC in this case).
191
+ :param foundation_model_environment_variable_name: Optional Name for the Lambda function environment variable set to the Model name. Default: - BEDROCK_MODEL
192
+ :param inference_profile_environment_variable_name: Optional Name for the Lambda function environment variable set to the inference profile arn. Default: - BEDROCK_PROFILE
193
+ :param inference_profile_props: Properties to override constructs props values for the Inference Profile. The construct will populate inverenceProfileName - so don't override it unless you have an very good reason. The construct base IAM policies around the modelSource that it creates, so trying to send a modelSource in ths parameter will cause an error. This is where you set tags required for tracking inference calls.
194
+ :param lambda_function_props: User provided props to override the default props for the Lambda function. Default: - Default properties are used.
195
+ :param vpc_props: Properties to override default properties if deployVpc is true.
196
+
197
+ :access: public
198
+ :since: 0.8.0
199
+ :summary: Constructs a new instance of the LambdaToSns class.
200
+ '''
201
+ if __debug__:
202
+ type_hints = typing.get_type_hints(_typecheckingstub__3f146eecba713ed1ed7bed25607c92b6cdce670262bf0c10ad465027e80d1370)
203
+ check_type(argname="argument scope", value=scope, expected_type=type_hints["scope"])
204
+ check_type(argname="argument id", value=id, expected_type=type_hints["id"])
205
+ props = LambdaToBedrockinferenceprofileProps(
206
+ bedrock_model_id=bedrock_model_id,
207
+ deploy_cross_region_profile=deploy_cross_region_profile,
208
+ deploy_vpc=deploy_vpc,
209
+ existing_lambda_obj=existing_lambda_obj,
210
+ existing_vpc=existing_vpc,
211
+ foundation_model_environment_variable_name=foundation_model_environment_variable_name,
212
+ inference_profile_environment_variable_name=inference_profile_environment_variable_name,
213
+ inference_profile_props=inference_profile_props,
214
+ lambda_function_props=lambda_function_props,
215
+ vpc_props=vpc_props,
216
+ )
217
+
218
+ jsii.create(self.__class__, self, [scope, id, props])
219
+
220
+ @builtins.property
221
+ @jsii.member(jsii_name="inferenceProfile")
222
+ def inference_profile(
223
+ self,
224
+ ) -> _aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfile:
225
+ return typing.cast(_aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfile, jsii.get(self, "inferenceProfile"))
226
+
227
+ @builtins.property
228
+ @jsii.member(jsii_name="lambdaFunction")
229
+ def lambda_function(self) -> _aws_cdk_aws_lambda_ceddda9d.Function:
230
+ return typing.cast(_aws_cdk_aws_lambda_ceddda9d.Function, jsii.get(self, "lambdaFunction"))
231
+
232
+ @builtins.property
233
+ @jsii.member(jsii_name="vpc")
234
+ def vpc(self) -> typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc]:
235
+ return typing.cast(typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc], jsii.get(self, "vpc"))
236
+
237
+
238
+ @jsii.data_type(
239
+ jsii_type="@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile.LambdaToBedrockinferenceprofileProps",
240
+ jsii_struct_bases=[],
241
+ name_mapping={
242
+ "bedrock_model_id": "bedrockModelId",
243
+ "deploy_cross_region_profile": "deployCrossRegionProfile",
244
+ "deploy_vpc": "deployVpc",
245
+ "existing_lambda_obj": "existingLambdaObj",
246
+ "existing_vpc": "existingVpc",
247
+ "foundation_model_environment_variable_name": "foundationModelEnvironmentVariableName",
248
+ "inference_profile_environment_variable_name": "inferenceProfileEnvironmentVariableName",
249
+ "inference_profile_props": "inferenceProfileProps",
250
+ "lambda_function_props": "lambdaFunctionProps",
251
+ "vpc_props": "vpcProps",
252
+ },
253
+ )
254
+ class LambdaToBedrockinferenceprofileProps:
255
+ def __init__(
256
+ self,
257
+ *,
258
+ bedrock_model_id: builtins.str,
259
+ deploy_cross_region_profile: typing.Optional[builtins.bool] = None,
260
+ deploy_vpc: typing.Optional[builtins.bool] = None,
261
+ existing_lambda_obj: typing.Optional[_aws_cdk_aws_lambda_ceddda9d.Function] = None,
262
+ existing_vpc: typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc] = None,
263
+ foundation_model_environment_variable_name: typing.Optional[builtins.str] = None,
264
+ inference_profile_environment_variable_name: typing.Optional[builtins.str] = None,
265
+ inference_profile_props: typing.Optional[typing.Union[_aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfileProps, typing.Dict[builtins.str, typing.Any]]] = None,
266
+ lambda_function_props: typing.Optional[typing.Union[_aws_cdk_aws_lambda_ceddda9d.FunctionProps, typing.Dict[builtins.str, typing.Any]]] = None,
267
+ vpc_props: typing.Optional[typing.Union[_aws_cdk_aws_ec2_ceddda9d.VpcProps, typing.Dict[builtins.str, typing.Any]]] = None,
268
+ ) -> None:
269
+ '''
270
+ :param bedrock_model_id: The foundation model to use with the inference profile. The construct will validate the model name, create the correct inference profile name based on the region and remind the developer in which regions the model must be available for this profile. Be certain that the account is granted access to the foundation model in all the regions covered by cross-region inference profile
271
+ :param deploy_cross_region_profile: Whether to deploy a cross-region inference profile that will automatically distribute Invoke calls across multiple regions. Default: - true
272
+ :param deploy_vpc: Whether to deploy a new VPC. Default: - false
273
+ :param existing_lambda_obj: Existing instance of Lambda Function object, providing both this and ``lambdaFunctionProps`` will cause an error. Default: - None
274
+ :param existing_vpc: An existing VPC for the construct to use (construct will NOT create a new VPC in this case).
275
+ :param foundation_model_environment_variable_name: Optional Name for the Lambda function environment variable set to the Model name. Default: - BEDROCK_MODEL
276
+ :param inference_profile_environment_variable_name: Optional Name for the Lambda function environment variable set to the inference profile arn. Default: - BEDROCK_PROFILE
277
+ :param inference_profile_props: Properties to override constructs props values for the Inference Profile. The construct will populate inverenceProfileName - so don't override it unless you have an very good reason. The construct base IAM policies around the modelSource that it creates, so trying to send a modelSource in ths parameter will cause an error. This is where you set tags required for tracking inference calls.
278
+ :param lambda_function_props: User provided props to override the default props for the Lambda function. Default: - Default properties are used.
279
+ :param vpc_props: Properties to override default properties if deployVpc is true.
280
+
281
+ :summary: The properties for the LambdaToSns class.
282
+ '''
283
+ if isinstance(inference_profile_props, dict):
284
+ inference_profile_props = _aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfileProps(**inference_profile_props)
285
+ if isinstance(lambda_function_props, dict):
286
+ lambda_function_props = _aws_cdk_aws_lambda_ceddda9d.FunctionProps(**lambda_function_props)
287
+ if isinstance(vpc_props, dict):
288
+ vpc_props = _aws_cdk_aws_ec2_ceddda9d.VpcProps(**vpc_props)
289
+ if __debug__:
290
+ type_hints = typing.get_type_hints(_typecheckingstub__dbd286561a19e8bd53f160f75f50f6ccc70ee89235d93c7e43431b10d35bd16c)
291
+ check_type(argname="argument bedrock_model_id", value=bedrock_model_id, expected_type=type_hints["bedrock_model_id"])
292
+ check_type(argname="argument deploy_cross_region_profile", value=deploy_cross_region_profile, expected_type=type_hints["deploy_cross_region_profile"])
293
+ check_type(argname="argument deploy_vpc", value=deploy_vpc, expected_type=type_hints["deploy_vpc"])
294
+ check_type(argname="argument existing_lambda_obj", value=existing_lambda_obj, expected_type=type_hints["existing_lambda_obj"])
295
+ check_type(argname="argument existing_vpc", value=existing_vpc, expected_type=type_hints["existing_vpc"])
296
+ check_type(argname="argument foundation_model_environment_variable_name", value=foundation_model_environment_variable_name, expected_type=type_hints["foundation_model_environment_variable_name"])
297
+ check_type(argname="argument inference_profile_environment_variable_name", value=inference_profile_environment_variable_name, expected_type=type_hints["inference_profile_environment_variable_name"])
298
+ check_type(argname="argument inference_profile_props", value=inference_profile_props, expected_type=type_hints["inference_profile_props"])
299
+ check_type(argname="argument lambda_function_props", value=lambda_function_props, expected_type=type_hints["lambda_function_props"])
300
+ check_type(argname="argument vpc_props", value=vpc_props, expected_type=type_hints["vpc_props"])
301
+ self._values: typing.Dict[builtins.str, typing.Any] = {
302
+ "bedrock_model_id": bedrock_model_id,
303
+ }
304
+ if deploy_cross_region_profile is not None:
305
+ self._values["deploy_cross_region_profile"] = deploy_cross_region_profile
306
+ if deploy_vpc is not None:
307
+ self._values["deploy_vpc"] = deploy_vpc
308
+ if existing_lambda_obj is not None:
309
+ self._values["existing_lambda_obj"] = existing_lambda_obj
310
+ if existing_vpc is not None:
311
+ self._values["existing_vpc"] = existing_vpc
312
+ if foundation_model_environment_variable_name is not None:
313
+ self._values["foundation_model_environment_variable_name"] = foundation_model_environment_variable_name
314
+ if inference_profile_environment_variable_name is not None:
315
+ self._values["inference_profile_environment_variable_name"] = inference_profile_environment_variable_name
316
+ if inference_profile_props is not None:
317
+ self._values["inference_profile_props"] = inference_profile_props
318
+ if lambda_function_props is not None:
319
+ self._values["lambda_function_props"] = lambda_function_props
320
+ if vpc_props is not None:
321
+ self._values["vpc_props"] = vpc_props
322
+
323
+ @builtins.property
324
+ def bedrock_model_id(self) -> builtins.str:
325
+ '''The foundation model to use with the inference profile.
326
+
327
+ The construct
328
+ will validate the model name, create the correct inference profile name
329
+ based on the region and remind the developer in which regions the model
330
+ must be available for this profile. Be certain that the account is granted
331
+ access to the foundation model in all the regions covered by cross-region
332
+ inference profile
333
+ '''
334
+ result = self._values.get("bedrock_model_id")
335
+ assert result is not None, "Required property 'bedrock_model_id' is missing"
336
+ return typing.cast(builtins.str, result)
337
+
338
+ @builtins.property
339
+ def deploy_cross_region_profile(self) -> typing.Optional[builtins.bool]:
340
+ '''Whether to deploy a cross-region inference profile that will automatically distribute Invoke calls across multiple regions.
341
+
342
+ :default: - true
343
+ '''
344
+ result = self._values.get("deploy_cross_region_profile")
345
+ return typing.cast(typing.Optional[builtins.bool], result)
346
+
347
+ @builtins.property
348
+ def deploy_vpc(self) -> typing.Optional[builtins.bool]:
349
+ '''Whether to deploy a new VPC.
350
+
351
+ :default: - false
352
+ '''
353
+ result = self._values.get("deploy_vpc")
354
+ return typing.cast(typing.Optional[builtins.bool], result)
355
+
356
+ @builtins.property
357
+ def existing_lambda_obj(
358
+ self,
359
+ ) -> typing.Optional[_aws_cdk_aws_lambda_ceddda9d.Function]:
360
+ '''Existing instance of Lambda Function object, providing both this and ``lambdaFunctionProps`` will cause an error.
361
+
362
+ :default: - None
363
+ '''
364
+ result = self._values.get("existing_lambda_obj")
365
+ return typing.cast(typing.Optional[_aws_cdk_aws_lambda_ceddda9d.Function], result)
366
+
367
+ @builtins.property
368
+ def existing_vpc(self) -> typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc]:
369
+ '''An existing VPC for the construct to use (construct will NOT create a new VPC in this case).'''
370
+ result = self._values.get("existing_vpc")
371
+ return typing.cast(typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc], result)
372
+
373
+ @builtins.property
374
+ def foundation_model_environment_variable_name(
375
+ self,
376
+ ) -> typing.Optional[builtins.str]:
377
+ '''Optional Name for the Lambda function environment variable set to the Model name.
378
+
379
+ :default: - BEDROCK_MODEL
380
+ '''
381
+ result = self._values.get("foundation_model_environment_variable_name")
382
+ return typing.cast(typing.Optional[builtins.str], result)
383
+
384
+ @builtins.property
385
+ def inference_profile_environment_variable_name(
386
+ self,
387
+ ) -> typing.Optional[builtins.str]:
388
+ '''Optional Name for the Lambda function environment variable set to the inference profile arn.
389
+
390
+ :default: - BEDROCK_PROFILE
391
+ '''
392
+ result = self._values.get("inference_profile_environment_variable_name")
393
+ return typing.cast(typing.Optional[builtins.str], result)
394
+
395
+ @builtins.property
396
+ def inference_profile_props(
397
+ self,
398
+ ) -> typing.Optional[_aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfileProps]:
399
+ '''Properties to override constructs props values for the Inference Profile.
400
+
401
+ The construct will populate inverenceProfileName - so don't override it
402
+ unless you have an very good reason. The construct base IAM policies around
403
+ the modelSource that it creates, so trying to send a modelSource in ths
404
+ parameter will cause an error. This is where you set tags required for
405
+ tracking inference calls.
406
+ '''
407
+ result = self._values.get("inference_profile_props")
408
+ return typing.cast(typing.Optional[_aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfileProps], result)
409
+
410
+ @builtins.property
411
+ def lambda_function_props(
412
+ self,
413
+ ) -> typing.Optional[_aws_cdk_aws_lambda_ceddda9d.FunctionProps]:
414
+ '''User provided props to override the default props for the Lambda function.
415
+
416
+ :default: - Default properties are used.
417
+ '''
418
+ result = self._values.get("lambda_function_props")
419
+ return typing.cast(typing.Optional[_aws_cdk_aws_lambda_ceddda9d.FunctionProps], result)
420
+
421
+ @builtins.property
422
+ def vpc_props(self) -> typing.Optional[_aws_cdk_aws_ec2_ceddda9d.VpcProps]:
423
+ '''Properties to override default properties if deployVpc is true.'''
424
+ result = self._values.get("vpc_props")
425
+ return typing.cast(typing.Optional[_aws_cdk_aws_ec2_ceddda9d.VpcProps], result)
426
+
427
+ def __eq__(self, rhs: typing.Any) -> builtins.bool:
428
+ return isinstance(rhs, self.__class__) and rhs._values == self._values
429
+
430
+ def __ne__(self, rhs: typing.Any) -> builtins.bool:
431
+ return not (rhs == self)
432
+
433
+ def __repr__(self) -> str:
434
+ return "LambdaToBedrockinferenceprofileProps(%s)" % ", ".join(
435
+ k + "=" + repr(v) for k, v in self._values.items()
436
+ )
437
+
438
+
439
+ __all__ = [
440
+ "LambdaToBedrockinferenceprofile",
441
+ "LambdaToBedrockinferenceprofileProps",
442
+ ]
443
+
444
+ publication.publish()
445
+
446
+ def _typecheckingstub__3f146eecba713ed1ed7bed25607c92b6cdce670262bf0c10ad465027e80d1370(
447
+ scope: _constructs_77d1e7e8.Construct,
448
+ id: builtins.str,
449
+ *,
450
+ bedrock_model_id: builtins.str,
451
+ deploy_cross_region_profile: typing.Optional[builtins.bool] = None,
452
+ deploy_vpc: typing.Optional[builtins.bool] = None,
453
+ existing_lambda_obj: typing.Optional[_aws_cdk_aws_lambda_ceddda9d.Function] = None,
454
+ existing_vpc: typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc] = None,
455
+ foundation_model_environment_variable_name: typing.Optional[builtins.str] = None,
456
+ inference_profile_environment_variable_name: typing.Optional[builtins.str] = None,
457
+ inference_profile_props: typing.Optional[typing.Union[_aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfileProps, typing.Dict[builtins.str, typing.Any]]] = None,
458
+ lambda_function_props: typing.Optional[typing.Union[_aws_cdk_aws_lambda_ceddda9d.FunctionProps, typing.Dict[builtins.str, typing.Any]]] = None,
459
+ vpc_props: typing.Optional[typing.Union[_aws_cdk_aws_ec2_ceddda9d.VpcProps, typing.Dict[builtins.str, typing.Any]]] = None,
460
+ ) -> None:
461
+ """Type checking stubs"""
462
+ pass
463
+
464
+ def _typecheckingstub__dbd286561a19e8bd53f160f75f50f6ccc70ee89235d93c7e43431b10d35bd16c(
465
+ *,
466
+ bedrock_model_id: builtins.str,
467
+ deploy_cross_region_profile: typing.Optional[builtins.bool] = None,
468
+ deploy_vpc: typing.Optional[builtins.bool] = None,
469
+ existing_lambda_obj: typing.Optional[_aws_cdk_aws_lambda_ceddda9d.Function] = None,
470
+ existing_vpc: typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IVpc] = None,
471
+ foundation_model_environment_variable_name: typing.Optional[builtins.str] = None,
472
+ inference_profile_environment_variable_name: typing.Optional[builtins.str] = None,
473
+ inference_profile_props: typing.Optional[typing.Union[_aws_cdk_aws_bedrock_ceddda9d.CfnApplicationInferenceProfileProps, typing.Dict[builtins.str, typing.Any]]] = None,
474
+ lambda_function_props: typing.Optional[typing.Union[_aws_cdk_aws_lambda_ceddda9d.FunctionProps, typing.Dict[builtins.str, typing.Any]]] = None,
475
+ vpc_props: typing.Optional[typing.Union[_aws_cdk_aws_ec2_ceddda9d.VpcProps, typing.Dict[builtins.str, typing.Any]]] = None,
476
+ ) -> None:
477
+ """Type checking stubs"""
478
+ pass
@@ -0,0 +1,46 @@
1
+ from pkgutil import extend_path
2
+ __path__ = extend_path(__path__, __name__)
3
+
4
+ import abc
5
+ import builtins
6
+ import datetime
7
+ import enum
8
+ import typing
9
+
10
+ import jsii
11
+ import publication
12
+ import typing_extensions
13
+
14
+ import typeguard
15
+ from importlib.metadata import version as _metadata_package_version
16
+ TYPEGUARD_MAJOR_VERSION = int(_metadata_package_version('typeguard').split('.')[0])
17
+
18
+ def check_type(argname: str, value: object, expected_type: typing.Any) -> typing.Any:
19
+ if TYPEGUARD_MAJOR_VERSION <= 2:
20
+ return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore
21
+ else:
22
+ if isinstance(value, jsii._reference_map.InterfaceDynamicProxy): # pyright: ignore [reportAttributeAccessIssue]
23
+ pass
24
+ else:
25
+ if TYPEGUARD_MAJOR_VERSION == 3:
26
+ typeguard.config.collection_check_strategy = typeguard.CollectionCheckStrategy.ALL_ITEMS # type:ignore
27
+ typeguard.check_type(value=value, expected_type=expected_type) # type:ignore
28
+ else:
29
+ typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore
30
+
31
+ import aws_cdk._jsii
32
+ import aws_solutions_constructs.core._jsii
33
+ import constructs._jsii
34
+
35
+ __jsii_assembly__ = jsii.JSIIAssembly.load(
36
+ "@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile",
37
+ "2.84.0",
38
+ __name__[0:-6],
39
+ "aws-lambda-bedrockinferenceprofile@2.84.0.jsii.tgz",
40
+ )
41
+
42
+ __all__ = [
43
+ "__jsii_assembly__",
44
+ ]
45
+
46
+ publication.publish()
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.1
2
+ Name: aws-solutions-constructs.aws-lambda-bedrockinferenceprofile
3
+ Version: 2.84.0
4
+ Summary: CDK constructs for defining an interaction between an AWS Lambda function and an Amazon Bedrock inference profile.
5
+ Home-page: https://github.com/awslabs/aws-solutions-constructs.git
6
+ Author: Amazon Web Services
7
+ License: Apache-2.0
8
+ Project-URL: Source, https://github.com/awslabs/aws-solutions-constructs.git
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: JavaScript
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Typing :: Typed
17
+ Classifier: License :: OSI Approved
18
+ Requires-Python: ~=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: aws-cdk-lib<3.0.0,>=2.190.0
22
+ Requires-Dist: aws-solutions-constructs.core==2.84.0
23
+ Requires-Dist: constructs<11.0.0,>=10.0.0
24
+ Requires-Dist: jsii<2.0.0,>=1.110.0
25
+ Requires-Dist: publication>=0.0.3
26
+ Requires-Dist: typeguard<4.3.0,>=2.13.3
27
+
28
+ # aws-lambda-bedrockinferenceprofile module
29
+
30
+ <!--BEGIN STABILITY BANNER-->---
31
+
32
+
33
+ ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
34
+
35
+ > All classes are under active development and subject to non-backward compatible changes or removal in any
36
+ > future version. These are not subject to the [Semantic Versioning](https://semver.org/) model.
37
+ > This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
38
+
39
+ ---
40
+ <!--END STABILITY BANNER-->
41
+
42
+ | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
43
+ |:-------------|:-------------|
44
+
45
+ <div style="height:8px"></div>
46
+
47
+ | **Language** | **Package** |
48
+ |:-------------|-----------------|
49
+ |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_lambda_bedrockinferenceprofile`|
50
+ |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile`|
51
+ |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.lambdabedrockinferenceprofile`|
52
+
53
+ ## Overview
54
+
55
+ This AWS Solutions Construct implements a Lambda function granted access to a new Bedrock Inference Profile. [Inference profiles](https://aws.amazon.com/blogs/machine-learning/getting-started-with-cross-region-inference-in-amazon-bedrock/) allow:
56
+
57
+ * Greater scalability of applications by distributing Bedrock Invoke calls across multiple regions
58
+ * Cost management by adding Cost Allocation Tags to an inference to track costs for specific applications.
59
+
60
+ Here is a minimal deployable pattern definition:
61
+
62
+ Typescript
63
+
64
+ ```python
65
+ import { Construct } from 'constructs';
66
+ import { Stack, StackProps } from 'aws-cdk-lib';
67
+ import { LambdaToBedrockInferenceProfile } from "@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile";
68
+ import * as lambda from 'aws-cdk-lib/aws-lambda';
69
+
70
+ new LambdaToBedrockInferenceProfile(this, 'LambdaToBedrockPattern', {
71
+ lambdaFunctionProps: {
72
+ runtime: lambda.Runtime.NODEJS_20_X,
73
+ handler: 'index.handler',
74
+ code: lambda.Code.fromAsset(`lambda`)
75
+ },
76
+ model: "amazon.nova-lite-v1:0"
77
+ });
78
+ ```
79
+
80
+ Python
81
+
82
+ ```python
83
+ # TBD
84
+ ```
85
+
86
+ Java
87
+
88
+ ```java
89
+ // TBD
90
+ ```
91
+
92
+ ## Pattern Construct Props
93
+
94
+ | **Name** | **Type** | **Description** |
95
+ |:-------------|:----------------|-----------------|
96
+ |existingLambdaObj?|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html)|Existing instance of Lambda Function object, providing both this and `lambdaFunctionProps` will cause an error.|
97
+ |lambdaFunctionProps?|[`lambda.FunctionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.FunctionProps.html)|Optional user provided props to override the default props for the Lambda function.|
98
+ |existingVpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html)|An optional, existing VPC into which this pattern should be deployed. When deployed in a VPC, the Lambda function will use ENIs in the VPC to access network resources and an Interface Endpoint will be created in the VPC for Amazon Bedrock and Bedrock-Runtime. If an existing VPC is provided, the `deployVpc` property cannot be `true`. This uses `ec2.IVpc` to allow clients to supply VPCs that exist outside the stack using the [`ec2.Vpc.fromLookup()`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Vpc.html#static-fromwbrlookupscope-id-options) method.|
99
+ |vpcProps?|[`ec2.VpcProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.VpcProps.html)|Optional user provided properties to override the default properties for the new VPC. `enableDnsHostnames`, `enableDnsSupport`, `natGateways` and `subnetConfiguration` are set by the pattern, so any values for those properties supplied here will be overridden. If `deployVpc` is not `true` then this property will be ignored.|
100
+ |deployVpc?|`boolean`|Whether to create a new VPC based on `vpcProps` into which to deploy this pattern. Setting this to true will deploy the minimal, most private VPC to run the pattern:<ul><li> One isolated subnet in each Availability Zone used by the CDK program</li><li>`enableDnsHostnames` and `enableDnsSupport` will both be set to true</li></ul>If this property is `true` then `existingVpc` cannot be specified. Defaults to `false`.|
101
+ |bedrockModelId|`string`|The foundation model to use with the inference profile. Depending on whether the deployment is cross region or single region, he construct will create the correct inference profile name and and assign IAM permissions to the Lambda function allowing access to the foundation model in all appropriate regions. For all of this to occur, the model must be specified here and *not* in `inferenceProfileProps`. Be certain that the account is granted access to the foundation model in [all the regions covered by the cross-region inference profile](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html).|
102
+ |inferenceProfileProps?|[`bedrock.CfnApplicationInferenceProfileProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnApplicationInferenceProfileProps.html)|This is where you set tags required for tracking inference calls. Do not populate the copyFrom attribute - the construct will populate this based upon the model sent in bedrockModelId (this allows the construct to correctly create all the other dependencies like the required IAM policies). If the copyFrom attribute is supplied here the construct will throw an error. The construct will also set a unique, stack specific inferenceProfileName - you may override that name here, but it is not recommended.
103
+ |deployCrossRegionProfile|boolean| Whether to deploy a cross-region inference profile that will automatically distribute Invoke calls across multiple regions. Note that at the time of this writing, cross-region profiles are only available in [US, EMEA and APAC](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html). Single region profiles are available in every region supporting Bedrock models. Defaults to `true`|
104
+ |foundationModelEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the Model name. Defaults to BEDROCK_MODEL|
105
+ |inferenceProfileEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the inference profile arn. Defaults to BEDROCK_PROFILE|
106
+
107
+ ## Pattern Properties
108
+
109
+ | **Name** | **Type** | **Description** |
110
+ |:-------------|:----------------|-----------------|
111
+ |lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html)|Returns an instance of the Lambda function created by the pattern.|
112
+ |inferenceProfile|[`CfnApplicationInferenceProfile`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnApplicationInferenceProfile.html)|The inference profile created by the construct.|
113
+ |vpc?|[`ec2.IVpc`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html)|Returns an interface on the VPC used by the pattern (if any). This may be a VPC created by the pattern or the VPC supplied to the pattern constructor.|
114
+
115
+ ## Default settings
116
+
117
+ Out of the box implementation of the Construct without any override will set the following defaults:
118
+
119
+ ### AWS Lambda Function
120
+
121
+ * Configure limited privilege access IAM role for Lambda function, granting Invoke privileges for:
122
+
123
+ * The new inference profile
124
+ * The appropriate foundation model in all regions in the geographic area. For single region inference profiles, access is only granted to model in the current region.
125
+ * Enable reusing connections with Keep-Alive for NodeJs Lambda function
126
+ * Enable X-Ray Tracing
127
+ * Set Environment Variables
128
+
129
+ * (default) BEDROCK_PROFILE
130
+ * (default) BEDROCK_MODEL
131
+
132
+ ### Amazon Bedrock Inference Profile
133
+
134
+ * Cross-region inference profile for provided model by default
135
+ * Geographic area prefix in arn defaults to value appropriate for deployment region (e.g. would us 'us' for us-east-1 deployment)
136
+
137
+ ## Architecture
138
+
139
+ ![Architecture Diagram](architecture.png)
140
+
141
+ ---
142
+
143
+
144
+ © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ setup.py
6
+ src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/PKG-INFO
7
+ src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/SOURCES.txt
8
+ src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/dependency_links.txt
9
+ src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/requires.txt
10
+ src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/top_level.txt
11
+ src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/__init__.py
12
+ src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/py.typed
13
+ src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/__init__.py
14
+ src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/aws-lambda-bedrockinferenceprofile@2.84.0.jsii.tgz
@@ -0,0 +1,6 @@
1
+ aws-cdk-lib<3.0.0,>=2.190.0
2
+ aws-solutions-constructs.core==2.84.0
3
+ constructs<11.0.0,>=10.0.0
4
+ jsii<2.0.0,>=1.110.0
5
+ publication>=0.0.3
6
+ typeguard<4.3.0,>=2.13.3