Skip to content

Instantly share code, notes, and snippets.

View kshailen's full-sized avatar

Shailendra kshailen

View GitHub Profile
@kshailen
kshailen / httpendpointmonitoring
Created April 4, 2022 15:23
Http Endpoint Monitoring
git clone https://github.com/kshailen/httpendpointmonitoring.git
cd httpendpointmonitoring
docker-compose up -d
@kshailen
kshailen / Vagrantfile
Created July 19, 2020 12:02 — forked from crissilvaeng/Vagrantfile
Puppet Lab with Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<-SCRIPT
wget https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
dpkg -i puppetlabs-release-pc1-xenial.deb
apt-get update
SCRIPT
$server = <<-SCRIPT
@kshailen
kshailen / Dockerfile
Created June 5, 2020 07:21
Sample Dockerfile
FROM python:2.7-alpine
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
ENV appname TestApp
ENV version=1.0
@kshailen
kshailen / delete_multipart_uploads.py
Last active May 20, 2020 14:47
This script will lifecycle rule to clean multipart uploads
import boto3
import sys
import json
from botocore.exceptions import ClientError
def delete_multipart_uploads(bucketName):
s3 = boto3.client('s3')
try:
bucket_lifecycle_response = s3.get_bucket_lifecycle(Bucket=bucketName)
@kshailen
kshailen / list_multiparts.py
Created May 20, 2020 11:41
This scripts provides a list of multiparts in it
import boto3
def get_multipart_upload(bucket):
client = boto3.client('s3')
response_multipart = client.list_multipart_uploads(Bucket=bucket)
# print(response_multipart)
multiparts = []
if "Uploads" in response_multipart.keys():
multiparts = response_multipart["Uploads"]
return multiparts
def main():
@kshailen
kshailen / check_multipart_uploads.py
Last active May 20, 2020 11:32
Checking if any bucket has multipart uploads or not
import boto3
def check_multipart_upload(bucket):
client = boto3.client('s3')
response_multipart = client.list_multipart_uploads(Bucket=bucket)
if "Uploads" in response_multipart.keys():
return True
return False
def main():
Bucket_list = ['complianx-xxdbox', 'corp-jenkins-xxxx']
# You can change bucket list as per your usecase
@kshailen
kshailen / s3_multipart_upload.py
Created May 9, 2020 05:17 — forked from teasherm/s3_multipart_upload.py
boto3 S3 Multipart Upload
import argparse
import os
import boto3
class S3MultipartUpload(object):
# AWS throws EntityTooSmall error for parts smaller than 5 MB
PART_MINIMUM = int(5e6)
@kshailen
kshailen / prepare_s3_report-fast.sh
Created May 7, 2020 11:38
Get size details of all s3 buckets in an account
#!/bin/bash
# exit when the command fails
set -o errexit;
# exit when try to use undeclared var
set -o nounset;
Total_num_of_buckets=`aws s3 ls s3:// | awk '{print $3}'| wc -l`
printf "%s: %4d\n" "Total Number of s3 buckets" ${Total_num_of_buckets}
printf "%s: %4s\n" "Bucket Name" "Bucket Size"
region=us-east-1
#Handling for MacOS and Linux
@kshailen
kshailen / prepare_s3_report-basic.sh
Created May 7, 2020 11:37
Get Size details of all S3 buckets
#!/bin/bash
# exit when the command fails
set -o errexit;
# exit when try to use undeclared var
set -o nounset;
Total_num_of_buckets=`aws s3 ls s3:// | awk '{print $NF}'| wc -l`
printf "%s: %4d\n" "Total Number of s3 buckets" ${Total_num_of_buckets}
printf "%s: %4s\n" "Bucket Name" "Bucket Size"
@kshailen
kshailen / README.md
Created April 30, 2020 06:27 — forked from Eyjafjallajokull/README.md
AWS EBS - Find unused snapshots

This script can help you find and remove unused AWS snapshots and volumes.

There is hardcoded list of regions that it searches, adjust the value to suit your needs.

Use snapshot.py snapshot-report to generate report.csv containing information about all snapshots.

snapshot.py snapshot-cleanup lets you interactively delete snapshot if it finds it is referencing unexisting resources.

./snapshots.py --help