UPD: Various additions

This commit is contained in:
xpk 2024-07-24 09:57:48 +08:00
parent 1afeac32f0
commit 863b5c7480
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
4 changed files with 19 additions and 0 deletions

6
aws/ec2-with-public-ip.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
aws sts get-caller-identity --query Account
aws ec2 describe-instances --query 'Reservations[].Instances[?PublicIpAddress != `null`].[InstanceId, PublicIpAddress]' --output text
echo "= = ="

View File

@ -0,0 +1,6 @@
aws iam list-policies --scope Local | jq -cr '.Policies[].Arn' | while read i; do
VER=$(aws iam get-policy --policy-arn $i | jq -cr .Policy.DefaultVersionId)
POLNAME=$(echo $i | awk -F/ '{print $NF}')
aws iam get-policy-version --policy-arn $i --version-id $VER > iam-policies/$POLNAME.json
done

View File

@ -0,0 +1,6 @@
#!/bin/bash
BUCKET=$1
aws s3 ls s3://$BUCKET --recursive | awk '{print $NF}' | while read i; do
aws s3api restore-object --bucket $BUCKET --key $i --restore-request Days=20
done

1
aws/sso-login-events.sh Normal file
View File

@ -0,0 +1 @@
aws cloudtrail lookup-events --start-time $(date -d '48 hour ago' +%s) --lookup-attributes AttributeKey=Username,AttributeValue=LEDP636 | jq -cr '.Events[] | .CloudTrailEvent' | jq -cr '[.eventTime, .eventName, .userIdentity.userName, .sourceIPAddress, .additionalEventData.CredentialType, .serviceEventDetails.CredentialVerification] | @tsv'