Skip to content

Commit

Permalink
fix s3 arn parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbalcaen committed Apr 25, 2024
1 parent c75cccf commit 01a88c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ terraform.rc
**/target
**/.aws-sam
.DS_Store
.vscode/launch.json
4 changes: 3 additions & 1 deletion lambdas/bedrock_invoker/src/index.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import boto3
import json
from botocore.exceptions import BotoCoreError, ClientError
from urllib.parse import urlparse

s3 = boto3.client('s3')
bedrock = boto3.client('bedrock')
Expand All @@ -14,7 +15,8 @@ def lambda_handler(event, context):
prompt = event['prompt']

# Parse the S3 ARN to get the bucket and key
bucket, key = s3_arn.split(':::')[1].split('/')
s3_path = s3_arn.replace("arn:aws:s3:::", "")
bucket, key = s3_path.split('/', 1)

# Download the file from S3
try:
Expand Down

0 comments on commit 01a88c6

Please sign in to comment.