Use Boto3 to Recover Deleted Files in AWS S3 Bucket

Recover Deleted Files

So it happened. One of our techs ‘accidentally’ deleted all the directories and files in one of our S3 buckets. I enabled S3 Bucket Versioning on all our important buckets. So the deleted files are still there with the ‘latest version’ of the file being a Delete Marker. If you… Continue reading

Using Boto3 to find Users and HostRoles with certain AWS Policy

Recently I was asked to scour multiple AWS accounts to find any users or host role that had the S3FullAccess policy applied.    So I came up with the following that will go through all users and roles to identify the ones with the S3FullAccess policy assigned. You can use this… Continue reading

How to Setup a GPS PPS NTP Time server on Raspberry Pi

The South Florida Amateur Astronomers Association is currently working on a project to coordinate multiple Radio Telescope collection points.   This would require very precise time stamps on recorded data, much more accurate than what public NTP server pools could deliver.     So we successfully built as close to… Continue reading

Using Python and Boto3 to get Instance Tag information

Here are 2 sample functions to illustrate how you can get information about Tags on instances using Boto3 in AWS. import boto3 def get_instance_name(fid): # When given an instance ID as str e.g. ‘i-1234567’, return the instance ‘Name’ from the name tag. ec2 = boto3.resource(‘ec2’) ec2instance = ec2.Instance(fid) instancename =… Continue reading

Using Python Boto3 with Amazon AWS S3 Buckets

I’m here adding some additional Python Boto3 examples, this time working with S3 Buckets. So to get started, lets create the S3 resource, client, and get a listing of our buckets. import boto3 s3 = boto3.resource(‘s3’) s3client = boto3.client(‘s3’) response = s3client.list_buckets() for bucket in response[“Buckets”]: print(bucket[‘Name’]) Here we create… Continue reading

How to use Python Boto3 to list Instances in Amazon AWS

Continuing on with simple examples to help beginners learn the basics of Python and Boto3. This is a very simple tutorial showing how to get a list of instances in your Amazon AWS environment. import boto3 ec2client = boto3.client(‘ec2’) response = ec2client.describe_instances() for reservation in response[“Reservations”]: for instance in reservation[“Instances”]:… Continue reading