Created
October 30, 2015 20:45
-
-
Save anamorph/6c62bb992ca795952399 to your computer and use it in GitHub Desktop.
# Create trails in all AWS standard regions with the AWS CLI and Linux.
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
# Create trails in all AWS standard regions with the AWS CLI and Linux. | |
SCRIPTNAME=$0 | |
if [ -z $3 ] | |
then | |
echo "$SCRIPTNAME is missing parameters. | |
Usage: $SCRIPTNAME bucket region profile | |
Example: $SCRIPTNAME my-cloudtrail-bucket eu-west-1 default" | |
else | |
CLOUDTRAIL_S3_BUCKET=$1 | |
REGION_FOR_GLOBAL_EVENTS=$2 | |
PROFILE=$3 | |
regionlist=($(aws ec2 describe-regions --query Regions[*].RegionName --output text)) | |
for region in "${regionlist[@]}" | |
do | |
if [ $region = $REGION_FOR_GLOBAL_EVENTS ] | |
then | |
aws --profile $PROFILE --region $region cloudtrail create-trail --name $region --s3-bucket-name $CLOUDTRAIL_S3_BUCKET --include-global-service-events --output table | |
else | |
aws --profile $PROFILE --region $region cloudtrail create-trail --name $region --s3-bucket-name $CLOUDTRAIL_S3_BUCKET --no-include-global-service-events --output table | |
fi | |
aws --profile $PROFILE --region $region cloudtrail start-logging --name $region --output table | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment