ssh-keygen -f ~/.ssh/id_rsa.pub -e -m PKCS8 > ~/.ssh/id_rsa.pem
echo "sometext" | openssl rsautl -encrypt -pubin -inkey ~/.ssh/id_rsa.pem > ~/encrypted-file.txt
from collections import defaultdict | |
import boto3 | |
""" | |
A tool for retrieving basic information from the running EC2 instances. | |
""" | |
# Connect to EC2 | |
ec2 = boto3.resource('ec2') |
aws s3 ls s3://my-prod/directory --recursive --human-readable --summarize --profile aws-profile | |
aws s3 ls --summarize --human-readable --recursive s3://my-prod/* --profile aws-profile | |
aws s3 ls s3://my-prod --recursive --human-readable --summarize --profile aws-profile | |
aws s3 ls --profile aws-profile s3://my-prod --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}' |
#Get the list of all the queues | |
rabbitmqadmin -f tsv --vhost=/ --username=RABBITMQ_USER --password=RABBITMQ_PASSWORD -q list queues name > file.txt | |
#Remove all the queues | |
while read -r name; do rabbitmqadmin --vhost=/ --username=RABBITMQ_USER --password=RABBITMQ_PASSWORD -q delete queue name="${name}"; done < file.txt |
openssl req -x509 -out localhost.crt -keyout localhost.key \ | |
-newkey rsa:2048 -nodes -sha256 -days 1024 \ | |
-subj '/CN=localhost' -extensions EXT -config <( \ | |
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth") |
#!/usr/bin/env bash | |
get_task_definition_arns() { | |
aws ecs list-task-definitions --region ${AWS_REGION} \ | |
| jq -M -r '.taskDefinitionArns | .[]' | |
} | |
delete_task_definition() { | |
local arn=$1 |
sudo add-apt-repository ppa:ts.sch.gr/ppa | |
sudo apt-get update | |
sudo apt-get install oracle-java8-installer |
#!/usr/bin/env python3 | |
# | |
# Script to replace EC2 instances in an ECS cluster's auto-scaling group after | |
# changing the AMI or instance type in the launch configuration. It | |
# checks for instances with the incorrect AMI or type, scales up the | |
# auto-scaling group with replacement instances, then drains the tasks | |
# from the old instances. | |
# | |
# Usage: aws-vault exec profile-name -- python3 replace_ecs_cluster_instances.py --group=asg-name --cluster=ecs-cluster-name --count=3 | |
# |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"ssm:DescribeSessions", | |
"ssm:GetConnectionStatus", | |
"ssm:DescribeInstanceProperties", | |
"ec2:DescribeInstances", |