Cloud-Custodian: Deleting just specific backups of specific DynamoDB tables

155 Views Asked by At

When I want to use an aging policy for DaynamoDB there is not filtering for tables and backups and it deletes all backups of all tables which age is in the defined interval. Is there any way filtering and deleting just some of backups os some DynamoDB Tables? (like find just tagged as "..." tables and delete backups which name just includes "..." in that specific table)

policies:
  - name: dynamodb-delete-backup
    resource: dynamodb-backup
    filters:
      - type: value
        key: BackupCreationDateTime
        op: greater-than
        value_type: age
        value: 28
    actions:
      - type: delete
1

There are 1 best solutions below

0
On BEST ANSWER

I have found a workaround solution like below with adding a prefix to backup-name;

policies:
  - name: dynamodb-create-backup
    resource: dynamodb-table
    filters:
      - not:
        - "tag:Backup": absent
    actions:
      - type: backup
        prefix: custom

  - name: dynamodb-delete-backup
    resource: dynamodb-backup
    filters:
      - type: value
        key: BackupCreationDateTime
        op: greater-than
        value_type: age
        value: 30
      - type: value
        key: BackupName
        op: regex
        value: custom-.*