Cli AWS - Incident

List of commonly used AWS CLI

With EC2 - Network - Log

List Ec2 ldz

aws ec2 describe-instances --profile aws-tcbs | jq -r '.Reservations[].Instances[] | .InstanceId + " " + .InstanceType + " " + (.Tags[] | select(.Key == "Name").Value)'

List Security GP

aws ec2 describe-security-groups --profile aws-tcbs | jq -r '.SecurityGroups[]|.GroupId+" "+.GroupName'

List subnet vpc-id

aws ec2 describe-subnets--filter Name=vpc-id,Values=<Your_VPC_ID> --profile aws-tcbs | jq -r '.Subnets[]|.SubnetId+" "+.CidrBlock+" "+(.Tags[]|select(.Key=="Name").Value)'

List log Avaiable Region

aws logs describe-log-groups --profile aws-tcbs --region <region>

CP log

aws s3 cp s3://<log_bucket_here>/AWSLogs . --recursive --profile aws-tcbs

Snapshot and create Volume

aws ec2 create-snapshot --volume-id <volume_id> --description "Snapshotcreated"
aws ec2 create-volume --availability-zone ap-southeast-1 --snapshot-id <snapshot_id>

Use coldsnap download snapshot

Ref : https://github.com/awslabs/coldsnap

coldsnap --region ap-southeast-1 download <snapshot_id> image.dd

Mount snapshot

With IAM Log

Go to the cloudwatch console > select insight > logs > then choose your log groups and set your time constraints. Use the following queries to quickly identify suspicious activity:

IAM Logs

  • List all IAM access denied attemptsList all IAM user and role creation events filter errorCode like

  • List All IAM user and role creation events

  • List the actions an access key has performed

  • List all "ListBucket" event

  • List IAM actions performed by a specified IP

  • List all roles in json format

  • List all users

  • List all groups

  • Block role

  • Remove block

  • Block user

  • Remove block

  • Disable access key

VPC flow Logs

  • List reject requests by IP

  • List requests originating from a specific ip

  • List outgoing requests from a specific IP

  • List reject requests

Last updated

Was this helpful?