Last active
February 4, 2020 02:59
-
-
Save kenzo0107/2dd4ec536ee19852c7a1f6fa7cd45276 to your computer and use it in GitHub Desktop.
AWS GuardDuty Archive Findings
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 | |
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