aws-samples / amazon-bedrock-workshop

This is a workshop designed for Amazon Bedrock a foundational model service.
https://catalog.us-east-1.prod.workshops.aws/workshops/a4bdb007-5600-4368-81c5-ff5b4154f518/en-US/20-intro
MIT No Attribution
1.39k stars 592 forks source link

Running notebooks on local machine #72

Closed aekundayo closed 11 months ago

aekundayo commented 11 months ago

I have followed all the instructions in the read me, I created a role with amazon bedrock access. Allowing all actions. My user trusted to assume the role.

I can create the bedrock client and list the models but when I try and invoke the model I get the following error:

repos/amazon-bedrock-workshop/00_Intro/~/Documents/repos/amazon-bedrock-workshop/.genenv/lib/python3.10/site-packages/botocore/client.py:980), in BaseClient._make_api_call(self, operation_name, api_params) 978 error_code = parsed_response.get("Error", {}).get("Code") 979 error_class = self.exceptions.from_code(error_code) --> 980 raise error_class(parsed_response, operation_name) 981 else: 982 return parsed_response

AccessDeniedException: An error occurred (AccessDeniedException) when calling the InvokeModel operation: Your account is not authorized to invoke this API operation.

Is anyone running this off their local machine rather than in AWS sagemaker?

aekundayo commented 11 months ago

resolved I switched from using

bedrock_runtime = bedrock.get_bedrock_client( assumed_role=os.environ.get("BEDROCK_ASSUME_ROLE", None), region=os.environ.get("AWS_DEFAULT_REGION", None) ) to using bedrockruntime = boto3.client(service_name='bedrock-runtime')