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 | |
| # Shell script to backup MySQL database | |
| # Set these variables | |
| MyUSER="" # DB_USERNAME | |
| MyPASS="" # DB_PASSWORD | |
| MyHOST="" # DB_HOSTNAME | |
| # Backup Dest directory | |
| DEST="" # /home/username/backups/DB |
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 u in $(aws iam list-users | jq ".Users[].UserName" --raw-output); do | |
| aws iam list-access-keys --user $u | jq '.AccessKeyMetadata[] | .UserName + ":" + .AccessKeyId' ; | |
| done |
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 -x | |
| yum -y update --security | |
| ########################## | |
| ## ENABLE SSH RECORDING ## | |
| ########################## | |
| # Create a new folder for the log files | |
| mkdir /var/log/bastion |
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
| a4b.amazonaws.com | |
| acm-pca.amazonaws.com | |
| acm.amazonaws.com | |
| alexa-appkit.amazon.com | |
| alexa-connectedhome.amazon.com | |
| amazonmq.amazonaws.com | |
| apigateway.amazonaws.com | |
| appflow.amazonaws.com | |
| application-autoscaling.amazonaws.com | |
| appstream.application-autoscaling.amazonaws.com |
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/sh | |
| ECHO='echo ' | |
| for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'main$\|develop$'); do | |
| if ! ( [[ -f "$branch" ]] || [[ -d "$branch" ]] ) && [[ "$(git log $branch --since "1 month ago" | wc -l)" -eq 0 ]]; then | |
| if [[ "$DRY_RUN" = "false" ]]; then | |
| ECHO="" | |
| fi | |
| local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///') | |
| $ECHO git branch -d "${local_branch_name}" |
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/python | |
| from OpenSSL import crypto | |
| import os | |
| import sys | |
| import datetime | |
| import whois | |
| #Variables | |
| TYPE_RSA = crypto.TYPE_RSA | |
| TYPE_DSA = crypto.TYPE_DSA |
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
| ## | |
| # Python Boto3 script to find the number of minutes an instance has been running. | |
| ## Output | |
| # i-00asdf5xxx50c96aa 84 days, 13:17:51.468559 | |
| # i-0260a1fxxx27ec894 6 days, 13:48:04.468643 | |
| # i-0acxxx6c630af322 13 days, 12:13:00.468659 | |
| # i-069bxxxd41bf975eb 19:42:08.468670 | |
| import boto3 | |
| from datetime import datetime, timezone |
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
| ''' quick example showing how to attach a pdf to multipart messages | |
| and then send them from SES via boto | |
| ''' | |
| from email.mime.text import MIMEText | |
| from email.mime.application import MIMEApplication | |
| from email.mime.multipart import MIMEMultipart | |
| import boto |
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 copy | |
| import logging | |
| import os | |
| import boto3 | |
| logging.basicConfig(level=os.environ.get('LOG_LEVEL', 'INFO')) | |
| ec2 = boto3.client('ec2') | |
| logger = logging.getLogger(__name__) |
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
| # most credit to the original: https://gist.github.com/brandond/6b4d22eaefbd66895f230f68f27ee586 | |
| # Tag snapshots based on their associated AMI and volumes based on attached instance. | |
| # format: | |
| # (AMI:db5|db5) /dev/sda1 (1/4) | |
| # (AMI:db5|db5) /dev/sdb (2/4) | |
| # Best practice: create IAM user | |
| # Simplest privilege to get it to work with reasonable security: use predefined policy "ReadOnlyAccess" |
OlderNewer