aws-solutions-constructs.aws-lambda-bedrockinferenceprofile 2.85.2__tar.gz → 2.85.4__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 (20) hide show
  1. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4/PKG-INFO +28 -0
  2. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4/README.md +1 -0
  3. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/setup.py +3 -3
  4. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/__init__.py +1 -150
  5. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/__init__.py +2 -2
  6. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/aws-lambda-bedrockinferenceprofile@2.85.4.jsii.tgz +0 -0
  7. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/PKG-INFO +28 -0
  8. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/SOURCES.txt +1 -1
  9. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/requires.txt +1 -1
  10. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2/PKG-INFO +0 -177
  11. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2/README.md +0 -150
  12. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/aws-lambda-bedrockinferenceprofile@2.85.2.jsii.tgz +0 -0
  13. aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/PKG-INFO +0 -177
  14. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/LICENSE +0 -0
  15. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/MANIFEST.in +0 -0
  16. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/pyproject.toml +0 -0
  17. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/setup.cfg +0 -0
  18. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/py.typed +0 -0
  19. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/dependency_links.txt +0 -0
  20. {aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.2 → aws_solutions_constructs_aws_lambda_bedrockinferenceprofile-2.85.4}/src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/top_level.txt +0 -0
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.1
2
+ Name: aws-solutions-constructs.aws-lambda-bedrockinferenceprofile
3
+ Version: 2.85.4
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.193.0
22
+ Requires-Dist: aws-solutions-constructs.core==2.85.4
23
+ Requires-Dist: constructs<11.0.0,>=10.0.0
24
+ Requires-Dist: jsii<2.0.0,>=1.111.0
25
+ Requires-Dist: publication>=0.0.3
26
+ Requires-Dist: typeguard<4.3.0,>=2.13.3
27
+
28
+ Documentation for this pattern can be found [here](https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/%40aws-solutions-constructs/aws-lambda-bedrockinferenceprofile/README.adoc)
@@ -0,0 +1 @@
1
+ Documentation for this pattern can be found [here](https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/%40aws-solutions-constructs/aws-lambda-bedrockinferenceprofile/README.adoc)
@@ -5,7 +5,7 @@ kwargs = json.loads(
5
5
  """
6
6
  {
7
7
  "name": "aws-solutions-constructs.aws-lambda-bedrockinferenceprofile",
8
- "version": "2.85.2",
8
+ "version": "2.85.4",
9
9
  "description": "CDK constructs for defining an interaction between an AWS Lambda function and an Amazon Bedrock inference profile.",
10
10
  "license": "Apache-2.0",
11
11
  "url": "https://github.com/awslabs/aws-solutions-constructs.git",
@@ -26,7 +26,7 @@ kwargs = json.loads(
26
26
  ],
27
27
  "package_data": {
28
28
  "aws_solutions_constructs.aws_lambda_bedrockinferenceprofile._jsii": [
29
- "aws-lambda-bedrockinferenceprofile@2.85.2.jsii.tgz"
29
+ "aws-lambda-bedrockinferenceprofile@2.85.4.jsii.tgz"
30
30
  ],
31
31
  "aws_solutions_constructs.aws_lambda_bedrockinferenceprofile": [
32
32
  "py.typed"
@@ -35,7 +35,7 @@ kwargs = json.loads(
35
35
  "python_requires": "~=3.9",
36
36
  "install_requires": [
37
37
  "aws-cdk-lib>=2.193.0, <3.0.0",
38
- "aws-solutions-constructs.core==2.85.2",
38
+ "aws-solutions-constructs.core==2.85.4",
39
39
  "constructs>=10.0.0, <11.0.0",
40
40
  "jsii>=1.111.0, <2.0.0",
41
41
  "publication>=0.0.3",
@@ -1,154 +1,5 @@
1
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
- from constructs import Construct
58
- from aws_cdk import (
59
- aws_lambda as _lambda,
60
- Stack
61
- )
62
-
63
- from aws_solutions_constructs import (
64
- aws_lambda_bedrockinferenceprofile as lambda_bedrock
65
- )
66
-
67
- lambda_bedrock.LambdaToBedrockinferenceprofile(
68
- self, 'bedrock-construct',
69
- bedrock_model_id="amazon.nova-lite-v1:0",
70
- lambda_function_props=_lambda.FunctionProps(
71
- runtime=_lambda.Runtime.NODEJS_20_X,
72
- code=_lambda.Code.from_asset('lambda'),
73
- handler='index.handler',
74
- )
75
- )
76
- ```
77
-
78
- Java
79
-
80
- ```java
81
- import software.constructs.Construct;
82
-
83
- import software.amazon.awscdk.Stack;
84
- import software.amazon.awscdk.StackProps;
85
- import software.amazon.awscdk.services.lambda.*;
86
- import software.amazon.awscdk.services.lambda.Runtime;
87
- import software.amazon.awsconstructs.services.lambdabedrockinferenceprofile.*;
88
-
89
- new LambdaToBedrockinferenceprofile(this, "ApiGatewayToLambdaPattern", new LambdaToBedrockinferenceprofileProps.Builder()
90
- .lambdaFunctionProps(new FunctionProps.Builder()
91
- .runtime(Runtime.NODEJS_20_X)
92
- .code(Code.fromAsset("lambda"))
93
- .handler("index.handler")
94
- .build())
95
- .bedrockModelId("amazon.nova-lite-v1:0")
96
- .build());
97
- ```
98
-
99
- ## Pattern Construct Props
100
-
101
- | **Name** | **Type** | **Description** |
102
- |:-------------|:----------------|-----------------|
103
- |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.|
104
- |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.|
105
- |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.|
106
- |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.|
107
- |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`.|
108
- |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).|
109
- |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.
110
- |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`|
111
- |foundationModelEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the Model name. Defaults to BEDROCK_MODEL|
112
- |inferenceProfileEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the inference profile arn. Defaults to BEDROCK_PROFILE|
113
-
114
- ## Pattern Properties
115
-
116
- | **Name** | **Type** | **Description** |
117
- |:-------------|:----------------|-----------------|
118
- |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.|
119
- |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.|
120
- |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.|
121
-
122
- ## Default settings
123
-
124
- Out of the box implementation of the Construct without any override will set the following defaults:
125
-
126
- ### AWS Lambda Function
127
-
128
- * Configure limited privilege access IAM role for Lambda function, granting Invoke privileges for:
129
-
130
- * The new inference profile
131
- * 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.
132
- * Enable reusing connections with Keep-Alive for NodeJs Lambda function
133
- * Enable X-Ray Tracing
134
- * Set Environment Variables
135
-
136
- * (default) BEDROCK_PROFILE
137
- * (default) BEDROCK_MODEL
138
-
139
- ### Amazon Bedrock Inference Profile
140
-
141
- * Cross-region inference profile for provided model by default
142
- * Geographic area prefix in arn defaults to value appropriate for deployment region (e.g. would us 'us' for us-east-1 deployment)
143
-
144
- ## Architecture
145
-
146
- ![Architecture Diagram](architecture.png)
147
-
148
- ---
149
-
150
-
151
- © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ Documentation for this pattern can be found [here](https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/%40aws-solutions-constructs/aws-lambda-bedrockinferenceprofile/README.adoc)
152
3
  '''
153
4
  from pkgutil import extend_path
154
5
  __path__ = extend_path(__path__, __name__)
@@ -34,9 +34,9 @@ import constructs._jsii
34
34
 
35
35
  __jsii_assembly__ = jsii.JSIIAssembly.load(
36
36
  "@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile",
37
- "2.85.2",
37
+ "2.85.4",
38
38
  __name__[0:-6],
39
- "aws-lambda-bedrockinferenceprofile@2.85.2.jsii.tgz",
39
+ "aws-lambda-bedrockinferenceprofile@2.85.4.jsii.tgz",
40
40
  )
41
41
 
42
42
  __all__ = [
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.1
2
+ Name: aws-solutions-constructs.aws-lambda-bedrockinferenceprofile
3
+ Version: 2.85.4
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.193.0
22
+ Requires-Dist: aws-solutions-constructs.core==2.85.4
23
+ Requires-Dist: constructs<11.0.0,>=10.0.0
24
+ Requires-Dist: jsii<2.0.0,>=1.111.0
25
+ Requires-Dist: publication>=0.0.3
26
+ Requires-Dist: typeguard<4.3.0,>=2.13.3
27
+
28
+ Documentation for this pattern can be found [here](https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/%40aws-solutions-constructs/aws-lambda-bedrockinferenceprofile/README.adoc)
@@ -11,4 +11,4 @@ src/aws_solutions_constructs.aws_lambda_bedrockinferenceprofile.egg-info/top_lev
11
11
  src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/__init__.py
12
12
  src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/py.typed
13
13
  src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/__init__.py
14
- src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/aws-lambda-bedrockinferenceprofile@2.85.2.jsii.tgz
14
+ src/aws_solutions_constructs/aws_lambda_bedrockinferenceprofile/_jsii/aws-lambda-bedrockinferenceprofile@2.85.4.jsii.tgz
@@ -1,5 +1,5 @@
1
1
  aws-cdk-lib<3.0.0,>=2.193.0
2
- aws-solutions-constructs.core==2.85.2
2
+ aws-solutions-constructs.core==2.85.4
3
3
  constructs<11.0.0,>=10.0.0
4
4
  jsii<2.0.0,>=1.111.0
5
5
  publication>=0.0.3
@@ -1,177 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: aws-solutions-constructs.aws-lambda-bedrockinferenceprofile
3
- Version: 2.85.2
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.193.0
22
- Requires-Dist: aws-solutions-constructs.core==2.85.2
23
- Requires-Dist: constructs<11.0.0,>=10.0.0
24
- Requires-Dist: jsii<2.0.0,>=1.111.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
- from constructs import Construct
84
- from aws_cdk import (
85
- aws_lambda as _lambda,
86
- Stack
87
- )
88
-
89
- from aws_solutions_constructs import (
90
- aws_lambda_bedrockinferenceprofile as lambda_bedrock
91
- )
92
-
93
- lambda_bedrock.LambdaToBedrockinferenceprofile(
94
- self, 'bedrock-construct',
95
- bedrock_model_id="amazon.nova-lite-v1:0",
96
- lambda_function_props=_lambda.FunctionProps(
97
- runtime=_lambda.Runtime.NODEJS_20_X,
98
- code=_lambda.Code.from_asset('lambda'),
99
- handler='index.handler',
100
- )
101
- )
102
- ```
103
-
104
- Java
105
-
106
- ```java
107
- import software.constructs.Construct;
108
-
109
- import software.amazon.awscdk.Stack;
110
- import software.amazon.awscdk.StackProps;
111
- import software.amazon.awscdk.services.lambda.*;
112
- import software.amazon.awscdk.services.lambda.Runtime;
113
- import software.amazon.awsconstructs.services.lambdabedrockinferenceprofile.*;
114
-
115
- new LambdaToBedrockinferenceprofile(this, "ApiGatewayToLambdaPattern", new LambdaToBedrockinferenceprofileProps.Builder()
116
- .lambdaFunctionProps(new FunctionProps.Builder()
117
- .runtime(Runtime.NODEJS_20_X)
118
- .code(Code.fromAsset("lambda"))
119
- .handler("index.handler")
120
- .build())
121
- .bedrockModelId("amazon.nova-lite-v1:0")
122
- .build());
123
- ```
124
-
125
- ## Pattern Construct Props
126
-
127
- | **Name** | **Type** | **Description** |
128
- |:-------------|:----------------|-----------------|
129
- |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.|
130
- |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.|
131
- |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.|
132
- |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.|
133
- |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`.|
134
- |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).|
135
- |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.
136
- |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`|
137
- |foundationModelEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the Model name. Defaults to BEDROCK_MODEL|
138
- |inferenceProfileEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the inference profile arn. Defaults to BEDROCK_PROFILE|
139
-
140
- ## Pattern Properties
141
-
142
- | **Name** | **Type** | **Description** |
143
- |:-------------|:----------------|-----------------|
144
- |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.|
145
- |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.|
146
- |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.|
147
-
148
- ## Default settings
149
-
150
- Out of the box implementation of the Construct without any override will set the following defaults:
151
-
152
- ### AWS Lambda Function
153
-
154
- * Configure limited privilege access IAM role for Lambda function, granting Invoke privileges for:
155
-
156
- * The new inference profile
157
- * 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.
158
- * Enable reusing connections with Keep-Alive for NodeJs Lambda function
159
- * Enable X-Ray Tracing
160
- * Set Environment Variables
161
-
162
- * (default) BEDROCK_PROFILE
163
- * (default) BEDROCK_MODEL
164
-
165
- ### Amazon Bedrock Inference Profile
166
-
167
- * Cross-region inference profile for provided model by default
168
- * Geographic area prefix in arn defaults to value appropriate for deployment region (e.g. would us 'us' for us-east-1 deployment)
169
-
170
- ## Architecture
171
-
172
- ![Architecture Diagram](architecture.png)
173
-
174
- ---
175
-
176
-
177
- © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -1,150 +0,0 @@
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
- from constructs import Construct
57
- from aws_cdk import (
58
- aws_lambda as _lambda,
59
- Stack
60
- )
61
-
62
- from aws_solutions_constructs import (
63
- aws_lambda_bedrockinferenceprofile as lambda_bedrock
64
- )
65
-
66
- lambda_bedrock.LambdaToBedrockinferenceprofile(
67
- self, 'bedrock-construct',
68
- bedrock_model_id="amazon.nova-lite-v1:0",
69
- lambda_function_props=_lambda.FunctionProps(
70
- runtime=_lambda.Runtime.NODEJS_20_X,
71
- code=_lambda.Code.from_asset('lambda'),
72
- handler='index.handler',
73
- )
74
- )
75
- ```
76
-
77
- Java
78
-
79
- ```java
80
- import software.constructs.Construct;
81
-
82
- import software.amazon.awscdk.Stack;
83
- import software.amazon.awscdk.StackProps;
84
- import software.amazon.awscdk.services.lambda.*;
85
- import software.amazon.awscdk.services.lambda.Runtime;
86
- import software.amazon.awsconstructs.services.lambdabedrockinferenceprofile.*;
87
-
88
- new LambdaToBedrockinferenceprofile(this, "ApiGatewayToLambdaPattern", new LambdaToBedrockinferenceprofileProps.Builder()
89
- .lambdaFunctionProps(new FunctionProps.Builder()
90
- .runtime(Runtime.NODEJS_20_X)
91
- .code(Code.fromAsset("lambda"))
92
- .handler("index.handler")
93
- .build())
94
- .bedrockModelId("amazon.nova-lite-v1:0")
95
- .build());
96
- ```
97
-
98
- ## Pattern Construct Props
99
-
100
- | **Name** | **Type** | **Description** |
101
- |:-------------|:----------------|-----------------|
102
- |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.|
103
- |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.|
104
- |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.|
105
- |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.|
106
- |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`.|
107
- |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).|
108
- |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.
109
- |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`|
110
- |foundationModelEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the Model name. Defaults to BEDROCK_MODEL|
111
- |inferenceProfileEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the inference profile arn. Defaults to BEDROCK_PROFILE|
112
-
113
- ## Pattern Properties
114
-
115
- | **Name** | **Type** | **Description** |
116
- |:-------------|:----------------|-----------------|
117
- |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.|
118
- |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.|
119
- |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.|
120
-
121
- ## Default settings
122
-
123
- Out of the box implementation of the Construct without any override will set the following defaults:
124
-
125
- ### AWS Lambda Function
126
-
127
- * Configure limited privilege access IAM role for Lambda function, granting Invoke privileges for:
128
-
129
- * The new inference profile
130
- * 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.
131
- * Enable reusing connections with Keep-Alive for NodeJs Lambda function
132
- * Enable X-Ray Tracing
133
- * Set Environment Variables
134
-
135
- * (default) BEDROCK_PROFILE
136
- * (default) BEDROCK_MODEL
137
-
138
- ### Amazon Bedrock Inference Profile
139
-
140
- * Cross-region inference profile for provided model by default
141
- * Geographic area prefix in arn defaults to value appropriate for deployment region (e.g. would us 'us' for us-east-1 deployment)
142
-
143
- ## Architecture
144
-
145
- ![Architecture Diagram](architecture.png)
146
-
147
- ---
148
-
149
-
150
- © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -1,177 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: aws-solutions-constructs.aws-lambda-bedrockinferenceprofile
3
- Version: 2.85.2
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.193.0
22
- Requires-Dist: aws-solutions-constructs.core==2.85.2
23
- Requires-Dist: constructs<11.0.0,>=10.0.0
24
- Requires-Dist: jsii<2.0.0,>=1.111.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
- from constructs import Construct
84
- from aws_cdk import (
85
- aws_lambda as _lambda,
86
- Stack
87
- )
88
-
89
- from aws_solutions_constructs import (
90
- aws_lambda_bedrockinferenceprofile as lambda_bedrock
91
- )
92
-
93
- lambda_bedrock.LambdaToBedrockinferenceprofile(
94
- self, 'bedrock-construct',
95
- bedrock_model_id="amazon.nova-lite-v1:0",
96
- lambda_function_props=_lambda.FunctionProps(
97
- runtime=_lambda.Runtime.NODEJS_20_X,
98
- code=_lambda.Code.from_asset('lambda'),
99
- handler='index.handler',
100
- )
101
- )
102
- ```
103
-
104
- Java
105
-
106
- ```java
107
- import software.constructs.Construct;
108
-
109
- import software.amazon.awscdk.Stack;
110
- import software.amazon.awscdk.StackProps;
111
- import software.amazon.awscdk.services.lambda.*;
112
- import software.amazon.awscdk.services.lambda.Runtime;
113
- import software.amazon.awsconstructs.services.lambdabedrockinferenceprofile.*;
114
-
115
- new LambdaToBedrockinferenceprofile(this, "ApiGatewayToLambdaPattern", new LambdaToBedrockinferenceprofileProps.Builder()
116
- .lambdaFunctionProps(new FunctionProps.Builder()
117
- .runtime(Runtime.NODEJS_20_X)
118
- .code(Code.fromAsset("lambda"))
119
- .handler("index.handler")
120
- .build())
121
- .bedrockModelId("amazon.nova-lite-v1:0")
122
- .build());
123
- ```
124
-
125
- ## Pattern Construct Props
126
-
127
- | **Name** | **Type** | **Description** |
128
- |:-------------|:----------------|-----------------|
129
- |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.|
130
- |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.|
131
- |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.|
132
- |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.|
133
- |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`.|
134
- |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).|
135
- |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.
136
- |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`|
137
- |foundationModelEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the Model name. Defaults to BEDROCK_MODEL|
138
- |inferenceProfileEnvironmentVariableName?|string|Optional Name for the Lambda function environment variable set to the inference profile arn. Defaults to BEDROCK_PROFILE|
139
-
140
- ## Pattern Properties
141
-
142
- | **Name** | **Type** | **Description** |
143
- |:-------------|:----------------|-----------------|
144
- |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.|
145
- |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.|
146
- |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.|
147
-
148
- ## Default settings
149
-
150
- Out of the box implementation of the Construct without any override will set the following defaults:
151
-
152
- ### AWS Lambda Function
153
-
154
- * Configure limited privilege access IAM role for Lambda function, granting Invoke privileges for:
155
-
156
- * The new inference profile
157
- * 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.
158
- * Enable reusing connections with Keep-Alive for NodeJs Lambda function
159
- * Enable X-Ray Tracing
160
- * Set Environment Variables
161
-
162
- * (default) BEDROCK_PROFILE
163
- * (default) BEDROCK_MODEL
164
-
165
- ### Amazon Bedrock Inference Profile
166
-
167
- * Cross-region inference profile for provided model by default
168
- * Geographic area prefix in arn defaults to value appropriate for deployment region (e.g. would us 'us' for us-east-1 deployment)
169
-
170
- ## Architecture
171
-
172
- ![Architecture Diagram](architecture.png)
173
-
174
- ---
175
-
176
-
177
- © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.