Skip to content

Instantly share code, notes, and snippets.

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

Branden Dane DaneTheory

🏠
Working from home
View GitHub Profile
@namuan
namuan / aws-cli-examples.sh
Last active March 20, 2021 00:04
[AWS CLI examples] #aws #cli
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[*]'
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[*].Tags[?Key==`Name`]'
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?Tags[?starts_with(Value, `registration`)]]'
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?Tags[?starts_with(Value, `email`)]]'
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[] | [?contains(Tags[?Key==`Name`].Value, `email-01`)]' --output table
@aniket91
aniket91 / email_ses.js
Created August 16, 2018 15:32
Node.js code snippet to send email using AWS SES service
const aws = require('aws-sdk');
aws.config.loadFromPath('./config.json');
const ses = new aws.SES();
/**
* author: athakur
* aws ses create-template --cli-input-json fileb://test_template.json --region us-east-1 --profile osfg
* aws ses update-template --cli-input-json fileb://test_template.json --region us-east-1 --profile osfg
* @param {*} callback
*/
@alan-cugler
alan-cugler / aws.sh
Created August 6, 2018 14:16
AWS commands
aws ec2 describe-instances
#
aws ec2 start-instances --instance-ids i-1348636c
#
aws sns publish --topic-arn arn:aws:sns:us-east-1:546419318123:OperationsError --message "Script Failure"
#
aws sqs receive-message --queue-url https://queue.amazonaws.com/546419318123/Test
#
aws autoscaling create-auto-scaling-group help
#
@holmesjr
holmesjr / git-credential-secrets-manager
Created August 1, 2018 23:25
A git credentials helper the uses AWS secrets manager
#!/bin/bash
set -eu
# The function creates global variables with the parsed results.
# It returns 0 if parsing was successful or non-zero otherwise.
#
# [schema://][user[:password]@]host[:port][/path][?[arg1=val1]...][#fragment]
#
# from http://vpalos.com/537/uri-parsing-using-bash-built-in-features/
parse_url() {
#!/bin/bash
DOMAIN=$1
mkdir -p /tmp/appwatch-bbl
mkdir -p /tmp/certbot
gsutil cp gs://appwatch-bbl/my-app-config.json /tmp/appwatch-bbl/my-app-config.json
chmod 600 /tmp/appwatch-bbl/my-app-config.json
@takuma-saito
takuma-saito / Route53For.sh
Created July 25, 2018 13:32
Route53-iam.sh
#!/bin/bash -xe
domain_name=$1
[[ $# < 1 ]] && echo "$0 <domain_name>" && exit 1
name=$(echo $domain_name | tr -d '.')
policy_name=$(basename $0 .sh)$(echo ${name:0:1} | tr 'a-z' 'A-Z')${name:1}
hostedzone=$(aws route53 list-hosted-zones |
jq -r '.HostedZones[] | select(.Name == "'$domain_name'.") | .Id')
delete_policy=$(dirname $0)/delete_and_detach_policy.sh
[[ -f $delete_policy ]] && $delete_policy $policy_name
[[ -z $hostedzone ]] && echo "unknown domain name: ${domain_name}" && exit 1
@dserodio
dserodio / aws.sh
Last active June 21, 2022 17:50
AWS snippets
# find the owner of an AWS access key
# https://stackoverflow.com/a/31275655
for user in $(aws iam list-users --output text | awk '{print $NF}'); do
aws iam list-access-keys --user $user --output text
done
# alternative that uses jq(1) insteaed of awk(1)
for user in $(aws iam list-users --query 'Users[*].UserName' --output text); do
@chrisenytc
chrisenytc / aws-metadata.sh
Created July 22, 2018 05:43
Creating wildcard ssl with certbot on AWS
#!/bin/bash
set -e
# Set environment variables
export AWS_IAM_ROLE=$(curl "http://169.254.169.254/latest/meta-data/iam/security-credentials/" 2>/dev/null)
if [ "${AWS_IAM_ROLE}" ]; then
export AWS_ACCESS_KEY_ID=$(curl "http://169.254.169.254/latest/meta-data/iam/security-credentials/${AWS_IAM_ROLE}" 2>/dev/null | jq -r .AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(curl "http://169.254.169.254/latest/meta-data/iam/security-credentials/${AWS_IAM_ROLE}" 2>/dev/null | jq -r .SecretAccessKey)
@thieryl
thieryl / 01_aws_rbd_cli.md
Last active March 31, 2022 10:49
[AWS] Amazon Web Services #aws

AWS CLI RBD

White list office ip

aws allow-my-ip "Proxy-Cerebro" tcp 22 rbd_sys
#!/bin/bash
AWS_DEFAULT_REGION=$1
AWS_ACCESS_KEY_ID=$2
AWS_SECRET_ACCESS_KEY=$3
domain=$4
networkStack=$5
#Parameters validation
if [[ $1 && $2 && $3 ]]; then
export AWS_DEFAULT_REGION AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY