You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apigw-lambda-bedrock-sam/README.md
+4-63Lines changed: 4 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Amazon API Gateway to AWS Lambda to Amazon Bedrock using SAM
2
2
3
-
This sample project deploys an Amazon API Gateway REST API with an AWS Lambda integration. The Lambda function is written in Python, calls the Amazon Bedrock API for Anthropic Claude-v2 model and returns a response containing the generated content.
3
+
This sample project deploys an Amazon API Gateway REST API with an AWS Lambda integration. The Lambda function is written in Python, calls the Amazon Bedrock API for Anthropic Claude 3.5 Sonnet model and returns a response containing the generated content.
4
4
5
5
Learn more about this pattern at Serverless Land Patterns: serverlessland.com/patterns/apigw-lambda-bedrock
6
6
@@ -43,73 +43,18 @@ Amazon Bedrock users need to request access to models before they are available
43
43
44
44
For production applications, you should [enable authentication for the API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-control-access-to-api.html) using one of several available options and [follow the API Gateway security best practices](https://docs.aws.amazon.com/apigateway/latest/developerguide/security-best-practices.html).
45
45
46
-
5. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for next step as well as testing.
47
-
6. Run the `create_lambda_layer.sh`. You may have to change the file permission to make it executable. This will create the lambda layer with necessary boto3 api for bedrock.
8. You may have to press `q` to come out of the output. Copy the value of `LayerVersionArn` from the above output and provide it into the next step. Such as:
71
-
```bash
72
-
Enter the LayerVersionArn from the above command: arn:aws:lambda:us-east-1:xxxxxxxxxxxx:layer:boto3-lambda-layer:1
73
-
```
74
-
9. Please copy the value of `ContentGenerationLambdaFunction` from the `sam deploy --guided` output and provide that as response to next question. Such as:
75
-
```bash
76
-
Enter the Lambda functionname from the SAM deploy output: your-stack-name-ContentGenerationLambdaXx-xxxxxxxxxxxx
77
-
```
78
-
The script will now run aws cli command to add the newly created layer to the Lambda function. It will show output as below:
79
-
It will show output like below:
80
-
```bash
81
-
Adding the new layer to your Lambda function's configuration. Please wait ...
"LastUpdateStatusReason": "The function is being created.",
89
-
"LastUpdateStatusReasonCode": "Creating",
90
-
"PackageType": "Zip",
91
-
"Architectures": [
92
-
"arm64"
93
-
],
94
-
"EphemeralStorage": {
95
-
"Size": 512
96
-
}
97
-
}
98
-
```
99
-
10. You may have to press `q` to come out of the output. The setup is ready for testing.
100
-
101
46
## How it works
102
47
103
-
This SAM project uses Amazon Bedrock API for Anthropic Claude-v2 model to generate content based on given prompt. This is exposed through a serverless REST API. Please refer to the architecture diagram below:
48
+
This SAM project uses Amazon Bedrock API for Anthropic Claude 3.5 Sonnet model to generate content based on given prompt. This is exposed through a serverless REST API. Please refer to the architecture diagram below:
104
49

105
50
106
51
Here's a breakdown of the steps:
107
52
108
53
1.**Amazon API Gateway**: Receives the HTTP POST request containing the prompt.
109
54
110
-
2. **AWS Lambda**: Triggered by the API Gateway, this functionforwards the prompt to Amazon Bedrock API using boto3 bedrock-runtime API. It uses Anthropic Claude-v2 model and sets other required parameters to fixed values for simplicity.
55
+
2.**AWS Lambda**: Triggered by the API Gateway, this function forwards the prompt to Amazon Bedrock API using boto3 bedrock-runtime API. It uses Anthropic Claude 3.5 Sonnet model and sets parameters like temperature, max tokens, and other configuration options.
111
56
112
-
3. **Amazon Bedrock**: Based on the given prompt, using Anthropic Claude-v2 model generates the content and returns the response to Lambda.
57
+
3.**Amazon Bedrock**: Based on the given prompt, using Anthropic Claude 3.5 Sonnet model generates the content and returns the response to Lambda.
113
58
114
59
4.**Response**: Lambda processes the Bedrock output and sends it back to the user via the API Gateway.
115
60
@@ -135,10 +80,6 @@ The API returns a response with generated content. Such as (Your out may vary):
135
80
```bash
136
81
sam delete
137
82
```
138
-
2. Delete the Lambda layer version using the `delete_lambda_layer.sh` script. You may have to give execution permission to the file. You will need to pass the Lambda layer name and the version in the inpout when requested:
0 commit comments