Questions tagged [boto3]

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

Filter by
Sorted by
Tagged with
-2
votes
0answers
15 views

how to fetch specific tag value of a lambda function using boto 3 or aws cli?

Boto Script import boto3 client = boto3.client('lambda') response = client.list_tags( Resource='lambdaarn' ) print response Output : {'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': ...
0
votes
1answer
14 views

ec2client.describe_instances returns UnauthorizedOperation after adding condition to IAM policy

My goals is to restrict access to ec2 using tag key. It works fine if I remove the condition from the IAM policy. However, if I add the aws:TagKeys condition then I get UnauthorizedOperation error. ...
0
votes
0answers
14 views

How to correctly iterate over filtered AWS bucket?

I'm having trouble working through the boto3 API. I'm trying to grab the data from files in a specific folder in an S3 bucket. The closest I can get to getting this to work looks like this: bucket = ...
0
votes
1answer
23 views

aws lambda function to disable and delete CloudFront distribution in python boto3

I am working on a Lambda Function written in python and using boto3 to call AWS APIs. Work of lambda function as follows - Get the CloudFront Distribution list. Get the CloudFront Distribution ID. ...
0
votes
1answer
13 views

Getting 'ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden' while doing cross account copy of file in using boto3

Copying a file from an s3 bucket in one AWS account to an s3 bucket of another account. The required roles/policies for this task were created by IAM team which is out of my scope. This lambda is ...
0
votes
1answer
23 views

Is there a way to create Quicksight analysis purely through code (boto3)?

What I currently have in my Quicksight account is a Data Source (Redshift), some datasets (some Redshift views) and an analysis (graphs and charts that use the datasets). I can view all of these on ...
0
votes
1answer
20 views

query cloudwatch logs for distinct values using boto3 in python

I have a lambda function that writes metrics to Cloudwatch. While, it writes metrics, It generates some logs in a log-group. INFO:: username: [email protected] ClinicID: 7667 nodename: MacBook-Pro-...
0
votes
1answer
5 views

Boto3 intermittent NoAuthHandlerFound errors

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'] ...
0
votes
0answers
14 views

How to write custom log messages from AWS glue to S3?

I want to write a detailed custom log messages in S3 for every ETL job done by Glue. I can write logs from EMR to S3 with S3FS module. from __future__ import unicode_literals import os import boto3 ...
1
vote
1answer
8 views

S3 Boto3 Stubber doesn't have mapping for download file?

Currently writing tests and trying to make use of the Stubber provided by botocore. I'm trying: client = boto3.client("s3") response = {'Body': 'content'} expected_params = {'Bucket': 'a_bucket_name'...
0
votes
2answers
25 views

An exception occurred : 's3.ServiceResource' object has no attribute 'head_object'

I am checking if an object exist in S3 bucket. Following is the code snippet that I am using. obj is the filename. s3 = boto3.resource('s3') try: s3.head_object(Bucket=bucket_name, ...
0
votes
2answers
32 views

How to delete a folder and its contents on Amazon S3 using Python

For some reason my response only gives me empty square brackets, i.e [ ] and nothing happens. Here's my code: session = boto3.Session(aws_access_key_id=awsaccesskey,aws_secret_access_key=...
0
votes
1answer
24 views

Duplicate in ec2 instance list with pythonboto3

i made a tool that need to reboot a aws ec2 instances , the reboot works fine but when im listing the servers i have duplicates in the instance id , how i can list the instances without duplications? ...
0
votes
1answer
19 views

Python Boto3: Failed to fetch s3 file

Thanks in advance. I'm trying to fetch amazon s3 file after uploading it. But Client error occurs: *** botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation:...
-1
votes
1answer
29 views

“TypeError: string indices must be integers, not str” during boto3 aws execution

I am trying to get AWS' VM list using Boto3's describe_instance method. I am getting the following error. Traceback (most recent call last): File "pySkynet2.py", line 238, in <module> ...
0
votes
0answers
25 views

need to launch an ec2 in an existing subnet using boto3

I have created a VPC and a public subnet and i have saved the subnet id into file called "SubnetId.txt". the code is below: import boto3 ec2 = boto3.resource('ec2') vpc = ec2.create_vpc(CidrBlock='10....
0
votes
1answer
19 views

Aws Security Hub - createmembers boto3 returns the requested account under UnprocessedAccounts in the response

Trying to create a new member (random other account) to my security hub in aws. for some reason the request returns some of the accounts as UnprocessedAccounts with no other description. ive checked ...
0
votes
0answers
19 views

Invoke API end points with in Lambda using Boto and Pass Arguments

I m using AWS lambda for a use case. I have deployed the lambda function using Zappa. I m trying to invoke my AWS lambda function directly from my backend system(Django app) using boto (python). The ...
0
votes
0answers
6 views

Django File object and S3

So I have added s3 support to one of my Django projects. (storages and boto3) I have a model that has a file field with zip-archive with images in it. At some point I need to access this zip-archive ...
0
votes
1answer
39 views

Boto3 - How to filter out attributeType from scan() output using Python Boto3?

I'm using Boto3 to retrieve and return all data from a small dynamoDB table. My goal is to remove the attributeTypes from the output. The following is my output: {"Items": [{"...
0
votes
0answers
10 views

list all tags added to ALL SNS topics

I need assistance with using Boto3 list_tags_for_resource I am looking to list all tags for all SNS Topics. the Request Syntax requires a ResourceArn and I dont want to put one. Because it'll just ...
0
votes
2answers
41 views

create cloudwatch dashboard with boto3 using lambda

i want to create cloudwatch dashboard for multiple EC2 i have problem to put JSON dashboard bady and make region and id instance value be variable the code from __future__ import print_function ...
0
votes
0answers
13 views

How to set multiple Qualification criteria for a batch in mechanical turk using python API

I want to implement the same functionality from Requester end using APIs in python as shown in the image below: I want to test if Hit approval rate is > 95% for a worker and I also want the worker to ...
0
votes
2answers
33 views

How to perform cross account (using role arn's)in aws using python?

I was trying to connect to multiple aws accounts using arn's in list, but every time it is working only for the 1st arn in given list and for second it is failing. I have deleted the first arn and ...
0
votes
1answer
20 views

boto3 handle ClientError during s3 file upload

When making a boto3 upload request with invalid credentials I would like to use a custom format for displaying an error message. I am trying to accomplish this in the following way, try: ...
0
votes
0answers
14 views

DynamoDB binary conversion to python string/binary

Getting issues while converting the DynamoDB Binary type using TypeSerializer() into python types. Steps: setting resource to Dynamo Db and using Table API ( some people suggested to use Client ...
0
votes
0answers
16 views

using boto3.client('sts') throws Unable to load data for: endpoints error

I am using python 2.7 and trying to use boto3 to get client. It throws this error Caused by: (<class 'botocore.exceptions.DataNotFoundError'>, DataNotFoundError(u'Unable to load data for: ...
0
votes
1answer
33 views

Lambda reading file on S3 - flushing S3 cache

I have a problem regarding cache on S3. Basically I have a lambda that reads a file on S3 which is used as configuration. This file is a JSON. I am using python with boto3 to extract the needed info. ...
0
votes
3answers
83 views

How to query cloudwatch logs using boto3 in python

I have a lambda function that writes metrics to Cloudwatch. While, it writes metrics, It generates some logs in a log-group. INFO:: username: [email protected] ClinicID: 7667 nodename: MacBook-Pro-...
1
vote
1answer
38 views

boto3.exceptions.S3UploadFailedError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied

I'm running an Amazon EC2 (ubuntu) instance which outputs a JSON file daily. I am now trying to copy this JSON to Amazon S3 so that I can eventually download it to my local machine. Following the ...
1
vote
1answer
30 views

Does boto3 or aws cli have Create Template from Instance?

I noticed the aws console has "Create Template from Instance" option. Is there a boto3 or aws cli equivalent? I want to create a launch template using python + boto3 from a given instance-id. However ...
0
votes
1answer
37 views

Why am I getting botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden?

I'm getting this traceback when trying run run manage.py collectstatic as part of an AWS ElasticbeanStalk deploy using an S3 bucket. File "./src/manage.py", line 10, in <module> ...
1
vote
1answer
24 views

“Parser must be a string or character stream, not datetime” error in lambda aws function - can't figure out how to fix it

I am getting a very annoying error when trying to save/test this Lambda Boto3 function. There are other threads here on this issue, but i have spent about 2 hours trying to debug this and can't figure ...
0
votes
1answer
27 views

AWS KMS client not returning an alias name

I've been using the list_aliases() method of KMS client since a while now without any issues. But recently it has stopped listing one of the alias names I want to use. import boto3 kms_client = ...
0
votes
1answer
33 views

How to get all dimension values in MetricDataResults in CloudWatch

I have a search expression that looks like this: stats = cloudwatch.get_metric_data( MetricDataQueries=[ { "Id":'m1', 'Expression': "SEARCH('{ABC/...
0
votes
1answer
24 views

passing boto client parameters as variables

I have the boto3 script below. I pass it the access key and secret key. It then starts each crawler in a list. If I pass it the access key and secret key as a variable it throws the error below. ...
0
votes
2answers
41 views

S3 Default server side encryption on large number of buckets using Python boto3

Hi Iam trying to turn on default s3 encryption on all my buckets in an account using python boto3 script see below. import boto3 from botocore.exceptions import ClientError s3 = boto3.client('s3') ...
0
votes
0answers
13 views

Convert boto3 BaseCondition to its string representation

I am trying to convert boto3 dynamoDB conditional expressions (using types from boto3.dynamodb.conditions) to its string representation. Of course this could be hand coded but naturally I would prefer ...
0
votes
1answer
30 views

Uploading file to an s3 bucket path longer than 63 characters

I am writing a lambda function to upload a file from one s3 bucket to another, when the former is updated. I am running into an invalid parameter exception when uploading a file to the s3 path, which ...
0
votes
1answer
15 views

AWS s3 simultaneous move of the same object

Lately I consider a thing that I haven't totally figured. Basically, the thing is summarized in the question. In a broader way, my question is as follows: (Assume that these things are done by ...
0
votes
1answer
41 views

Get results based on subset of dimensions from cloudwatch

I am sending in 3 dimensions (Clinic_Id, Email, NodeName)to CloudWatch for a Metric. While querying Cloudwatch, I want to query based on 1 dimension (Clinic_Id) and get distinct values for 3rd ...
0
votes
0answers
15 views

Getting handshake error when I try to create template on pinpoint through boto

today I just started utilizing AWS Pinpoint through Boto. I am able to send Push notifications through the Pinpoint dashboard itself but when I try to connect through my D jango server and send push ...
1
vote
1answer
32 views

Best way to update a large number of dynamodb items from a list

I have a python list of approximately 500,000 strings, each element in the list corresponds to an id for a item in the dynamodb table I want to update. My question is, what would be the best way of ...
0
votes
2answers
32 views

AWS boto3 retrieve more than 1000 folders name, but not object names under the folders

I have an Amazon S3 bucket with the following structure: bucket_name/level1/level2/level3/level4/..../somefilename1.txt, somefilename2.txt,... somefilename(n).txt where multiple files can be under ...
0
votes
1answer
17 views

Use List Values in HTML BODY with Boto3/Amazon SES

I have the following problem. I use boto3 to generate a HMTL EMail with Amazon SES. Here I want to use Placeholders. I have a list with values which I want to put in this placeholders, but I dont know ...
0
votes
1answer
26 views

Aws Security Group rule deletion via revoke in boto3

I wrote a script to delete a rule in a security group. Not all the rules, only the rule with 0.0.0.0/0 cidr block. I am trying to use ec2.revoke_security_group_ingress, but the parameters mentioned in ...
0
votes
2answers
23 views

Can I pull python2 packages after support for python2 ends

I have a project written in python2. Suppose if I want to deploy my project after the end of life of python2 support, am I able to pull specific versions of specific packages? For example, I am using ...
0
votes
0answers
10 views

SDK Generated from Boto3 exports with null name. How can I name it properly?

I am a beginner in AWS and Boto3. I am exporting SDKs from API Gateway by using Boto3 get_sdk() method. The problem here is the file exports correctly but it names as "null-datetime.zip". How can I ...
0
votes
0answers
20 views

Generate a temporary token to upload files to s3 bucket through a browser

I need to pass the access data to perform the file upload operation to s3 bucket via a browser (React Js is used). An example of implementation is taken here. My task is to transfer access data from ...
0
votes
1answer
20 views

clone a job using boto

I click on "clone job" button, change an environment variable and submit the second job. Now both the jobs are running without any problem. But I have a python list of a few thousand variables those ...