boto3

Know when upload to s3 bucket is complete

Know when upload to s3 bucket is complete Question: I am using boto3 to upload an image to my s3 bucket and the below proccess works fine. What I want is, how can I know when the upload process is complete. Maybe print ‘upload complete’ when done. How can I achieve this? Thanks in advance. …

Total answers: 1

Find all JSON files within S3 Bucket

Find all JSON files within S3 Bucket Question: is it possible to find all .json files within S3 bucket where the bucket itself can have multiple sub-directories ? Actually my bucket includes multiple sub-directories where i would like to collect all JSON files inside it in order to iterate over them and parse specific key/values. …

Total answers: 1

MIDIutil write MIDI File to boto3 API server via Flask [Python]

MIDIutil write MIDI File to boto3 API server via Flask [Python] Question: struggling with trying to write a MIDIUtil file in my Flask App connecting to an s3 server. In a local instance, it’s no sweat: LOCAL_UPLOAD_FOLDER = ‘./_static/uploads/MIDI_files/’ file_name = "NAME.mid" file_path = f'{LOCAL_UPLOAD_FOLDER}{file_name}’ MyMIDI = MIDIFile(1) with open(file_path, "wb") as output_file: MyMIDI.writeFile(output_file) However, …

Total answers: 2

How to get filenames list from S3 bucket using Boto3

How to get filenames list from S3 bucket using Boto3 Question: How to get a list of all the filenames present in the s3 bucket. import boto3 import pandas as pd s3 = boto3.client(‘s3′) s3 = boto3.resource( service_name=’s3′, region_name=’us’, aws_access_key_id=’pjh’, aws_secret_access_key=’mm’) ob = [] for i in s3.Bucket(‘xyzbucket’).objects.all(): ob.append(i) test= [] for i in ob: …

Total answers: 1

Tagging S3 bucket object Issue

Tagging S3 bucket object Issue Question: I am trying to add tags to existing object in S3 bucket using Lambda. Lambda has IAM role permission to add tags to bucket object, however simple python code to get_object_tagging is working but put_object_tagging is not working. client = boto3.client("s3") tagresponse = client.put_object_tagging( Bucket="mybucket, Key="folder1/Test.txt", Tagging={‘TagSet’:[{‘key’:’:permission:allowdownload’,’Value’:’no’},{‘key’:’service:feature’,’Value’:’sftpfiletransfer’}]}, ) API …

Total answers: 1

Intermittent ConnectTimeoutError from within Docker, but only when accessing AWS SSM

Intermittent ConnectTimeoutError from within Docker, but only when accessing AWS SSM Question: My app uses SSM Parameter Store from within a Docker container both on Fargate instances and locally. I’m accessing it with Boto3 from Python. Multiple developers on my team, in different countries, have seen an intermittent issue, cropping up maybe a few times …

Total answers: 1

how to tag an existing AWS autoscaling group with boto3

how to tag an existing AWS autoscaling group with boto3 Question: I’m trying to tag an existing autoscaling group, using Python and Boto3. I can definitely describe the ASGs by name: import boto3 asg_client = boto3.client("autoscaling") asg_name = "foo-bar20220502044025104700000001" response = asg_client.describe_auto_scaling_groups(AutoScalingGroupNames=[asg_name]) The problem I have with the create_or_update_tags() and delete_tags() methods is that they …

Total answers: 1

How to upload s3 using boto3

How to upload s3 using boto3 Question: I want to upload my logs to my bucket I never been used python and boto3 This is my code import os import datetime as dt import boto3 x = dt.datetime.now() date = x.strftime("%Y%m%d") bucket = ‘mybucket’ dir_path = "/log" s3 = boto3.client(‘s3’) def log(): global dir_path for …

Total answers: 2

get list of all sub-accounts from given organization in aws

get list of all sub-accounts from given organization in aws Question: I am trying to pull list of all aws accounts for given organization (parent) using boto3 API. import boto3 import json client = boto3.client(‘organizations’) paginator = client.get_paginator(‘list_accounts_for_parent’) response_iterator = paginator.paginate( ParentId='<>’, PaginationConfig={ ‘MaxItems’: 123, ‘PageSize’: 123, ‘StartingToken’: ‘string’ } ) print(json.dumps(response_iterator)) But getting below …

Total answers: 1