--- policy: /ce/ca/aws/elasticache/redis-cluster-automatic-backup logic: /ce/ca/aws/elasticache/redis-cluster-automatic-backup/prod.logic.yaml executionTime: 2026-02-10T22:32:52.411656736Z generationMs: 99 executionMs: 909 rows: - id: test1 match: true status: expected: DISAPPEARED actual: DISAPPEARED conditionIndex: expected: 99 actual: 99 conditionText: expected: isDisappeared(CA10__disappearanceTime__c) actual: isDisappeared(CA10__disappearanceTime__c) runtimeError: {} - id: test2 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__snapshotRetentionLimit__c') == number(0.0) actual: extract('CA10__snapshotRetentionLimit__c') == number(0.0) runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test4 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: "not(setOfText(['redis', 'valkey']).contains(extract('CA10__engine__c')))" actual: "not(setOfText(['redis', 'valkey']).contains(extract('CA10__engine__c')))" runtimeError: {} usedFiles: - path: /ce/ca/aws/elasticache/redis-cluster-automatic-backup/policy.yaml md5Hash: 882949CA336AEC154FC84879A993A639 content: "---\nnames:\n full: \"AWS ElastiCache Redis Cluster automatic backups\ \ are not enabled\"\n contextual: \"Redis Cluster automatic backups are not\ \ enabled\"\ndescription: >\n Ensure that AWS ElastiCache clusters for Valkey\ \ and Redis OSS have automatic \n backups enabled to facilitate point-in-time\ \ recovery and protect against data loss.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n\ \ - \"SECURITY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/resource-security/data-protection-and-recovery\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/elasticache/01\"\n - \"/frameworks/aws-well-architected/rel/09/03\"\ \nsimilarPolicies:\n awsSecurityHub:\n - name: \"[ElastiCache.1] ElastiCache\ \ (Valkey and Redis OSS) clusters should have automatic backups enabled\"\n\ \ url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/elasticache-controls.html#elasticache-1\"" - path: /ce/ca/aws/elasticache/redis-cluster-automatic-backup/prod.logic.yaml md5Hash: 75F203952611A440B88DA773121A9C28 content: | --- inputType: "CA10__CaAwsCacheCluster__c" testData: - file: "test-data.json" importExtracts: - file: /types/CA10__CaAwsCacheCluster__c/object.extracts.yaml conditions: - status: "INAPPLICABLE" currentStateMessage: "This policy is only applicable to Redis clusters." check: NOT: arg: CONTAINS: arg: SET: itemType: TEXT items: - "redis" - "valkey" search: EXTRACT: "CA10__engine__c" - status: "INCOMPLIANT" currentStateMessage: "Automatic backups are disabled for this Redis cluster." remediationMessage: "Set a snapshot retention period greater than 0 to enable automatic backups." check: IS_EQUAL: left: EXTRACT: "CA10__snapshotRetentionLimit__c" right: NUMBER: 0.0 otherwise: status: "COMPLIANT" currentStateMessage: "Automatic backups are enabled for this Redis cluster." - path: /ce/ca/aws/elasticache/redis-cluster-automatic-backup/test-data.json md5Hash: 8F3353F609D5E8990A1FD8932A2A191F content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2025-10-21T01:48:33Z" }, "CA10__disappearanceTime__c": "2025-10-15T19:54:29Z", "CA10__engine__c": "redis", "CA10__snapshotRetentionLimit__c": 0, "Id": "test1" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10__snapshotRetentionLimit__c') == number(0.0)", "runtimeError": null }, "context": { "snapshotTime": "2025-10-21T01:48:33Z" }, "CA10__disappearanceTime__c": null, "CA10__engine__c": "redis", "CA10__snapshotRetentionLimit__c": 0, "Id": "test2" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-10-21T01:48:33Z" }, "CA10__disappearanceTime__c": null, "CA10__engine__c": "valkey", "CA10__snapshotRetentionLimit__c": 7, "Id": "test3" }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "not(setOfText(['redis', 'valkey']).contains(extract('CA10__engine__c')))", "runtimeError": null }, "context": { "snapshotTime": "2025-10-08T06:14:51Z" }, "CA10__disappearanceTime__c": null, "CA10__engine__c": "memcached", "CA10__snapshotRetentionLimit__c": 7, "Id": "test4" } ] - path: /types/CA10__CaAwsCacheCluster__c/object.extracts.yaml md5Hash: 149E948C3FC56157AFB5E33CEAD7558E content: "---\nextracts:\n# Values: available, creating, deleted, deleting, incompatible-network,\ \ modifying, \n# rebooting cluster nodes, restore-failed, snapshotting\n# Not\ \ nullable. Can't have no access, retrieved via elasticache:DescribeCacheClusters\n\ \ - name: \"CA10__status__c\"\n value:\n FIELD:\n path: \"CA10__status__c\"\ \n undeterminedIf:\n isEmpty: \"Corrupted data. Status cannot\ \ be empty.\" \n# Values: memcached | redis. Not nullable. Can't have no access,\ \ retrieved via elasticache:DescribeCacheClusters\n - name: \"CA10__engine__c\"\ \n value:\n FIELD:\n path: \"CA10__engine__c\"\n undeterminedIf:\n\ \ isEmpty: \"Corrupted data. Engine cannot be empty.\"\n# Date/Time\n\ \ - name: \"CA10__createTime__c\"\n value:\n FIELD:\n path:\ \ \"CA10__createTime__c\"\n# Percent\n - name: \"CA10__cpuUtilizationAvg30d__c\"\ \n value:\n FIELD:\n path: \"CA10__cpuUtilizationAvg30d__c\"\n\ # Checkbox. Can't have no access, retrieved via elasticache:DescribeCacheClusters\n\ \ - name: \"CA10__autoMinorVersionUpgrade__c\"\n value:\n FIELD:\n\ \ path: \"CA10__autoMinorVersionUpgrade__c\"\n# Not nullable. Can't have\ \ no access, retrieved via elasticache:DescribeCacheClusters\n - name: \"CA10__snapshotRetentionLimit__c\"\ \n value:\n FIELD:\n path: \"CA10__snapshotRetentionLimit__c\"\ \n undeterminedIf:\n isEmpty: \"Corrupted data. Snapshot Retention\ \ Limit cannot be empty.\"\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10__snapshotRetentionLimit__c') == number(0.0)", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "not(setOfText(['redis', 'valkey']).contains(extract('CA10__engine__c')))", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsCacheCluster__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-10-21T01:48:33Z") }, "CA10__disappearanceTime__c" : new Date("2025-10-15T19:54:29Z"), "CA10__engine__c" : "redis", "CA10__snapshotRetentionLimit__c" : 0, "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-10-21T01:48:33Z") }, "CA10__engine__c" : "redis", "CA10__snapshotRetentionLimit__c" : 0, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-10-21T01:48:33Z") }, "CA10__engine__c" : "valkey", "CA10__snapshotRetentionLimit__c" : 7, "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2025-10-08T06:14:51Z") }, "CA10__engine__c" : "memcached", "CA10__snapshotRetentionLimit__c" : 7, "Id" : "test4" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsCacheCluster__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__engine__c STRING, CA10__snapshotRetentionLimit__c FLOAT64, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var BytesLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg; }; 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 CollectionLib = new function () { this.parse = function(arg, separator, skipEmpty, skipDuplicates, sort, normalize) { if (arg == null) return []; let parts = arg.split(separator); return this.fromArray(parts, skipEmpty, skipDuplicates, sort, normalize); }; this.fromArray = function(arr, skipEmpty, skipDuplicates, sort, normalize) { if (arr == null) return []; let result = []; let seen = new Set(); arr.forEach(el => { let normalized = normalize ? TextLib.normalize(el) : BytesLib.normalize(el); if (!skipEmpty || (normalize ? TextLib.isNotEmpty(el) : BytesLib.isNotEmpty(el))) { if (!skipDuplicates || !seen.has(normalized)) { if (skipDuplicates) seen.add(normalized); result.push(normalized); } } }); if (sort) result.sort(); return result; }; this.equal = function(left, right) { left = left == null ? [] : left; right = right == null ? [] : right; if (left.length !== right.length) return false; for (let i = 0; i < left.length; i++) { if (left[i] !== right[i]) return false; } return true; }; this.notEqual = function(left, right) { return !this.equal(left, right); }; this.size = function(collection) { return collection == null ? 0 : collection.length; }; this.startsWith = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search); return collection[0] === normalizedSearch; }; this.endsWith = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search); return collection[collection.length - 1] === normalizedSearch; }; this.contains = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; return collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search)); }; this.containsAll = function(collection, searchArray, normalize) { if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false; return searchArray.every(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search))); }; this.containsAny = function(collection, searchArray, normalize) { if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false; return searchArray.some(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search))); }; }(); 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 IsEmptyLib = new function () { this.simpleIsEmpty = function(arg) { return arg == null; }; this.simpleIsNotEmpty = function(arg) { return arg != null; }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c); if (obj.CA10__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] function fieldChecked4() { if (TextLib.isEmpty(obj.CA10__engine__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__engine__c.isEmpty()", currentStateMessage: "Corrupted data. Engine cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__engine__c; } function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Engine [obj.CA10__engine__c]: ' + obj.CA10__engine__c); try { if (!CollectionLib.contains(CollectionLib.fromArray(['redis', 'valkey'], true, true, true, true), extract3.call(extract3), true)) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['redis', 'valkey']).contains(extract('CA10__engine__c')))", currentStateMessage: "This policy is only applicable to Redis clusters.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[2], conditionIndex:[200..299] function fieldChecked7() { if (IsEmptyLib.simpleIsEmpty(obj.CA10__snapshotRetentionLimit__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__snapshotRetentionLimit__c.isEmpty()", currentStateMessage: "Corrupted data. Snapshot Retention Limit cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__snapshotRetentionLimit__c; } function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; }; references1.push('Snapshot Retention Limit [obj.CA10__snapshotRetentionLimit__c]: ' + obj.CA10__snapshotRetentionLimit__c); try { if (extract6.call(extract6) == 0.0) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__snapshotRetentionLimit__c') == number(0.0)", currentStateMessage: "Automatic backups are disabled for this Redis cluster.", currentStateReferences: references1.join('\n'), remediation: "Set a snapshot retention period greater than 0 to enable automatic backups.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Automatic backups are enabled for this Redis cluster.", 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__engine__c AS CA10__engine__c, sObject.CA10__snapshotRetentionLimit__c AS CA10__snapshotRetentionLimit__c, sObject.Id AS Id, process_CA10__CaAwsCacheCluster__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__engine__c AS CA10__engine__c, sObject.CA10__snapshotRetentionLimit__c AS CA10__snapshotRetentionLimit__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsCacheCluster__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;