Questions tagged [boto]

boto is an open-source Python Interface to Amazon Web Services

Boto is a Python package that provides an interface to Amazon Web Services. The code is hosted on github.com (https://github.com/boto/boto) and the documentation can be found at http://docs.pythonboto.org.

Boto supports the following services:

  • Compute
    • Amazon Elastic Compute Cloud (EC2)
    • Amazon Elastic Map Reduce (EMR)
    • AutoScaling
    • Elastic Load Balancing (ELB)
  • Content Delivery
    • Amazon CloudFront
  • Database
    • Amazon Relational Data Service (RDS)
    • Amazon DynamoDB
    • Amazon SimpleDB
  • Deployment and Management
    • AWS Identity and Access Management (IAM)
    • Amazon CloudWatch
    • AWS Elastic Beanstalk
    • AWS CloudFormation
  • Application Services
    • Amazon CloudSearch
    • Amazon Simple Workflow Service (SWF)
    • Amazon Simple Queue Service (SQS)
    • Amazon Simple Notification Server (SNS)
    • Amazon Simple Email Service (SES)
  • Networking
    • Amazon Route53
    • Amazon Virtual Private Cloud (VPC)
  • Payments and Billing
    • Amazon Flexible Payment Service (FPS)
  • Storage
    • Amazon Simple Storage Service (S3)
    • Amazon Glacier
    • Amazon Elastic Block Store (EBS)
    • Google Cloud Storage
  • Workforce
    • Amazon Mechanical Turk
  • Other
    • Marketplace Web Services
2362 questions
359
votes
21 answers

Listing contents of a bucket with boto3

How can I see what's inside a bucket in S3 with boto3? (i.e. do an "ls")? Doing the following: import boto3 s3 = boto3.resource('s3') my_bucket = s3.Bucket('some/path/') returns: s3.Bucket(name='some/path/') How do I see its contents?
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
311
votes
10 answers

How to handle errors with boto3?

I am trying to figure how to do proper error handling with boto3. I am trying to create an IAM user: def create_user(username, iam_conn): try: user = iam_conn.create_user(UserName=username) return user except Exception as e: …
SQDK
  • 3,987
  • 3
  • 18
  • 16
235
votes
8 answers

Open S3 object as a string with Boto3

I'm aware that with Boto 2 it's possible to open an S3 object as a string with: get_contents_as_string() Is there an equivalent function in boto3 ?
Gahl Levy
  • 3,211
  • 2
  • 13
  • 7
219
votes
17 answers

Boto3 Error: botocore.exceptions.NoCredentialsError: Unable to locate credentials

When I simply run the following code, I always gets this error. s3 = boto3.resource('s3') bucket_name = "python-sdk-sample-%s" % uuid.uuid4() print("Creating new bucket with name:", bucket_name) s3.create_bucket(Bucket=bucket_name) I have saved my…
d-_-b
  • 4,142
  • 6
  • 28
  • 43
199
votes
8 answers

How to write a file or data to an S3 object using boto3

In boto 2, you can write to an S3 object using these methods: Key.set_contents_from_string() Key.set_contents_from_file() Key.set_contents_from_filename() Key.set_contents_from_stream() Is there a boto 3 equivalent? What is the boto3 method for…
jkdev
  • 11,360
  • 15
  • 54
  • 77
181
votes
7 answers

How to save S3 object to a file using boto3

I'm trying to do a "hello world" with new boto3 client for AWS. The use-case I have is fairly simple: get object from S3 and save it to the file. In boto 2.X I would do it like this: import boto key =…
Vor
  • 33,215
  • 43
  • 135
  • 193
168
votes
1 answer

What is the difference between the AWS boto and boto3

I'm trying to learn the boto API and I noticed that there are two major versions/packages for Python: boto and boto3. What is the difference between the AWS boto and boto3 libraries?
Matt
  • 3,592
  • 5
  • 21
  • 26
163
votes
13 answers

Amazon S3 boto - how to create a folder?

How can I create a folder under a bucket using boto library for Amazon s3? I followed the manual, and created the keys with permission, metadata etc, but no where in the boto's documentation it describes how to create folders under a bucket, or…
vito huang
  • 4,228
  • 7
  • 26
  • 24
153
votes
17 answers

How to upload a file to directory in S3 bucket using boto

I want to copy a file in s3 bucket using python. Ex : I have bucket name = test. And in the bucket, I have 2 folders name "dump" & "input". Now I want to copy a file from local directory to S3 "dump" folder using python... Can anyone help me?
Dheeraj Gundra
  • 1,585
  • 2
  • 10
  • 9
142
votes
8 answers

Amazon S3 boto - how to delete folder?

I created a folder in s3 named "test" and I pushed "test_1.jpg", "test_2.jpg" into "test". How can I use boto to delete folder "test"?
wade huang
  • 1,435
  • 2
  • 11
  • 7
128
votes
8 answers

Mocking boto3 S3 client method Python

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…
ptimson
  • 5,533
  • 8
  • 35
  • 53
95
votes
11 answers

The role defined for the function cannot be assumed by Lambda

I'm getting the error "The role defined for the function cannot be assumed by Lambda" when I'm trying to create a lambda function with create-function command. aws lambda create-function --region us-west-2 --function-name HelloPython …
Midhun Sudhakar
  • 1,238
  • 2
  • 10
  • 14
89
votes
5 answers

How to upload a file to S3 and make it public using boto3?

I am able to upload an image file using: s3 = session.resource('s3') bucket = s3.Bucket(S3_BUCKET) bucket.upload_file(file, key) However, I want to make the file public too. I tried looking up for some functions to set ACL for the file but seems…
Adi
  • 4,149
  • 4
  • 25
  • 41
84
votes
2 answers

Is it better to have multiple s3 buckets or one bucket with sub folders?

Is it better to have multiple s3 buckets per category of uploads or one bucket with sub folders OR a linked s3 bucket? I know for sure there will be more user-images than there will be profille-pics and that there is a 5TB limit per bucket and 100…
user805981
  • 9,979
  • 8
  • 44
  • 64
82
votes
9 answers

Disable boto logging without modifying the boto files

I am using the Boto library to talk to AWS. I want to disable logging. (Or redirect to /dev/null or other file). I can't find an obvious way to do this. I tried this, but that doesn't seem to help: import boto boto.set_file_logger('boto',…
agiliq
  • 7,518
  • 14
  • 54
  • 74
1
2 3
99 100