Created
May 4, 2018 10:54
-
-
Save raelga/12636dab813678697d93ef8690bcbf93 to your computer and use it in GitHub Desktop.
This file contains 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 | |
set -euo pipefail | |
function EnableStackDynamoDbBackups { | |
local CF_STACK="$1" | |
local CF_REGION=${2:-eu-central-1} | |
echo "Getting tables from the $CF_STACK stack in the $CF_REGION region." | |
local CF_TABLES=$(aws cloudformation describe-stack-resources \ | |
--stack-name ${CF_STACK} \ | |
--query 'StackResources[?ResourceType == `AWS::DynamoDB::Table`].PhysicalResourceId' \ | |
--output text \ | |
--region ${CF_REGION} | |
); | |
if [ ${#CF_TABLES[@]} -eq 0 ]; then | |
echo "Didn't found any table in ${CF_STACK}." | |
return | |
fi | |
for TABLE in ${CF_TABLES}; | |
do | |
echo "Enabling Backups for $TABLE" | |
aws dynamodb update-continuous-backups \ | |
--table-name ${CF} \ | |
--point-in-time-recovery-specification 'PointInTimeRecoveryEnabled=true' \ | |
--region ${CF_REGION} | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment