Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save quiver/12b1163e084bd4149929a9e185f1103b to your computer and use it in GitHub Desktop.
Save quiver/12b1163e084bd4149929a9e185f1103b to your computer and use it in GitHub Desktop.
CloudFormation template to configure thin backup rules for AWS Backup
AWSTemplateFormatVersion: "2010-09-09"
Description: "Backup Plan template for thin backups"
Resources:
BackupVaultWithThinBackups:
Type: "AWS::Backup::BackupVault"
Properties:
BackupVaultName: "BackupVaultWithThinBackups"
BackupPlanWithThinBackups:
Type: "AWS::Backup::BackupPlan"
Properties:
BackupPlan:
BackupPlanName: "BackupPlanWithThinBackups"
BackupPlanRule:
-
RuleName: "RuleForDailyBackups"
TargetBackupVault: !Ref BackupVaultWithThinBackups
ScheduleExpression: "cron(0 5 ? * * *)"
Lifecycle:
DeleteAfterDays: 7
-
RuleName: "RuleForWeeklyBackups"
TargetBackupVault: !Ref BackupVaultWithThinBackups
ScheduleExpression: "cron(0 5 ? * 1 *)"
Lifecycle:
DeleteAfterDays: 28
-
RuleName: "RuleForMonthlyBackups"
TargetBackupVault: !Ref BackupVaultWithThinBackups
ScheduleExpression: "cron(0 5 1 * ? *)"
Lifecycle:
DeleteAfterDays: 90
DependsOn: BackupVaultWithThinBackups
TagBasedBackupSelection:
Type: "AWS::Backup::BackupSelection"
Properties:
BackupSelection:
SelectionName: "TagBasedBackupSelection"
IamRoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/service-role/AWSBackupDefaultServiceRole"
ListOfTags:
-
ConditionType: "STRINGEQUALS"
ConditionKey: "backup"
ConditionValue: "thinbackup"
BackupPlanId: !Ref BackupPlanWithThinBackups
DependsOn: BackupPlanWithThinBackups
@abhiknovis
Copy link

Is it all using the default role and dynamodb? What if someone uses a default vault?

@quiver
Copy link
Author

quiver commented May 6, 2021

This CFn template is intended for basic/default usage.
Please customize it for your specific use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment