Skip to content
← Back to activity

Immutable solution version

Invalid LocationConstraint error in lab 03_QuestionAnswering/knowledge-bases /0_create_ingest_documents_test_kb.ipynb

Version 1

Complete solution

[GAcharyaOS (reporter)]: us-east-1 is special: S3 rejects CreateBucketConfiguration with a LocationConstraint there, so delete the CreateBucketConfiguration={ 'LocationConstraint': region_name } argument from the create_bucket call. Every other region works with the existing code.

Invalid LocationConstraint error in lab 03QuestionAnswering/knowledge-bases /0createingestdocumentstestkb.ipynb

[GAcharyaOS (reporter)]: us-east-1 is special: S3 rejects CreateBucketConfiguration with a LocationConstraint there, so delete the CreateBucketConfiguration={ 'LocationConstraint': regionname } argument from the createbucket call. Every other region works with the existing code. If you want one snippet that works in all regions, set the region on the client instead: s3client = boto3.client('s3', regionname=region_name).

Context from the issue

gh:aws-samples/amazon-bedrock-workshop#190: Issue aws-samples/amazon-bedrock-workshop#190 (closed, 5 comments): The jupyter notebook provided in the lab does not work for deployment in us-east-1 region. Remove the item in the bold from the below code in the notebook cell to create S3 bucket for knowledgebase : # Create S3 bucket for knowledge base data source s3bucket = s3client.createbucket( Bucket=bucketname**, CreateBucketConfiguration={ 'LocationConstraint': regionname }** )

Evidence

Issue gh:aws-samples/amazon-bedrock-workshop#190: the reporter asked: Issue aws-samples/amazon-bedrock-workshop#190 (closed, 5 comments): The jupyter notebook provided in the lab does not work for deployment in us-east-1 region. Remove the item in the bold from the below code in the notebook cell to create S3 bucket for knowledgebase : # Create S3 bucket for knowledge base data source s3bucket = s3client.createbucket( Bucket=bucketname**, CreateBucketConfiguration={ 'LocationConstraint': regionname }** ) The verified answer was: [GAcharyaOS (reporter)]: us-east-1 is special: S3 rejects CreateBucketConfiguration with a LocationConstraint there, so delete the CreateBucketConfiguration={ 'LocationConstraint': regionname } argument from the createbucket call. Every other region works with the existing code. If you want one snippet that works in all regions, set the region on the client instead: s3client = boto3.client('s3', regionname=region_name). Evidence thread: https://github.com/aws-samples/amazon-bedrock-workshop/issues/190

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_rL92kAAdYLnkIwMjtmyTNA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Invalid LocationConstraint error in lab 03_QuestionAnswering/knowledge-bases /0_create_ingest_documents_test_kb.ipynb <span>— Vectle</span></a>