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
58
votes
7 answers

AWS Cognito Authentication USER_PASSWORD_AUTH flow not enabled for this client

I have an mobile app with user pool (username & password). The app works fine with aws-amplify sdk. But, wanted to move the code out to Lambdas. So, I have written the following Lambda using Boto3. Here is Lambda: import boto3 def…
user9374347
  • 1,631
  • 2
  • 8
  • 8
56
votes
11 answers

AWS: Boto3: AssumeRole example which includes role usage

I'm trying to use the AssumeRole in such a way that i'm traversing multiple accounts and retrieving assets for those accounts. I've made it to this point: import boto3 stsclient = boto3.client('sts') assumedRoleObject =…
mumbles
  • 989
  • 2
  • 8
  • 19
53
votes
2 answers

botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found

I'm downloading files from AWS S3 Bucket like so: import boto3 s3client = boto3.client("s3") s3 = boto3.resource('s3') bucket_name = 'practice_bucket' bucket = s3.Bucket(bucket_name) for obj in bucket.objects.all(): filename =…
Dan Me
  • 2,143
  • 4
  • 19
  • 19
52
votes
4 answers

Boto3: get credentials dynamically?

I am struggling to find out how I can get my aws_access_key_id and aws_secret_access_key dynamically from my code. In boto2 I could do the following: boto.config.get_value('Credentials', 'aws_secret_access_key') but I can't seem to find a similar…
Mo.
  • 40,243
  • 37
  • 86
  • 131
51
votes
6 answers

Override S3 endpoint using Boto3 configuration file

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…
Vor
  • 33,215
  • 43
  • 135
  • 193
50
votes
12 answers

Getting S3 objects' last modified datetimes with boto

I'm writing a Python script that uploads files to S3 using boto librairy. I only want to upload changed files (which I can check by their "last modified" datetimes), but I can't find the Boto API endpoint to get the last modified date.
vreal
  • 797
  • 1
  • 7
  • 16
50
votes
2 answers

Are Boto3 Resources and Clients Equivalent? When Use One or Other?

What is the functional difference, if any, between Clients and Resources? Are they functionally equivalent? Under what conditions would you elect to invoke a Boto3 Resource vs. a Client (and vice-versa)?
Plane Wryter
  • 1,299
  • 1
  • 11
  • 14
49
votes
6 answers

Uploading a file to a S3 bucket with a prefix using Boto3

I am attempting to upload a file into a S3 bucket, but I don't have access to the root level of the bucket and I need to upload it to a certain prefix instead. The following code: import boto3 s3 = boto3.resource('s3') open('/tmp/hello.txt',…
foxes
  • 808
  • 1
  • 7
  • 13
49
votes
3 answers

AWS: Publish SNS message for Lambda function via boto3 (Python2)

I am trying to publish to an SNS topic which will then notify a Lambda function, as well as an SQS queue. My Lambda function does get called, but the CloudWatch logs state that my "event" object is None. The boto3 docs states to use the kwarg…
bmoran
  • 1,499
  • 2
  • 13
  • 21
47
votes
7 answers

The security token included in the request is expired

I have a script that pulls a lot of metrics from Cloudwatch for our own internal reports. The script iterates all of the EC2 instances in a specific region and ask for 5 cloudwatch metrics (all the statistics available) for the past 2 weeks (each…
Avi
  • 21,182
  • 26
  • 82
  • 121
46
votes
4 answers

AWS BOTO3 S3 python - An error occurred (404) when calling the HeadObject operation: Not Found

I am trying download a directory inside s3 bucket. I am trying to use transfer to download a directory from S3 bucket but I am getting an error as "An error occurred (404) when calling the HeadObject operation: Not Found". Please help. S3…
Jack
  • 957
  • 3
  • 10
  • 23
46
votes
2 answers

S3 Connection timeout when using boto3

I am using boto3 to operate with S3. If my application is unable to reach S3 due to a network issue, the connection will hang until eventually it times out. I would like to set a lower connection timeout. I came across this PR for botocore that…
Python Novice
  • 1,980
  • 5
  • 26
  • 33
46
votes
3 answers

Get AWS Account ID from Boto

I have an AWS_ACCESS_KEY_ID and an AWS_SECRET_KEY. These are active credentials, so they belong to an active user, who belongs to an AWS Account. How, using Boto3, do I find the ID of this AWS Account?
Zags
  • 37,389
  • 14
  • 105
  • 140
45
votes
3 answers

What does boto stand for

What does Boto stand for in the context of AWS? It seems like a random word to choose for an api name. Is it an acronym? I have tried googling around and see no indication of what it could mean.
user3726494
  • 493
  • 4
  • 11
44
votes
7 answers

Reading contents of a gzip file from a AWS S3 in Python

I am trying to read some logs from a Hadoop process that I run in AWS. The logs are stored in an S3 folder and have the following path. bucketname = name key = y/z/stderr.gz Here Y is the cluster id and z is a folder name. Both of these act as…
Kshitij Marwah
  • 1,091
  • 3
  • 14
  • 23