boto3

Boto3 intermittent NoAuthHandlerFound errors

自古美人都是妖i 提交于 2021-01-29 11:21:28
问题 When trying to connect to an AWS service via Boto3, I occasionally get the following error: NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV3Handler'] Check your credentials This is running on an EC2 instance with an IAM Role configured. This error happens rarely. 回答1: IAM roles provide credentials via the AWS metadata service. Boto3 will connect to this service to get credentials, but this connection can time out. By default, Boto3 will not retry

AWS Athena: Named boto3 queries not creating corresponding tables

拈花ヽ惹草 提交于 2021-01-29 10:24:06
问题 I have the following boto3 draft script #!/usr/bin/env python3 import boto3 client = boto3.client('athena') BUCKETS='buckets.txt' DATABASE='some_db' QUERY_STR="""CREATE EXTERNAL TABLE IF NOT EXISTS some_db.{}( BucketOwner STRING, Bucket STRING, RequestDateTime STRING, RemoteIP STRING, Requester STRING, RequestID STRING, Operation STRING, Key STRING, RequestURI_operation STRING, RequestURI_key STRING, RequestURI_httpProtoversion STRING, HTTPstatus STRING, ErrorCode STRING, BytesSent BIGINT,

Updating the value of DynamoDB table with boto3 implemented lambda function

给你一囗甜甜゛ 提交于 2021-01-29 10:13:02
问题 I am trying to achieve an update operation using my API method to update the content of the table. I have following lambda code set up: def lambda_handler(event, context): param = event['queryStringParameters']['employeID'] name = event['queryStringParameters']['employeName'] dynamodb = boto3.resource('dynamodb', region_name="us-east-1") table = dynamodb.Table('api_demo_employe') response = table.update_item( Key = { 'employeID' : param } ) I need to figure out how can i set the

Display a 1 GB video file in react js frontend, stored in private S3 bucket using flask

ⅰ亾dé卋堺 提交于 2021-01-29 09:29:09
问题 I need to display/stream large video files in reactjs. These files are being uploaded to private s3 bucket by user using react form and flask. I tried getObject method, but my file size is too large. get a signed url method required me to download the file. I am new to AWS-python-react setup. What is the best/most efficient/least costly approach to display large video files in react? 回答1: AWS offers other streaming specific services but if you really want to get them off S3 you could retrieve

S3 Python Download with Progress Bar

≯℡__Kan透↙ 提交于 2021-01-29 08:55:09
问题 Couldn't comment on the initial thread where I adapted this code (Track download progress of S3 file using boto3 and callbacks) so hopefully someone can help me here. I was able to use this code to show a progress bar for file uploads, now I need the do the same thing for file downloads from AWS S3. Any help would be GREATLY APPRECIATED! I know I need to get the size of the file from S3 instead of from the local file system. I'm sure there is some silly code I need to adjust to make this work

Putting to local DynamoDB table with Python boto3 times out

元气小坏坏 提交于 2021-01-29 05:54:15
问题 I am attempting to programmatically put data into a locally running DynamoDB Container by triggering a Python lambda expression. I'm trying to follow the template provided here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Python.03.html I am using the amazon/dynamodb-local you can download here: https://hub.docker.com/r/amazon/dynamodb-local Using Ubuntu 18.04.2 LTS to run the container and lambda server AWS Sam CLI to run my Lambda api Docker Version 18.09

boto3 how to retrieve the elastic ip from an instance

醉酒当歌 提交于 2021-01-28 16:47:52
问题 I need to do the following: I have some instances that contain a certain tag, I need to loop through those instances and for each instance which contains that certain tag, if that instance has an elastic ip attached, I need to tag that elastic ip with that same tag. My code is the following: import boto3 import json region_list = ['us-east-1'] session = boto3.Session(profile_name='default') for region in region_list: ec2 = session.resource('ec2',region) client = boto3.client('ec2',region) #

boto3 how to retrieve the elastic ip from an instance

北战南征 提交于 2021-01-28 16:33:21
问题 I need to do the following: I have some instances that contain a certain tag, I need to loop through those instances and for each instance which contains that certain tag, if that instance has an elastic ip attached, I need to tag that elastic ip with that same tag. My code is the following: import boto3 import json region_list = ['us-east-1'] session = boto3.Session(profile_name='default') for region in region_list: ec2 = session.resource('ec2',region) client = boto3.client('ec2',region) #

Check whether AWS credentials are present without making any requests

心已入冬 提交于 2021-01-28 11:45:57
问题 I have a program that sometimes needs to make requests to the AWS API using boto3. Sometimes somebody runs this without providing any credentials, and when the script gets to point where it needs to interact with AWS it crashes with a botocore.exceptions.NoCredentialsError . I'd like to preempt this by validating when the script starts whether any credentials have been provided and quitting with an explanatory message if they have not. However, as noted in the docs, there are loads of

Accessing stream in job.get_output('body')

大兔子大兔子 提交于 2021-01-28 07:55:25
问题 Sample code import boto3 glacier = boto3.resource('glacier') job = glacier.Job(accountID, vaultlist[0], id=joblist[0]) r = job.get_output() print(r0['body']) That print only yields botocore.response.StreamingBody at 0xsnip r0['body'] should be the inventory in CSV format, but I can't figure out how to get to it. I spent a bit of time trying to us io to read in the steam and either that is not the right way or I did it wrong. Can you point me in the right direction? Thanks! 回答1: Here's a