Skip to content

Commit

Permalink
[Improvement] * - Support to disable AWS Backup (widdix#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig authored Aug 13, 2019
1 parent 0645bac commit e6d3049
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 12 deletions.
9 changes: 7 additions & 2 deletions jenkins/jenkins2-ha-agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ Parameters:
Type: Number
Default: 0
EFSBackupRetentionPeriod:
Description: 'The number of days to keep backups of the EFS file system.'
Description: 'The number of days to keep backups of the EFS file system (set to 0 to disable).'
Type: Number
MinValue: 1
MinValue: 0
MaxValue: 35
Default: 30
EFSBackupScheduleExpression:
Expand Down Expand Up @@ -269,6 +269,7 @@ Conditions:
HasNotEFSProvisionedThroughput: !Equals [!Ref EFSProvisionedThroughputInMibps, '0']
HasAlertTopicAndEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasEFSProvisionedThroughput]
HasAlertTopicAndNotEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasNotEFSProvisionedThroughput]
HasEFSBackupRetentionPeriod: !Not [!Equals [!Ref EFSBackupRetentionPeriod, 0]]
Resources:
MasterStorageSG:
Type: 'AWS::EC2::SecurityGroup'
Expand Down Expand Up @@ -2221,11 +2222,13 @@ Resources:
ThroughputInMibps: !Ref EFSProvisionedThroughputInMibps
ServiceToken: !GetAtt 'LambdaFunction.Arn'
BackupVault: # cannot be deleted with data
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupVault'
Properties:
BackupVaultName: !Ref 'AWS::StackName'
Notifications: !If [HasAlertTopic, {BackupVaultEvents: [BACKUP_JOB_STARTED, BACKUP_JOB_COMPLETED, RESTORE_JOB_STARTED, RESTORE_JOB_COMPLETED, RECOVERY_POINT_MODIFIED], SNSTopicArn: {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}}, !Ref 'AWS::NoValue']
BackupPlan:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupPlan'
Properties:
BackupPlan:
Expand All @@ -2239,6 +2242,7 @@ Resources:
StartWindowMinutes: 60
TargetBackupVault: !Ref BackupVault
BackupRole:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Expand All @@ -2259,6 +2263,7 @@ Resources:
- 'elasticfilesystem:DescribeTags'
Resource: !Sub 'arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:file-system/${MasterStorage}'
BackupSelection:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupSelection'
Properties:
BackupPlanId: !Ref BackupPlan
Expand Down
9 changes: 7 additions & 2 deletions jenkins/jenkins2-ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ Parameters:
Type: Number
Default: 0
EFSBackupRetentionPeriod:
Description: 'The number of days to keep backups of the EFS file system.'
Description: 'The number of days to keep backups of the EFS file system (set to 0 to disable).'
Type: Number
MinValue: 1
MinValue: 0
MaxValue: 35
Default: 30
EFSBackupScheduleExpression:
Expand Down Expand Up @@ -208,6 +208,7 @@ Conditions:
HasNotEFSProvisionedThroughput: !Equals [!Ref EFSProvisionedThroughputInMibps, '0']
HasAlertTopicAndEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasEFSProvisionedThroughput]
HasAlertTopicAndNotEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasNotEFSProvisionedThroughput]
HasEFSBackupRetentionPeriod: !Not [!Equals [!Ref EFSBackupRetentionPeriod, 0]]
Resources:
MasterStorageSG:
Type: 'AWS::EC2::SecurityGroup'
Expand Down Expand Up @@ -1040,11 +1041,13 @@ Resources:
ThroughputInMibps: !Ref EFSProvisionedThroughputInMibps
ServiceToken: !GetAtt 'LambdaFunction.Arn'
BackupVault: # cannot be deleted with data
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupVault'
Properties:
BackupVaultName: !Ref 'AWS::StackName'
Notifications: !If [HasAlertTopic, {BackupVaultEvents: [BACKUP_JOB_STARTED, BACKUP_JOB_COMPLETED, RESTORE_JOB_STARTED, RESTORE_JOB_COMPLETED, RECOVERY_POINT_MODIFIED], SNSTopicArn: {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}}, !Ref 'AWS::NoValue']
BackupPlan:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupPlan'
Properties:
BackupPlan:
Expand All @@ -1058,6 +1061,7 @@ Resources:
StartWindowMinutes: 60
TargetBackupVault: !Ref BackupVault
BackupRole:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Expand All @@ -1078,6 +1082,7 @@ Resources:
- 'elasticfilesystem:DescribeTags'
Resource: !Sub 'arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:file-system/${MasterStorage}'
BackupSelection:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupSelection'
Properties:
BackupPlanId: !Ref BackupPlan
Expand Down
9 changes: 7 additions & 2 deletions state/dynamodb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ Parameters:
Default: DISABLED
AllowedValues: [DISABLED, KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES]
BackupRetentionPeriod:
Description: 'The number of days to keep backups of the table.'
Description: 'The number of days to keep backups of the table (set to 0 to disable).'
Type: Number
MinValue: 1
MinValue: 0
MaxValue: 35
Default: 30
BackupScheduleExpression:
Expand All @@ -137,6 +137,7 @@ Conditions:
HasBillingAndScalingModeProvisioned: !Equals [!Ref BillingAndScalingMode, PROVISIONED]
HasTimeToLiveAttributeName: !Not [!Equals [!Ref TimeToLiveAttributeName, '']]
HasStream: !Not [!Equals [!Ref StreamViewType, 'DISABLED']]
HasBackupRetentionPeriod: !Not [!Equals [!Ref BackupRetentionPeriod, 0]]
Resources:
Table:
Type: 'AWS::DynamoDB::Table'
Expand Down Expand Up @@ -334,11 +335,13 @@ Resources:
OKActions:
- {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}
BackupVault: # cannot be deleted with data
Condition: HasBackupRetentionPeriod
Type: 'AWS::Backup::BackupVault'
Properties:
BackupVaultName: !Ref 'AWS::StackName'
Notifications: !If [HasAlertTopic, {BackupVaultEvents: [BACKUP_JOB_STARTED, BACKUP_JOB_COMPLETED, RESTORE_JOB_STARTED, RESTORE_JOB_COMPLETED, RECOVERY_POINT_MODIFIED], SNSTopicArn: {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}}, !Ref 'AWS::NoValue']
BackupPlan:
Condition: HasBackupRetentionPeriod
Type: 'AWS::Backup::BackupPlan'
Properties:
BackupPlan:
Expand All @@ -352,6 +355,7 @@ Resources:
StartWindowMinutes: 60
TargetBackupVault: !Ref BackupVault
BackupRole:
Condition: HasBackupRetentionPeriod
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Expand All @@ -377,6 +381,7 @@ Resources:
- 'dynamodb:DeleteBackup'
Resource: !Sub '${Table.Arn}/backup/*'
BackupSelection:
Condition: HasBackupRetentionPeriod
Type: 'AWS::Backup::BackupSelection'
Properties:
BackupPlanId: !Ref BackupPlan
Expand Down
9 changes: 7 additions & 2 deletions vpc/vpc-vpn-bastion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ Parameters:
Type: Number
Default: 0
EFSBackupRetentionPeriod:
Description: 'The number of days to keep backups of the EFS file system.'
Description: 'The number of days to keep backups of the EFS file system (set to 0 to disable).'
Type: Number
MinValue: 1
MinValue: 0
MaxValue: 35
Default: 30
EFSBackupScheduleExpression:
Expand Down Expand Up @@ -169,6 +169,7 @@ Conditions:
HasNotEFSProvisionedThroughput: !Equals [!Ref EFSProvisionedThroughputInMibps, '0']
HasAlertTopicAndEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasEFSProvisionedThroughput]
HasAlertTopicAndNotEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasNotEFSProvisionedThroughput]
HasEFSBackupRetentionPeriod: !Not [!Equals [!Ref EFSBackupRetentionPeriod, 0]]
Resources:
StorageSG:
Type: 'AWS::EC2::SecurityGroup'
Expand Down Expand Up @@ -873,11 +874,13 @@ Resources:
ThroughputInMibps: !Ref EFSProvisionedThroughputInMibps
ServiceToken: !GetAtt 'LambdaFunction.Arn'
BackupVault: # cannot be deleted with data
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupVault'
Properties:
BackupVaultName: !Ref 'AWS::StackName'
Notifications: !If [HasAlertTopic, {BackupVaultEvents: [BACKUP_JOB_STARTED, BACKUP_JOB_COMPLETED, RESTORE_JOB_STARTED, RESTORE_JOB_COMPLETED, RECOVERY_POINT_MODIFIED], SNSTopicArn: {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}}, !Ref 'AWS::NoValue']
BackupPlan:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupPlan'
Properties:
BackupPlan:
Expand All @@ -891,6 +894,7 @@ Resources:
StartWindowMinutes: 60
TargetBackupVault: !Ref BackupVault
BackupRole:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Expand All @@ -911,6 +915,7 @@ Resources:
- 'elasticfilesystem:DescribeTags'
Resource: !Sub 'arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:file-system/${Storage}'
BackupSelection:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupSelection'
Properties:
BackupPlanId: !Ref BackupPlan
Expand Down
9 changes: 7 additions & 2 deletions wordpress/wordpress-ha-aurora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ Parameters:
Type: Number
Default: 0
EFSBackupRetentionPeriod:
Description: 'The number of days to keep backups of the EFS file system.'
Description: 'The number of days to keep backups of the EFS file system (set to 0 to disable).'
Type: Number
MinValue: 1
MinValue: 0
MaxValue: 35
Default: 30
EFSBackupScheduleExpression:
Expand Down Expand Up @@ -231,6 +231,7 @@ Conditions:
HasAlertTopicAndEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasEFSProvisionedThroughput]
HasAlertTopicAndNotEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasNotEFSProvisionedThroughput]
HasManagedPolicyArns: !Not [!Equals [!Ref ManagedPolicyArns, '']]
HasEFSBackupRetentionPeriod: !Not [!Equals [!Ref EFSBackupRetentionPeriod, 0]]
Resources:
WebServerLogs:
Type: 'AWS::Logs::LogGroup'
Expand Down Expand Up @@ -1310,11 +1311,13 @@ Resources:
SslSupportMethod: 'sni-only'
MinimumProtocolVersion: TLSv1
BackupVault: # cannot be deleted with data
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupVault'
Properties:
BackupVaultName: !Ref 'AWS::StackName'
Notifications: !If [HasAlertTopic, {BackupVaultEvents: [BACKUP_JOB_STARTED, BACKUP_JOB_COMPLETED, RESTORE_JOB_STARTED, RESTORE_JOB_COMPLETED, RECOVERY_POINT_MODIFIED], SNSTopicArn: {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}}, !Ref 'AWS::NoValue']
BackupPlan:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupPlan'
Properties:
BackupPlan:
Expand All @@ -1328,6 +1331,7 @@ Resources:
StartWindowMinutes: 60
TargetBackupVault: !Ref BackupVault
BackupRole:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Expand All @@ -1348,6 +1352,7 @@ Resources:
- 'elasticfilesystem:DescribeTags'
Resource: !Sub 'arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:file-system/${EFSFileSystem}'
BackupSelection:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupSelection'
Properties:
BackupPlanId: !Ref BackupPlan
Expand Down
9 changes: 7 additions & 2 deletions wordpress/wordpress-ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ Parameters:
Type: Number
Default: 0
EFSBackupRetentionPeriod:
Description: 'The number of days to keep backups of the EFS file system.'
Description: 'The number of days to keep backups of the EFS file system (set to 0 to disable).'
Type: Number
MinValue: 1
MinValue: 0
MaxValue: 35
Default: 30
EFSBackupScheduleExpression:
Expand Down Expand Up @@ -231,6 +231,7 @@ Conditions:
HasAlertTopicAndEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasEFSProvisionedThroughput]
HasAlertTopicAndNotEFSProvisionedThroughput: !And [!Condition HasAlertTopic, !Condition HasNotEFSProvisionedThroughput]
HasManagedPolicyArns: !Not [!Equals [!Ref ManagedPolicyArns, '']]
HasEFSBackupRetentionPeriod: !Not [!Equals [!Ref EFSBackupRetentionPeriod, 0]]
Resources:
WebServerLogs:
Type: 'AWS::Logs::LogGroup'
Expand Down Expand Up @@ -1286,11 +1287,13 @@ Resources:
SslSupportMethod: 'sni-only'
MinimumProtocolVersion: TLSv1
BackupVault: # cannot be deleted with data
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupVault'
Properties:
BackupVaultName: !Ref 'AWS::StackName'
Notifications: !If [HasAlertTopic, {BackupVaultEvents: [BACKUP_JOB_STARTED, BACKUP_JOB_COMPLETED, RESTORE_JOB_STARTED, RESTORE_JOB_COMPLETED, RECOVERY_POINT_MODIFIED], SNSTopicArn: {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'}}, !Ref 'AWS::NoValue']
BackupPlan:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupPlan'
Properties:
BackupPlan:
Expand All @@ -1304,6 +1307,7 @@ Resources:
StartWindowMinutes: 60
TargetBackupVault: !Ref BackupVault
BackupRole:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Expand All @@ -1324,6 +1328,7 @@ Resources:
- 'elasticfilesystem:DescribeTags'
Resource: !Sub 'arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:file-system/${EFSFileSystem}'
BackupSelection:
Condition: HasEFSBackupRetentionPeriod
Type: 'AWS::Backup::BackupSelection'
Properties:
BackupPlanId: !Ref BackupPlan
Expand Down

0 comments on commit e6d3049

Please sign in to comment.