botocore

AWS Boto3 sts get_caller_identity – catching exceptions if credentials are invalid

AWS Boto3 sts get_caller_identity – catching exceptions if credentials are invalid Question: With a Python app, using Boto3 v1.26.59 (and botocore of same version) about the first thing done is to try to get the username of the user. We have Identity Center (SSO) users. With aged credentials (token), two exceptions are thrown and I …

Total answers: 1

How to run parallel lambdas from another lambda?

How to run parallel lambdas from another lambda? Question: I’m trying to trigger several lambdas in parallel from another lambda. I’m using aiobotocore and this works fine locally but when I try to run it on AWSLambda, I have an error on the import modules: Unable to import module ‘lambda_function’: cannot import name ‘apply_request_checksum’ from …

Total answers: 3

How to capture botocore's NoSuchKey exception?

How to capture botocore's NoSuchKey exception? Question: I’m trying to write “good” python and capture a S3 no such key error with this: session = botocore.session.get_session() client = session.create_client(‘s3′) try: client.get_object(Bucket=BUCKET, Key=FILE) except NoSuchKey as e: print >> sys.stderr, “no such key in bucket” But NoSuchKey isn’t defined and I can’t trace it to the …

Total answers: 4

Mocking boto3 S3 client method Python

Mocking boto3 S3 client method Python Question: I’m trying to mock a singluar method from the boto3 s3 client object to throw an exception. But I need all other methods for this class to work as normal. This is so I can test a singular Exception test when and error occurs performing a upload_part_copy 1st …

Total answers: 8

Example of update_item in dynamodb boto3

Example of update_item in dynamodb boto3 Question: Following the documentation, I’m trying to create an update statement that will update or add if not exists only one attribute in a dynamodb table. I’m trying this response = table.update_item( Key={‘ReleaseNumber’: ‘1.0.179’}, UpdateExpression=’SET’, ConditionExpression=’Attr(‘ReleaseNumber’).eq(‘1.0.179′)’, ExpressionAttributeNames={‘attr1’: ‘val1’}, ExpressionAttributeValues={‘val1’: ‘false’} ) The error I’m getting is: botocore.exceptions.ClientError: An error …

Total answers: 9

Override S3 endpoint using Boto3 configuration file

Override S3 endpoint using Boto3 configuration file Question: OVERVIEW: I’m trying to override certain variables in boto3 using the configuration file (~/aws/confg). In my use case I want to use fakes3 service and send S3 requests to the localhost. EXAMPLE: In boto (not boto3), I can create a config in ~/.boto similar to this one: …

Total answers: 6

How to view Boto3 HTTPS request string

How to view Boto3 HTTPS request string Question: I have been able to view the attributes of the PreparedRequest that botocore sends, but I’m wondering how I can view the exact request string that is sent to AWS. I need the exact request string to be able to compare it to another application I’m testing …

Total answers: 2