Skip to content

Instantly share code, notes, and snippets.

View anujkumar-df's full-sized avatar
🚜
Working from home

Anuj Kumar anujkumar-df

🚜
Working from home
View GitHub Profile
@sudharsans
sudharsans / ec2-running-time.py
Created March 1, 2018 11:50
Python Boto3 script to find the number of minutes an instance has been running.
import boto3
from datetime import datetime, timezone
from functools import reduce
import operator
ec2 = boto3.client('ec2')
cloudtrail = boto3.client('cloudtrail')
def get_events(instanceid):
response = cloudtrail.lookup_events (