Questions tagged [boto3]

Boto 3 - The Amazon Web Services (AWS) SDK for Python

About

Boto is the Amazon Web Services (AWS) software development kit (SDK) for Python, which allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2. Boto provides an easy to use, object-oriented API as well as low-level direct service access.

Links

7627 questions
43
votes
7 answers

Upload to Amazon S3 using Boto3 and return public url

Iam trying to upload files to s3 using Boto3 and make that uploaded file public and return it as a url. class UtilResource(BaseZMPResource): class Meta(BaseZMPResource.Meta): queryset = Configuration.objects.none() resource_name =…
Yaswanth Kumar
  • 459
  • 1
  • 4
  • 10
42
votes
4 answers

How do I conditionally insert an item into a dynamodb table using boto3

If I have a table with a hash key of userId and a range key of productId how do I put an item into that table only if it doesn't already exist using boto3's dynamodb bindings? The normal call to put_item looks like…
aychedee
  • 24,871
  • 8
  • 79
  • 83
40
votes
5 answers

Is boto3 client thread-safe

Is boto3 low level client for S3 thread-safe? Documentation is not explicit about it. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#client A similar issue is discussed in Github…
Andrey Novosad
  • 401
  • 1
  • 4
  • 5
39
votes
3 answers

Can I use boto3 anonymously?

With boto I could connect to public S3 buckets without credentials by passing the anon= keyword argument. s3 = boto.connect_s3(anon=True) Is this possible with boto3?
MRocklin
  • 55,641
  • 23
  • 163
  • 235
38
votes
2 answers

Properly catch boto3 Errors

I am developing a django app which communicates with several Amazon Web Services. So far I am having trouble dealing with and catching exceptions thrown by the boto3 client. What I am doing seems unnecessarily tedious: Example: client =…
David Schumann
  • 13,380
  • 9
  • 75
  • 96
37
votes
4 answers

What is the fastest way to empty s3 bucket using boto3?

I was thinking about deleting and then re-creating bucket (bad option which I realised later). Then how can delete all objects from the bucket? I tried this :…
Tushar Niras
  • 3,654
  • 2
  • 22
  • 24
37
votes
6 answers

uploading file to specific folder in S3 using boto3

Everything with my code works. The only pitfall I am currently facing is that I cannot specify the folder within the S3 bucket that I would like to place my file in. Here is what I have: s3.meta.client.upload_file('/tmp/'+filename, '',…
Alex
  • 493
  • 1
  • 4
  • 9
37
votes
6 answers

How to create an ec2 instance using boto3

Is it possible to create an ec2 instance using boto3 in python? Boto3 document is not helping here, and I couldn't find any helping documents online. please provide some sample codes/links.
MikA
  • 5,184
  • 5
  • 33
  • 42
37
votes
3 answers

boto3 equivalent to boto.utils.get_instance_metadata()?

In regular boto 2.38 I used to access instance metadata (e.g. get current stack-name), through boto's boto.utils.get_instance_metadata() Is there an equivalent in boto3, or do I need to go to the down level direct http address to fetch metadata…
user2123288
  • 1,103
  • 1
  • 13
  • 22
36
votes
1 answer

Using a ProjectionExpression with reserved words with Boto3 in DynamoDB

I'm selecting data from my DynamoDB database using boto3 dynamodb = boto3.resource('dynamodb') table = dynamodb.Table(table_name) response = table.scan(ProjectionExpression='Id,Name')['Items'] Works fine. Now I also want to retrieve an attribute…
Kirk Broadhurst
  • 27,836
  • 16
  • 104
  • 169
36
votes
5 answers

dynamodb how to query by sort key only?

I have written some python code, I want to query dynamoDB data by sort key. I remember I can use follow-up code successful: table.query(KeyConditionExpression=Key('event_status').eq(event_status)) My table structure column primary…
scott
  • 441
  • 2
  • 5
  • 10
36
votes
2 answers

Boto3 updating multiple values

in the boto3 documentation updating an item is described by this example: table.update_item( Key={ 'username': 'janedoe', 'last_name': 'Doe' }, UpdateExpression='SET age = :val1', ExpressionAttributeValues={ …
weka1
  • 737
  • 2
  • 9
  • 20
36
votes
1 answer

Change the number of request retries in boto3

In boto3 or botocore, how do I do the equivalent of setting the number of request retries? e.g. in boto2 from boto import config config.set('Boto', 'num_retries', '20') How do I do this in boto3? I've…
DG812
  • 460
  • 1
  • 5
  • 5
36
votes
2 answers

How to generate url from boto3 in amazon web services

I have a Bucket in s3 and I am trying to pull the url of the image that is in there. I am using boto3 and boto3 doesn't seem to have an implemented generate url method. They have a core method, that generates url like this, import…
Prabhakar Shanmugam
  • 5,634
  • 6
  • 25
  • 36
35
votes
1 answer

What is the difference between boto3 list_objects and list_objects_v2?

I'm trying to list objects in an Amazon s3 bucket in python using boto3. It seems boto3 has 2 functions for listing the objects in a bucket: list_objects() and list_objects_v2(). What is the difference between the 2 and what is the benefit of using…
tamjd1
  • 876
  • 1
  • 10
  • 29