function isMatchingSelection()

in src/rules/dynamodb/DynamoDBInBackupPlan.ts [52:74]


function isMatchingSelection(
  node: CfnBackupSelection,
  tableLogicalId: string,
  tableName: string | undefined
): boolean {
  const backupSelection = Stack.of(node).resolve(node.backupSelection);
  const resources = Stack.of(node).resolve(backupSelection.resources);
  if (Array.isArray(resources)) {
    for (const resource of resources) {
      const resolvedResource = JSON.stringify(Stack.of(node).resolve(resource));
      if (
        new RegExp(`${tableLogicalId}(?![\\w])`).test(resolvedResource) ||
        (tableName != undefined &&
          new RegExp(`table\/${tableName}(?![\\w\\-_\\.])`).test(
            resolvedResource
          ))
      ) {
        return true;
      }
    }
  }
  return false;
}