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
snap=snap-123456789 | |
desc=$(aws ec2 describe-snapshots --snapshot-ids $snap --query Snapshots[].Description --output text) | |
aws ec2 create-volume --snapshot-id $snap --availability-zone ap-southeast-2c --tag-specifications "[{\"ResourceType\":\"volume\",\"Tags\":[{\"Key\":\"Name\",\"Value\":\"$desc\"}]}]" |
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
ROLE_TO_ASSUME="arn:aws:iam::${ACCOUNT_ID}:role/${ROLE_NAME}" | |
session_token=($(aws sts assume-role --role-arn $ROLE_TO_ASSUME --query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]' --role-session-name "$USER-$$" --output text)) | |
export AWS_ACCESS_KEY_ID="${session_token[1]}" AWS_SECRET_ACCESS_KEY="${session_token[2]}" AWS_SESSION_TOKEN="${session_token[3]}" |
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 route53 list-hosted-zones-by-name --dns-name example.com --query HostedZones[].Id --output text | cut -d/ -f3 |
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 acm us-east-1 list-certificates --query CertificateSummaryList[].[CertificateArn,DomainName] \ | |
--output text | grep example.com | cut -f1 |
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
### Keybase proof | |
I hereby claim: | |
* I am bashtoni on github. | |
* I am sambashton (https://keybase.io/sambashton) on keybase. | |
* I have a public key whose fingerprint is F008 00FE C6A4 AFB4 2E08 E1B7 E2CB 2ADC 2C3C 437C | |
To claim this, I am signing this object: |
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 ec2 describe-instances --filter --query 'Reservations[].Instances[?!not_null(Tags[?Key == `aws:autoscaling:groupName`].Value)] | [].[InstanceId]' --output text |
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 detectorid in $(aws guardduty list-detectors --query DetectorIds[] --output text); do | |
aws guardduty get-findings --detector-id $detectorid \ | |
--finding-ids $(aws guardduty list-findings --detector-id $detectorid --query FindingIds --output text) \ | |
--query 'Findings[*].[Resource.InstanceDetails.InstanceId,Type,Service.Count]' --output text | |
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 | |
for user in $(aws iam list-users --query 'Users[].UserName' --output text); do | |
for key in $(aws iam list-access-keys --user-name $user --query 'AccessKeyMetadata[].AccessKeyId' --output text); do | |
aws iam get-access-key-last-used --access-key-id $key --query '[UserName,AccessKeyLastUsed.LastUsedDate]' --output text | |
done | |
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
user=foo | |
for key in $(aws iam list-access-keys --user-name $foo --query 'AccessKeyMetadata[].AccessKeyId' --output text); do | |
aws iam get-access-key-last-used --access-key-id $key | |
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 | |
if [ -n $1 ]; then | |
echo "Usage: $0 <username>" | |
fi | |
user=$1 | |
# First, find which groups the user is in and remove them from there | |
for group in $(aws iam list-groups-for-user --user-name $user --query Groups[].GroupName --output text); do | |
aws iam remove-user-from-group --user-name $user --group-name $group |