Skip to content

Instantly share code, notes, and snippets.

View prasvats's full-sized avatar

Prashant Vats prasvats

View GitHub Profile
@prasvats
prasvats / nginx_node
Created November 2, 2021 16:04
nginx_node
server {
listen 80;
location /
{
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
@prasvats
prasvats / S3LifeCycle.py
Created August 9, 2020 19:41
S3LifeCycle.py
import boto3
from botocore.exceptions import ClientError
session = boto3.Session(profile_name='tsample', region_name='ap-southeast-2')
client = session.client('s3')
try:
all_buckets = client.list_buckets()
policy_status = client.put_bucket_lifecycle_configuration(
Bucket='sample-compute-optimizer',
LifecycleConfiguration={
'Rules': [
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment-50001
spec:
selector:
matchLabels:
app: products
department: sales
replicas: 3
@prasvats
prasvats / es.py
Created February 26, 2020 06:24
Python Script to test ElasticSearch
import boto3
import json
import requests
from requests_aws4auth import AWS4Auth
#Get Temporary Credentials
credentials = boto3.Session().get_credentials()
service = 'es'
region = 'ap-southeast-2'
@prasvats
prasvats / debugindocker
Created September 26, 2019 05:07
Debug in Docker Debian
apt-get update
apt-get install telnet -y
apt-get install curl -y
apt-get install net-tools -y
apt-get install procps -y
@prasvats
prasvats / trigger_jenkins_job.py
Created September 5, 2019 18:51
Python Script to trigger a Jenkins job remotely
import jenkins
import time
# It comes with pip module python-jenkins
# use pip to install python-jenkins
# Jenkins Authentication URL
JENKINS_URL = "https://xxxx"
JENKINS_USERNAME = "xxxxx"
JENKINS_PASSWORD = "xxxxxxx"
@prasvats
prasvats / Exposed_AWS_Resources.sh
Created August 12, 2019 11:13
This Script will check exposed EBS Snapshots, AMI and RDS Snapshots across all AWS region
declare -a regions=("eu-north-1" "ap-south-1" "eu-west-3" "eu-west-2" "eu-west-1" "ap-northeast-2" "ap-northeast-1" "sa-east-1" "ca-central-1" "ap-southeast-1" "ap-southeast-2" "eu-central-1" "us-east-1" "us-east-2" "us-west-1" "us-west-2")
for region in "${regions[@]}"
do
echo "+++++++++++++++++++++++++++++"
echo "Checking for Region: $region"
echo "-----------------------------"
echo "Exposed EBS Snapshots"
aws ec2 --region $region describe-snapshots --owner-id self --restorable-by-user-ids all --no-paginate --output table
echo "Exposed RDS Snapshots"
aws rds --region $region describe-db-snapshots --snapshot-type public --no-paginate --output table
@prasvats
prasvats / Jenkins.sh
Created June 25, 2019 15:02
Install Jenkins
sudo apt-get update
sudo locale-gen
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install default-jdk
sudo apt policy jenkins
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc
echo "export LANG=en_US.UTF-8" >> ~/.bashrc
source ~/.bashrc
@prasvats
prasvats / self-sign-cert
Created June 10, 2019 10:26
Generate Self Sign Certificate
openssl req -new -newkey rsa:2048 -nodes -out magento-2_3_1_suresh_com.csr -keyout magento-2_3_1_suresh_com.key -subj "/C=IN/ST=Delaware/L=Noida/O=TTN/OU=Admin/CN=magento-2.3.1.suresh.com"
openssl x509 -req -days 365 -in magento-2_3_1_suresh_com.csr -signkey magento-2_3_1_suresh_com.key -out magento-2_3_1_suresh_com.crt
@prasvats
prasvats / install_k8.sh
Created May 23, 2019 06:19
Install K8 on CentOS | Pseudo Steps
#!/bin/bash
yum update
#Install repo adder
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum update && yum install docker-ce-18.06.2.ce
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],