Skip to content

Commit e3ee9a7

Browse files
committed
docs: update deployment instructions and enhance ECR push script
1 parent bdfa57c commit e3ee9a7

File tree

4 files changed

+192
-112
lines changed

4 files changed

+192
-112
lines changed

README.md

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,47 +55,75 @@ Alternatively, you can use Lambda Function URL to replace ALB, see [example](htt
5555

5656
### Deployment
5757

58-
Please follow the steps below to deploy the Bedrock Proxy APIs into your AWS account. Only supports regions where Amazon Bedrock is available (such as `us-west-2`). The deployment will take approximately **3-5 minutes** 🕒.
58+
Please follow the steps below to deploy the Bedrock Proxy APIs into your AWS account. Only supports regions where Amazon Bedrock is available (such as `us-west-2`). The deployment will take approximately **10-15 minutes** 🕒.
5959

6060
**Step 1: Create your own API key in Secrets Manager (MUST)**
6161

62-
6362
> **Note:** This step is to use any string (without spaces) you like to create a custom API Key (credential) that will be used to access the proxy API later. This key does not have to match your actual OpenAI key, and you don't need to have an OpenAI API key. please keep the key safe and private.
6463
6564
1. Open the AWS Management Console and navigate to the AWS Secrets Manager service.
66-
2. Click on "Store a new secret" button.
65+
2. Click on "Store a new secret" button.
6766
3. In the "Choose secret type" page, select:
6867

6968
Secret type: Other type of secret
7069
Key/value pairs:
7170
- Key: api_key
7271
- Value: Enter your API key value
73-
72+
7473
Click "Next"
7574
4. In the "Configure secret" page:
7675
Secret name: Enter a name (e.g., "BedrockProxyAPIKey")
7776
Description: (Optional) Add a description of your secret
7877
5. Click "Next" and review all your settings and click "Store"
7978

80-
After creation, you'll see your secret in the Secrets Manager console. Make note of the secret ARN.
79+
After creation, you'll see your secret in the Secrets Manager console. Make note of the secret ARN.
80+
81+
**Step 2: Build and push container images to ECR**
82+
83+
1. Clone this repository:
84+
```bash
85+
git clone https://github.com/aws-samples/bedrock-access-gateway.git
86+
cd bedrock-access-gateway
87+
```
88+
89+
2. Run the build and push script:
90+
```bash
91+
cd scripts
92+
bash ./push-to-ecr.sh
93+
```
94+
95+
3. Follow the prompts to configure:
96+
- ECR repository names (or use defaults)
97+
- Image tag (or use default: `latest`)
98+
- AWS region (or use default: `us-east-1`)
99+
100+
4. The script will build and push both Lambda and ECS/Fargate images to your ECR repositories.
101+
102+
5. **Important**: Copy the image URIs displayed at the end of the script output. You'll need these in the next step.
103+
104+
**Step 3: Deploy the CloudFormation stack**
81105

106+
1. Download the CloudFormation template you want to use:
107+
- For Lambda: [`deployment/BedrockProxy.template`](deployment/BedrockProxy.template)
108+
- For Fargate: [`deployment/BedrockProxyFargate.template`](deployment/BedrockProxyFargate.template)
82109

83-
**Step 2: Deploy the CloudFormation stack**
110+
2. Sign in to AWS Management Console and navigate to the CloudFormation service in your target region.
84111

85-
1. Sign in to AWS Management Console, switch to the region to deploy the CloudFormation Stack to.
86-
2. Click the following button to launch the CloudFormation Stack in that region. Choose one of the following:
112+
3. Click "Create stack" → "With new resources (standard)".
87113

88-
[<kbd> <br> ALB + Lambda 1-Click Deploy 🚀 <br> </kbd>](https://console.aws.amazon.com/cloudformation/home?#/stacks/quickcreate?templateURL=https://aws-gcr-solutions.s3.amazonaws.com/bedrock-access-gateway/latest/BedrockProxy.template&stackName=BedrockProxyAPI)
114+
4. Upload the template file you downloaded.
115+
116+
5. On the "Specify stack details" page, provide the following information:
117+
- **Stack name**: Enter a stack name (e.g., "BedrockProxyAPI")
118+
- **ApiKeySecretArn**: Enter the secret ARN from Step 1
119+
- **ContainerImageUri**: Enter the ECR image URI from Step 2 output
120+
- **DefaultModelId**: (Optional) Change the default model if needed
89121

90-
[<kbd> <br> ALB + Fargate 1-Click Deploy 🚀 <br> </kbd>](https://console.aws.amazon.com/cloudformation/home?#/stacks/quickcreate?templateURL=https://aws-gcr-solutions.s3.amazonaws.com/bedrock-access-gateway/latest/BedrockProxyFargate.template&stackName=BedrockProxyAPI)
91-
3. Click "Next".
92-
4. On the "Specify stack details" page, provide the following information:
93-
- Stack name: Change the stack name if needed.
94-
- ApiKeySecretArn: Enter the secret ARN you used for storing the API key.
95-
96122
Click "Next".
97-
5. On the "Configure stack options" page, you can leave the default settings or customize them according to your needs. Click "Next".
98-
6. On the "Review" page, review the details of the stack you're about to create. Check the "I acknowledge that AWS CloudFormation might create IAM resources" checkbox at the bottom. Click "Create stack".
123+
124+
6. On the "Configure stack options" page, you can leave the default settings or customize them according to your needs. Click "Next".
125+
126+
7. On the "Review" page, review all details. Check the "I acknowledge that AWS CloudFormation might create IAM resources" checkbox at the bottom. Click "Submit".
99127

100128
That is it! 🎉 Once deployed, click the CloudFormation stack and go to **Outputs** tab, you can find the API Base URL from `APIBaseUrl`, the value should look like `http://xxxx.xxx.elb.amazonaws.com/api/v1`.
101129

@@ -247,12 +275,6 @@ Note that not all models are available in those regions.
247275

248276
You can use the [Models API](./docs/Usage.md#models-api) to get/refresh a list of supported models in the current region.
249277

250-
### Can I build and use my own ECR image
251-
252-
Yes, you can clone the repo and build the container image by yourself (`src/Dockerfile`) and then push to your ECR repo. You can use `scripts/push-to-ecr.sh`
253-
254-
Replace the repo url in the CloudFormation template before you deploy.
255-
256278
### Can I run this locally
257279

258280
Yes, you can run this locally, e.g. run below command under `src` folder:
@@ -279,13 +301,7 @@ Fine-tuned models and models with Provisioned Throughput are currently not suppo
279301

280302
### How to upgrade?
281303

282-
To use the latest features, you don't need to redeploy the CloudFormation stack. You simply need to pull the latest image.
283-
284-
To do so, depends on which version you deployed:
285-
286-
- **Lambda version**: Go to AWS Lambda console, find the Lambda function, then find and click the `Deploy new image` button and click save.
287-
- **Fargate version**: Go to ECS console, click the ECS cluster, go the `Tasks` tab, select the only task that is running and simply click `Stop selected` menu. A new task with latest image will start automatically.
288-
304+
To use the latest features, you need follow the deployment guide to redeploy the application. You can upgrade the existing CloudFormation stack to get the latest changes.
289305

290306
## Security
291307

deployment/BedrockProxy.template

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Parameters:
44
Type: String
55
AllowedPattern: ^arn:aws:secretsmanager:.*$
66
Description: The secret ARN in Secrets Manager used to store the API Key
7+
ContainerImageUri:
8+
Type: String
9+
Description: The ECR image URI for the Lambda function (e.g., 123456789012.dkr.ecr.us-east-1.amazonaws.com/bedrock-proxy-api:latest)
710
DefaultModelId:
811
Type: String
912
Default: anthropic.claude-3-sonnet-20240229-v1:0
@@ -169,13 +172,7 @@ Resources:
169172
- arm64
170173
Code:
171174
ImageUri:
172-
Fn::Join:
173-
- ""
174-
- - 366590864501.dkr.ecr.
175-
- Ref: AWS::Region
176-
- "."
177-
- Ref: AWS::URLSuffix
178-
- /bedrock-proxy-api:latest
175+
Ref: ContainerImageUri
179176
Description: Bedrock Proxy API Handler
180177
Environment:
181178
Variables:

deployment/BedrockProxyFargate.template

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Parameters:
44
Type: String
55
AllowedPattern: ^arn:aws:secretsmanager:.*$
66
Description: The secret ARN in Secrets Manager used to store the API Key
7+
ContainerImageUri:
8+
Type: String
9+
Description: The ECR image URI for the ECS/Fargate task (e.g., 123456789012.dkr.ecr.us-east-1.amazonaws.com/bedrock-proxy-api-ecs:latest)
710
DefaultModelId:
811
Type: String
912
Default: anthropic.claude-3-sonnet-20240229-v1:0
@@ -134,10 +137,6 @@ Resources:
134137
PolicyDocument:
135138
Statement:
136139
- Action:
137-
- ecr:GetAuthorizationToken
138-
- ecr:BatchCheckLayerAvailability
139-
- ecr:GetDownloadUrlForLayer
140-
- ecr:BatchGetImage
141140
- logs:CreateLogStream
142141
- logs:PutLogEvents
143142
Effect: Allow
@@ -157,8 +156,35 @@ Resources:
157156
Fn::Join:
158157
- ""
159158
- - "arn:aws:ecr:"
160-
- Ref: AWS::Region
161-
- :366590864501:repository/bedrock-proxy-api-ecs
159+
- Fn::Select:
160+
- 3
161+
- Fn::Split:
162+
- "."
163+
- Fn::Select:
164+
- 0
165+
- Fn::Split:
166+
- "/"
167+
- Ref: ContainerImageUri
168+
- ":"
169+
- Fn::Select:
170+
- 0
171+
- Fn::Split:
172+
- "."
173+
- Fn::Select:
174+
- 0
175+
- Fn::Split:
176+
- "/"
177+
- Ref: ContainerImageUri
178+
- ":repository/"
179+
- Fn::Select:
180+
- 0
181+
- Fn::Split:
182+
- ":"
183+
- Fn::Select:
184+
- 1
185+
- Fn::Split:
186+
- "/"
187+
- Ref: ContainerImageUri
162188
- Action: ecr:GetAuthorizationToken
163189
Effect: Allow
164190
Resource: "*"
@@ -227,13 +253,7 @@ Resources:
227253
Value: "true"
228254
Essential: true
229255
Image:
230-
Fn::Join:
231-
- ""
232-
- - 366590864501.dkr.ecr.
233-
- Ref: AWS::Region
234-
- "."
235-
- Ref: AWS::URLSuffix
236-
- /bedrock-proxy-api-ecs:latest
256+
Ref: ContainerImageUri
237257
Name: proxy-api
238258
PortMappings:
239259
- ContainerPort: 80

0 commit comments

Comments
 (0)