--- policy: /ce/ca/aws/backup/recovery-point-expired logic: /ce/ca/aws/backup/recovery-point-expired/prod.logic.yaml executionTime: 2026-06-06T12:02:31.731117451Z generationMs: 48 executionMs: 874 rows: - id: test1 match: true status: expected: DISAPPEARED actual: DISAPPEARED conditionIndex: expected: 99 actual: 99 conditionText: expected: isDisappeared(CA10A1__disappearanceTime__c) actual: isDisappeared(CA10A1__disappearanceTime__c) runtimeError: {} - id: test2 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10A1__status__c') != 'EXPIRED' actual: extract('CA10A1__status__c') != 'EXPIRED' runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10A1__calcLifecycleDeleteAt__c').isEmpty() actual: extract('CA10A1__calcLifecycleDeleteAt__c').isEmpty() runtimeError: {} - id: test4 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('CA10A1__calcLifecycleDeleteAt__c').beyondLastDays(2) actual: extract('CA10A1__calcLifecycleDeleteAt__c').beyondLastDays(2) runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test6 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/backup/recovery-point-expired/policy.yaml md5Hash: D6F49CDEFD2B0ADDF44F100002878061 content: "---\nnames:\n full: AWS Backup Recovery Point is expired and failed\ \ to delete\n contextual: Recovery Point is expired and failed to delete\n\ description: >\n Ensures that expired AWS Backup Recovery Points did not fail\ \ to delete. \n This is indicated by recovery points being past their calculated\ \ deletion \n date, or having no calculated deletion date. This can lead to\ \ unnecessary costs \n and data retention issues.\ncategories:\n - \"COST\"\ \ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/cost-efficiency-and-optimization/waste-reduction\"" - path: /ce/ca/aws/backup/recovery-point-expired/prod.logic.yaml md5Hash: 8F61157E430C36E3F19AA6F9A64D27A1 content: "---\ninputType: \"CA10A1__CaAwsBackupRecoveryPoint__c\"\nimportExtracts:\n\ \ - file: \"/types/CA10A1__CaAwsBackupRecoveryPoint__c/object.extracts.yaml\"\ \ntestData:\n - file: \"test-data.json\" \nconditions:\n - status: \"INAPPLICABLE\"\ \n currentStateMessage: \"The recovery point is not expired.\"\n check:\n\ \ NOT_EQUAL:\n left:\n EXTRACT: \"CA10A1__status__c\"\n\ \ right:\n TEXT: \"EXPIRED\"\n - status: \"INCOMPLIANT\"\n\ \ currentStateMessage: \"The recovery point is expired, but its lifecycle\ \ deletion date is not empty indicating failure to delete.\"\n remediationMessage:\ \ \"Delete the expired recovery point and investigate why the automated lifecycle\ \ rule failed.\"\n check:\n IS_EMPTY:\n arg:\n EXTRACT:\ \ \"CA10A1__calcLifecycleDeleteAt__c\" \n - status: \"INCOMPLIANT\"\n currentStateMessage:\ \ \"The recovery point was scheduled for deletion more than 2 days ago but still\ \ exists.\"\n remediationMessage: \"Delete the expired recovery point and\ \ investigate why the automated lifecycle rule failed.\"\n check:\n \ \ IS_BEYOND_LAST_DAYS:\n arg:\n EXTRACT: \"CA10A1__calcLifecycleDeleteAt__c\"\ \n offsetDays: 2\notherwise:\n status: \"COMPLIANT\"\n currentStateMessage:\ \ \"The backup recovery point has not yet reached its deletion date.\"\n" - path: /ce/ca/aws/backup/recovery-point-expired/test-data.json md5Hash: 644A269B908E4140BC6D2C50E1560D16 content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10A1__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2025-06-27T05:19:14Z" }, "Id": "test1", "CA10A1__disappearanceTime__c": "2025-06-26T22:45:21Z", "CA10A1__status__c": "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c": "2025-06-26T22:00:00Z" }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10A1__status__c') != 'EXPIRED'", "runtimeError": null }, "context": { "snapshotTime": "2025-06-27T05:19:14Z" }, "Id": "test2", "CA10A1__disappearanceTime__c": null, "CA10A1__status__c": "COMPLETED", "CA10A1__calcLifecycleDeleteAt__c": "2025-06-30T17:00:00Z" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10A1__calcLifecycleDeleteAt__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-06-27T05:19:14Z" }, "Id": "test3", "CA10A1__disappearanceTime__c": null, "CA10A1__status__c": "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c": null }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "399", "conditionText": "extract('CA10A1__calcLifecycleDeleteAt__c').beyondLastDays(2)", "runtimeError": null }, "context": { "snapshotTime": "2025-06-27T05:19:14Z" }, "Id": "test4", "CA10A1__disappearanceTime__c": null, "CA10A1__status__c": "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c": "2025-01-09T00:30:00Z" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "400", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-06-27T05:19:14Z" }, "Id": "test5", "CA10A1__disappearanceTime__c": null, "CA10A1__status__c": "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c": "2025-06-28T05:19:14Z" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "400", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-06-27T05:19:14Z" }, "Id": "test6", "CA10A1__disappearanceTime__c": null, "CA10A1__status__c": "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c": "2025-06-26T05:19:14Z" } ] - path: /types/CA10A1__CaAwsBackupRecoveryPoint__c/object.extracts.yaml md5Hash: 03645351ED418265EF3EFF8207F505A7 content: "---\nextracts:\n# Not Nullable. Can't have no access, retrieved via\ \ backup:ListRecoveryPointsByBackupVault\n - name: CA10A1__kmsMasterKeyId__c\n\ \ value: \n FIELD:\n path: CA10A1__kmsMasterKeyId__c\n# Values:\ \ COMPLETED | PARTIAL | DELETING | EXPIRED | AVAILABLE | STOPPED | CREATING\n\ # Not Nullable. Can't have no access, retrieved via backup:ListRecoveryPointsByBackupVault\n\ \ - name: CA10A1__status__c\n value: \n FIELD:\n path: CA10A1__status__c\n\ # Nullable. Can't have no access, retrieved via backup:ListRecoveryPointsByBackupVault\n\ \ - name: CA10A1__calcLifecycleDeleteAt__c\n value: \n FIELD:\n \ \ path: CA10A1__calcLifecycleDeleteAt__c\n# Not nullable.\n - name: \"\ CA10A1__creationDate__c\"\n value: \n FIELD:\n path: \"CA10A1__creationDate__c\"\ \n undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10A1__creationDate__c\"\n currentStateMessage: \"Backup Recovery\ \ Point creation date cannot be empty.\"" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10A1__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "extract('CA10A1__status__c') != 'EXPIRED'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10A1__calcLifecycleDeleteAt__c').isEmpty()", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "399", "conditionText" : "extract('CA10A1__calcLifecycleDeleteAt__c').beyondLastDays(2)", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "400", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test6", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "400", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10A1__CaAwsBackupRecoveryPoint__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-06-27T05:19:14Z") }, "CA10A1__disappearanceTime__c" : new Date("2025-06-26T22:45:21Z"), "CA10A1__status__c" : "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c" : new Date("2025-06-26T22:00:00Z"), "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-06-27T05:19:14Z") }, "CA10A1__status__c" : "COMPLETED", "CA10A1__calcLifecycleDeleteAt__c" : new Date("2025-06-30T17:00:00Z"), "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-06-27T05:19:14Z") }, "CA10A1__status__c" : "EXPIRED", "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2025-06-27T05:19:14Z") }, "CA10A1__status__c" : "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c" : new Date("2025-01-09T00:30:00Z"), "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2025-06-27T05:19:14Z") }, "CA10A1__status__c" : "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c" : new Date("2025-06-28T05:19:14Z"), "Id" : "test5" }, { "context" : { "snapshotTime" : new Date("2025-06-27T05:19:14Z") }, "CA10A1__status__c" : "EXPIRED", "CA10A1__calcLifecycleDeleteAt__c" : new Date("2025-06-26T05:19:14Z"), "Id" : "test6" } ]; """; CREATE TEMP FUNCTION process_CA10A1__CaAwsBackupRecoveryPoint__c( obj STRUCT< CA10A1__disappearanceTime__c TIMESTAMP, CA10A1__status__c STRING, CA10A1__calcLifecycleDeleteAt__c TIMESTAMP, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var IsEmptyLib = new function () { this.simpleIsEmpty = function(arg) { return arg == null; }; this.simpleIsNotEmpty = function(arg) { return arg != null; }; }(); var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var todayMinus2Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-2 * 86400000); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From AWS [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c); if (obj.CA10A1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] function extract3() { if (!this.out) { this.out = obj.CA10A1__status__c; } return this.out; }; references1.push('Status [obj.CA10A1__status__c]: ' + obj.CA10A1__status__c); if (TextLib.notEqual(extract3.call(extract3), 'EXPIRED')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10A1__status__c') != 'EXPIRED'", currentStateMessage: "The recovery point is not expired.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10A1__calcLifecycleDeleteAt__c; } return this.out; }; references1.push('Calc Lifecycle Delete At [obj.CA10A1__calcLifecycleDeleteAt__c]: ' + obj.CA10A1__calcLifecycleDeleteAt__c); if (IsEmptyLib.simpleIsEmpty(extract6.call(extract6))) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10A1__calcLifecycleDeleteAt__c').isEmpty()", currentStateMessage: "The recovery point is expired, but its lifecycle deletion date is not empty indicating failure to delete.", currentStateReferences: references1.join('\n'), remediation: "Delete the expired recovery point and investigate why the automated lifecycle rule failed.", runtimeError: null}; } // condition[3], conditionIndex:[300..399] function extract9() { if (!this.out) { this.out = obj.CA10A1__calcLifecycleDeleteAt__c; } return this.out; }; if (extract9.call(extract9) != null && extract9.call(extract9).getTime() < todayMinus2Day) { return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10A1__calcLifecycleDeleteAt__c').beyondLastDays(2)", currentStateMessage: "The recovery point was scheduled for deletion more than 2 days ago but still exists.", currentStateReferences: references1.join('\n'), remediation: "Delete the expired recovery point and investigate why the automated lifecycle rule failed.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "The backup recovery point has not yet reached its deletion date.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; SELECT expectedResult.Id as Id, IF ( IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '') AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1) AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '') AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''), "MATCH", "FAIL" ) as match, expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus, expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex, expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText, expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError FROM UNNEST(mock_ExpectedResult()) expectedResult LEFT JOIN ( SELECT sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__status__c AS CA10A1__status__c, sObject.CA10A1__calcLifecycleDeleteAt__c AS CA10A1__calcLifecycleDeleteAt__c, sObject.Id AS Id, process_CA10A1__CaAwsBackupRecoveryPoint__c( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__status__c AS CA10A1__status__c, sObject.CA10A1__calcLifecycleDeleteAt__c AS CA10A1__calcLifecycleDeleteAt__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10A1__CaAwsBackupRecoveryPoint__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;