This file contains hidden or 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
| aws support describe-trusted-advisor-check-result --check-id eW7HH0l7J9 --query 'result.sort_by(flaggedResources[?status!="ok"],&metadata[2])[].metadata' --output table --region us-east-1 |
This file contains hidden or 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
| #!/bin/bash | |
| # Example would be to run this script as follows: | |
| # Every 6 hours; retain last 4 backups | |
| # efs-backup.sh $src $dst hourly 4 efs-12345 | |
| # Once a day; retain last 31 days | |
| # efs-backup.sh $src $dst daily 31 efs-12345 | |
| # Once a week; retain 4 weeks of backup | |
| # efs-backup.sh $src $dst weekly 7 efs-12345 | |
| # Once a month; retain 3 months of backups | |
| # efs-backup.sh $src $dst monthly 3 efs-12345 |
This file contains hidden or 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
| import boto3 | |
| import time | |
| region = 'eu-west-1' | |
| user_data_script = """#!/bin/bash | |
| instanceid=$(curl http://169.254.169.254/latest/meta-data/instance-id) | |
| cd / | |
| mkdir moodledata | |
| mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-xxxxxxxxxxc.efs.eu-west-1.amazonaws.com:/ moodledata | |
| tar czf mooodledata-backup-$(date +%d-%m-%Y_%H-%M).tar.gz /moodledata | |
| aws s3 mv mooodledata-backup-*.tar.gz s3://xxxxxxxxx/ |
This file contains hidden or 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 bash | |
| set -e | |
| function usage() { | |
| set -e | |
| cat <<EOM | |
| ##### ecs-run ##### | |
| Simple script for running tasks on Amazon Elastic Container Service | |
| One of the following is required: | |
| Required arguments: |
This file contains hidden or 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 bash | |
| if [ $# -eq 0 ]; then | |
| echo "" | |
| echo " Package an AWS Lambda script with all node modules into a zip file" | |
| echo " The packager runs in an AWS Linux docker container, so the node " | |
| echo " modules are compiled for the correct architecture." | |
| echo "" | |
| echo " -s/--src The source folder of the lambda script" | |
| echo " -d/--destination The destination folder for the lambda zip file" |
This file contains hidden or 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 has been tested with ansible 1.3 with these commands: | |
| # ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false" | |
| # ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true" | |
| # ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts" | |
| # NB: The type of the variable is crucial! | |
| - name: Ansible Conditionals Examples | |
| hosts: $hosts | |
| vars_files: |
This file contains hidden or 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
| #!/bin/bash | |
| ZONEFILEDIR="/usr/share/zoneinfo" | |
| ZONEFOLDERNAME=$(echo $ZONEFILEDIR | awk 'BEGIN { FS="/" } { print $NF }') | |
| usage() { | |
| echo "usage: change-timezone.sh <-l [SEARCH] | -s ZONE>" | |
| echo " -l -> List available timezones and search for SEARCH" | |
| echo " -s -> Set timezone to ZONE (requires sudo/root access)" | |
| } |
This file contains hidden or 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
| #!/bin/bash | |
| #### Set NTP Server | |
| # Sets correct Timezone. If no Timezone is set, then default is CST | |
| timezone=$1 | |
| if [ "$timezone" = "CST" ] | |
| then | |
| echo "America/Chicago" |
This file contains hidden or 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 region in `aws ec2 describe-regions --output text | cut -f3` | |
| do | |
| echo "Terminating region $region..." | |
| aws ec2 describe-instances --region $region | \ | |
| jq -r .Reservations[].Instances[].InstanceId | \ | |
| xargs -L 1 -I {} aws ec2 modify-instance-attribute \ | |
| --region $region \ | |
| --no-disable-api-termination \ | |
| --instance-id {} | |
| aws ec2 describe-instances --region $region | \ |
This file contains hidden or 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
| export PROFILE=XXXX | |
| for USER in `aws --profile $PROFILE iam list-users --query 'Users[].UserName' --output text` | |
| do | |
| for KEY in `aws --profile $PROFILE iam list-access-keys --user-name "$USER" --query 'AccessKeyMetadata[].AccessKeyId' --output text` | |
| do | |
| echo $USER $KEY | |
| done | |
| done |