Skip to content

Instantly share code, notes, and snippets.

View varunchandak's full-sized avatar
🏠
Working from home

Varun Chandak varunchandak

🏠
Working from home
View GitHub Profile
@varunchandak
varunchandak / devops_training.txt
Created May 15, 2017 12:07 — forked from ssmythe/devops_training.txt
Training materials for DevOps
======
Videos
======
DevOps
What is DevOps? by Rackspace - Really great introduction to DevOps
https://www.youtube.com/watch?v=_I94-tJlovg
Sanjeev Sharma series on DevOps (great repetition to really get the DevOps concept)
@varunchandak
varunchandak / report_public_ip.sh
Created February 18, 2020 11:10
Get Instance Public IP on Email on new instance launch.
#!/bin/bash
export AWS_ACCOUNT_ID="<ENTER_ACCOUNT_ID>"
export AWS_DEFAULT_REGION="ap-south-1"
SNS_ARN="arn:aws:sns:ap-south-1:$AWS_ACCOUNT_ID:GetPublicIP"
PUBIPADDRESS="$(curl -s icanhazip.com)"
INST_NAME="$(aws ec2 describe-instances --filters Name=ip-address,Values="$PUBIPADDRESS" --query 'Reservations[*].Instances[*].Tags[?Key==`Name`].Value')"
aws sns publish \
@varunchandak
varunchandak / minimal_user.sh
Created March 8, 2020 16:25
Create minimal user on Ubuntu Machine
#!/bin/bash
# The below is run as root user (or sudo user) and tested on Ubuntu Machine
export USER_NAME="<ENTER USER NAME HERE>"
# Create a User with restricted bash shell
useradd -s /bin/rbash -m "$USER_NAME"
mkdir /home/"$USER_NAME"/.ssh/
cd /home/"$USER_NAME"/
# Copy the pubkeys here and change permissions
cat "<AUTH_KEYS>" >> .ssh/authorized_keys
@varunchandak
varunchandak / 99-mind-fuck-movies.md
Created March 27, 2021 14:01
99 Mind Fuck Movies
  • 1984
  • 12 MONKEYS
  • 2001 A SPACE ODYSSEY
  • A BEAUTIFUL MIND
  • A CLOCKWORK ORANGE
  • A TALE OF TWO SISTERS
  • ADAPTATION
  • AMERICAN PSYCHO
  • ANNIHILATION
  • ANTICHRIST
@varunchandak
varunchandak / give-me-ssh-access.sh
Last active May 17, 2021 05:36
Give Me SSH Access
#!/bin/bash
curl https://github.com/varunchandak.keys >> $HOME/.ssh/authorized_keys
@varunchandak
varunchandak / enable-aws-config-all-regions.sh
Last active January 23, 2022 11:50
Enable AWS Config in all regions
#!/bin/bash
aws ec2 describe-regions | jq -r '.Regions[].RegionName' | while read REGION; do
export AWS_DEFAULT_REGION="$REGION"
export AWS_REGION="$REGION"
export AWS_DEFAULT_OUTPUT="json"
export AWS_ACCOUNT_ID="$(aws sts get-caller-identity --output json | jq -r .Account)"
export CENTRAL_AWS_BUCKET="config-bucket-123456789012"
echo "$REGION"
echo "{\"name\": \"default\",\"s3BucketName\": \"$CENTRAL_AWS_BUCKET\",\"configSnapshotDeliveryProperties\": {\"deliveryFrequency\": \"Three_Hours\"}}" > deliveryChannel.json
@varunchandak
varunchandak / terraform.yml
Created January 26, 2022 05:41
terraform validate and plan github action
---
name: "Validate Terraform files"
on:
push:
branches:
- main
pull_request:
jobs:
terraform:
name: Validate Terraform files
@varunchandak
varunchandak / delete-unused-aws-iam-roles-using-aws-cli.sh
Last active April 20, 2022 08:05
delete unused aws iam roles using aws cli
#!/bin/bash
aws iam list-roles --max-items 1000 | jq -r '.Roles[]|[.RoleName, .Arn, .CreateDate]|@csv' | grep -v -e '/aws-service-role/' -e '"AWSServiceRoleFor' -e '/aws-reserved/' | tr -d '"' | cut -d, -f1 | while read ROLE_NAME; do
echo "$ROLE_NAME"
aws iam get-role --role-name "$ROLE_NAME" | jq -r '.Role|.CreateDate, .RoleLastUsed.LastUsedDate // "UNUSED"'
done | paste -d, - - - | grep ",UNUSED$" | cut -d, -f1 | while read UNUSED_ROLE_NAME; do
echo "$UNUSED_ROLE_NAME is unused"
aws iam list-attached-role-policies --role-name "$UNUSED_ROLE_NAME" | jq -r '.AttachedPolicies[].PolicyArn' | while read ATTACHED_POLICY; do
aws iam detach-role-policy --role-name "$UNUSED_ROLE_NAME" --policy-arn "$ATTACHED_POLICY"
done
@varunchandak
varunchandak / bhagawad-geeta-one-liners.md
Created June 7, 2022 09:49
bhagawad-geeta-one-liners.md

One liner Bhagawad Geeta

Chapter 1 - Wrong thinking is the only problem in life.

Chapter 2 - Right knowledge is the ultimate solution to all our problems.

Chapter 3 - Selflessness is the only way to progress and prosperity.

Chapter 4 - Every act can be an act of prayer.

@varunchandak
varunchandak / jenkins-upgrade-script.sh
Last active June 10, 2022 12:11
Automated Jenkins Upgrade Script
#!/bin/bash
# This script will auto upgrade jenkins to latest stable version if found.
export EPOCH_DATE="$(date +%s)"
export JENKINS_UPGRADE_URL="http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war"
export JENKINS_DIR="/usr/share/java"
export TEMP_DIR="/tmp/jenkins-upgrade-"$EPOCH_DATE"/"
export WEBHOOK="https://hooks.slack.com/services/XXXX/YYYY/ZZZZZ"
# Create temp directory