Skip to content

Commit 8e10027

Browse files
committed
2025-04-29
1 parent 660c801 commit 8e10027

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

apigw-lambda-bedrock-cdk-python/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Text generation via ApiGateway -> Lambda -> Bedrock
1+
# Text generation via Amazon API Gateway -> AWS Lambda -> Amazon Bedrock
22

33
![architecture](architecture/architecture.png)
44

@@ -24,19 +24,19 @@ You must request access to a model before you can use it. If you try to use the
2424

2525
1. Find **Amazon Bedrock** by searching in the AWS console.
2626

27-
![Bedrock Search](bedrock_setup/bedrock-search.png)
27+
![Amazon Bedrock Search](bedrock_setup/bedrock-search.png)
2828

2929
1. Expand the side menu.
3030

31-
![Bedrock Expand Menu](bedrock_setup/bedrock-menu-expand.png)
31+
![Amazon Bedrock Expand Menu](bedrock_setup/bedrock-menu-expand.png)
3232

3333
1. From the side menu, select **Model access**.
3434

35-
![Model Access](bedrock_setup/model-access-link.png)
35+
![Amazon Bedrock Model Access](bedrock_setup/model-access-link.png)
3636

3737
1. Select the **Edit** button.
3838

39-
![Model Access View](bedrock_setup/model-access-view.png)
39+
![Amazon Bedrock Model Access View](bedrock_setup/model-access-view.png)
4040

4141
6. Use the checkboxes to select the models you wish to enable. Review the applicable EULAs as needed. Click **Save changes** to activate the models in your account. For this pattern we only need Anthropic Claude 3 Haiku but feel free to experiment with others.
4242

@@ -74,14 +74,14 @@ You must request access to a model before you can use it. If you try to use the
7474
```
7575
cdk deploy
7676
```
77-
1. After deployment completes, take a look at the Outputs section. There will be an entry containing the URL of the API Gateway resource you just created. Copy that URL as you'll need it for your tests.
77+
1. After deployment completes, take a look at the Outputs section. There will be an entry containing the URL of the Amazon API Gateway resource you just created. Copy that URL as you'll need it for your tests.
7878
7979
The format of the URL will be something like `https://{id}.execute-api.{region}.amazonaws.com/prod`
8080
8181
8282
## How it works
8383
84-
CDK will create an Api Gateway, along with a resource and a POST method. There's a AWS Lambda function that will be taking the prompt and invoking an Amazon Bedrock model (anthropic.claude-v2) synchronously. If you wish to try other models, make sure to modify the policy attached to the Lambda function and invoke the right model.
84+
CDK will create an Amazon API Gateway, along with a resource and a POST method. There is an AWS Lambda function that will be taking the prompt and invoking an Amazon Bedrock model (anthropic.claude-3-haiku-20240307-v1:0) synchronously. If you wish to try other models, make sure to modify the policy attached to the Lambda function and invoke the right model.
8585
8686
This pattern is a synchronous pattern. For an asynchronous approach, please check [this](../apigw-rest-api-sqs-lambda-bedrock-cdk) pattern that involves the usage of Amazon SQS.
8787
@@ -107,7 +107,7 @@ Follow the example below and replace `{your-api-url}` with your api url from ste
107107
```
108108
109109
## Extra Resources
110-
* [Bedrock Api Reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html)
110+
* [Amazon Bedrock Api Reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html)
111111
112112
----
113113
Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.

apigw-lambda-bedrock-cdk-python/apigw_lambda_bedrock/apigw_lambda_bedrock_stack.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class ApigwLambdaBedrockStack(Stack):
1212
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
1313
super().__init__(scope, construct_id, **kwargs)
1414

15-
#lambda layer containing boto
15+
#AWS Lambda Layer containing boto
1616
layer = _lambda.LayerVersion(self, "Boto3Layer",
1717
code=_lambda.Code.from_asset("./boto_layer.zip"),
1818
compatible_runtimes=[_lambda.Runtime.PYTHON_3_10]
1919
)
2020

21-
#add policy to invoke bedrock model
21+
#add policy to invoke Amazon Bedrock model
2222
invoke_model_policy = iam.Policy(self, "InvokeModelPolicy",
2323
statements=[
2424
iam.PolicyStatement(
@@ -28,7 +28,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
2828
]
2929
)
3030

31-
# Create the Lambda function and attach the layer
31+
# Create AWS Lambda function and attach the layer
3232
lambda_function = _lambda.Function(self, "MyFunction",
3333
runtime=_lambda.Runtime.PYTHON_3_10,
3434
handler="index.handler",
@@ -39,7 +39,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
3939

4040
invoke_model_policy.attach_to_role(lambda_function.role)
4141

42-
#create api gateway
42+
#create Amazon API Gateway
4343
api = apigw.RestApi(self, "ServerlessLandGenAI",)
4444

4545
#create a new resource

0 commit comments

Comments
 (0)