Skip to content

Instantly share code, notes, and snippets.

@kenzo0107
Last active February 4, 2020 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenzo0107/2dd4ec536ee19852c7a1f6fa7cd45276 to your computer and use it in GitHub Desktop.
Save kenzo0107/2dd4ec536ee19852c7a1f6fa7cd45276 to your computer and use it in GitHub Desktop.
AWS GuardDuty Archive Findings
#!/bin/sh
PROFILE=hoge
regions=$(aws ec2 describe-regions | jq -r '.Regions[].RegionName')
for region in $(echo ${regions})
do
echo "region: $region"
detector_id=$(aws --profile ${PROFILE} \
guardduty list-detectors \
--region ${REGION} \
| jq -r '.DetectorIds[]')
findings_ids=$(aws --profile ${PROFILE} \
guardduty list-findings \
--detector-id ${detector_id} \
--region ${REGION} \
| jq -r '.FindingIds[]')
ids=$(echo -n ${findings_ids} | tr '\n' ',')
aws --profile ${PROFILE} \
guardduty archive-findings \
--detector-id ${detector_id} \
--finding-ids ${ids} \
--region ${REGION}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment