This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install --user --upgrade boto3 | |
export instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
python -c "import boto3 | |
import os | |
from botocore.exceptions import ClientError | |
ec2 = boto3.client('ec2') | |
volume_info = ec2.describe_volumes( | |
Filters=[ | |
{ | |
'Name': 'attachment.instance-id', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for volume in `aws ec2 describe-instances --filters Name=tag:tag-key,Values=tag-value --query 'Reservations[*].Instances[*].BlockDeviceMappings[*].Ebs.VolumeId' --output=text` | |
do | |
aws ec2 describe-volumes --volume-ids $volume --query 'Volumes[*].Encrypted' --output=text | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This is useful in case when you want your local docker to point to the minikube VM. | |
## So after running the below commands, you docker commands will return from the minikube vm. | |
## `docker images` will no longer report images on your local mac workstation but the images on the minikube VM. | |
## you may just run the eval command as in the last line to do all at once. | |
export DOCKER_TLS_VERIFY="1" | |
export DOCKER_HOST="tcp://192.168.99.106:2376" | |
export DOCKER_CERT_PATH="/Users/anurag.mathur/.minikube/certs" | |
# Run this command to configure your shell: | |
# eval $(minikube docker-env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GITLAB_GROUP="<group-name>" | |
GITLAB_PRIVATE_TOKEN="<token>" | |
GITLAB_ADDRESS="gitlab.<name>" | |
for i in `curl -s "https://$GITLAB_ADDRESS/api/v4/groups/$GITLAB_GROUP/projects?private_token=$GITLAB_PRIVATE_TOKEN&per_page=999" | \ | |
grep -o "\"ssh_url_to_repo\":[^ ,]\+" | \ | |
awk -F ':' '{gsub(/"/, "", $2); gsub(/"/, "", $3); print $2":"$3}'`; do git clone $i; done | |
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
## The script deletes the snapshots that are : | |
## - not attached to an AMI | |
## - are atleast 90 days old | |
## Output : | |
## - soem csv files if a report is required | |
## - the return values ( return_code && request_id from the delete command ) | |
## Usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install python3-pip -y | |
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1 | |
sudo update-alternatives --config python | |
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 | |
sudo update-alternatives --config pip | |
pip install aws-cdk.cdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import boto3 | |
s3 = boto3.resource('s3') | |
bucket = s3.Bucket('<<Bucket-name-here>>') | |
bucket.object_versions.all().delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'jenkins_api_client' | |
SERVER_IP = 'jenkins.dev.example.com' | |
$build = JenkinsApi::Client.new(:server_ip => "#{SERVER_IP}",:username => 'admin', :password => 'admin') | |
$opts = {'build_start_timeout' => 60, 'cancel_on_build_start_timeout' => true} | |
$build.job.build("test-project",{:parameter1=>"value-1",\ | |
:parameter2=>"value-2",\ | |
:parameter3=>"value-3",\ | |
:parameter4=>"value-4"} || {}, $opts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import boto3 | |
client = boto3.client('ec2') | |
account_number = boto3.client('sts').get_caller_identity()['Account'] | |
response = client.describe_images(Owners=[account_number]) | |
for image in response['Images']: | |
if "2017-08-21" in image['CreationDate']: | |
image_id = image['ImageId'] | |
snapshot_id = image['BlockDeviceMappings'][0]['Ebs']['SnapshotId'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find all instances and list their Private IP, instance-id and Name | |
# You may specify more filters like the vpc | |
# Name=vpc-id,Values=vpc-xxxxxxxx | |
aws ec2 describe-instances --filters --query 'Reservations[].Instances[].[PrivateIpAddress,InstanceId,Tags[?Key==`Name`].Value[]]' --output text --profile=elmodev | sed '$!N;s/\n/ /' |
NewerOlder