Asignación de recursos AWS Backup a través de AWS CloudFormation
Esta plantilla integral de AWS CloudFormation crea una asignación de recursos, un plan de copia de seguridad y un almacén de copias de seguridad de destino:
-
Un almacén de copias de seguridad denominado
CloudFormationTestBackupVault
. -
Un plan de copia de seguridad denominado
CloudFormationTestBackupPlan.
Este plan contiene dos reglas de copia de seguridad, que hacen copias de seguridad todos los días a las 12 del mediodía UTC y las retienen durante 210 días. -
Una selección de recursos denominada
BackupSelectionName
. -
-
La asignación de recursos hace una copia de seguridad de los siguientes recursos:
-
Cualquier recurso etiquetado con el par clave-valor
backupplan:dsi-sandbox-daily
. -
Cualquier recurso etiquetado con el valor
prod
o valores que comiencen porprod/
.
-
-
La asignación de recursos no hace una copia de seguridad de los siguientes recursos:
-
Cualquier clúster de RDS, Aurora, Neptune o DocumentDB.
-
Cualquier recurso etiquetado con el valor
test
o valores que comiencen portest/
.
-
-
Description: "Template that creates Backup Selection and its dependencies" Parameters: BackupVaultName: Type: String Default: "CloudFormationTestBackupVault" BackupPlanName: Type: String Default: "CloudFormationTestBackupPlan" BackupSelectionName: Type: String Default: "CloudFormationTestBackupSelection" BackupPlanTagValue: Type: String Default: "test-value-1" RuleName1: Type: String Default: "TestRule1" RuleName2: Type: String Default: "TestRule2" ScheduleExpression: Type: String Default: "cron(0 12 * * ? *)" StartWindowMinutes: Type: Number Default: 60 CompletionWindowMinutes: Type: Number Default: 120 RecoveryPointTagValue: Type: String Default: "test-recovery-point-value" MoveToColdStorageAfterDays: Type: Number Default: 120 DeleteAfterDays: Type: Number Default: 210 Resources: CloudFormationTestBackupVault: Type: "AWS::Backup::BackupVault" Properties: BackupVaultName: !Ref BackupVaultName BasicBackupPlan: Type: "AWS::Backup::BackupPlan" Properties: BackupPlan: BackupPlanName: !Ref BackupPlanName BackupPlanRule: - RuleName: !Ref RuleName1 TargetBackupVault: !Ref BackupVaultName ScheduleExpression: !Ref ScheduleExpression StartWindowMinutes: !Ref StartWindowMinutes CompletionWindowMinutes: !Ref CompletionWindowMinutes RecoveryPointTags: test-recovery-point-key-1: !Ref RecoveryPointTagValue Lifecycle: MoveToColdStorageAfterDays: !Ref MoveToColdStorageAfterDays DeleteAfterDays: !Ref DeleteAfterDays - RuleName: !Ref RuleName2 TargetBackupVault: !Ref BackupVaultName ScheduleExpression: !Ref ScheduleExpression StartWindowMinutes: !Ref StartWindowMinutes CompletionWindowMinutes: !Ref CompletionWindowMinutes RecoveryPointTags: test-recovery-point-key-1: !Ref RecoveryPointTagValue Lifecycle: MoveToColdStorageAfterDays: !Ref MoveToColdStorageAfterDays DeleteAfterDays: !Ref DeleteAfterDays BackupPlanTags: test-key-1: !Ref BackupPlanTagValue DependsOn: CloudFormationTestBackupVault TestRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: - "backup.amazonaws.com" Action: - "sts:AssumeRole" ManagedPolicyArns: - !Sub "arn:
${AWS::Partition}
:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup
" BasicBackupSelection: Type: 'AWS::Backup::BackupSelection' Properties: BackupPlanId: !Ref BasicBackupPlan BackupSelection: SelectionName: !Ref BackupSelectionName IamRoleArn: !GetAtt TestRole.Arn ListOfTags: - ConditionType: STRINGEQUALS ConditionKey: backupplan ConditionValue: dsi-sandbox-daily NotResources: - 'arn:aws:rds:*:*:cluster:*' Conditions: StringEquals: - ConditionKey: 'aws:ResourceTag/path' ConditionValue: prod StringNotEquals: - ConditionKey: 'aws:ResourceTag/path' ConditionValue: test StringLike: - ConditionKey: 'aws:ResourceTag/path' ConditionValue: prod/* StringNotLike: - ConditionKey: 'aws:ResourceTag/path' ConditionValue: test/*