--- policy: /ce/ca/aws/cognito/user-pool-deletion-protection logic: /ce/ca/aws/cognito/user-pool-deletion-protection/prod.logic.yaml executionTime: 2026-04-25T12:02:19.254596115Z generationMs: 54 executionMs: 1771 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: COMPLIANT actual: COMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10A1__deletionProtection__c') == 'ACTIVE' actual: extract('CA10A1__deletionProtection__c') == 'ACTIVE' runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10A1__deletionProtection__c') == 'INACTIVE' actual: extract('CA10A1__deletionProtection__c') == 'INACTIVE' runtimeError: {} - id: test4 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/cognito/user-pool-deletion-protection/policy.yaml md5Hash: D1D3F4049AF435CA56947D42495E9199 content: | --- names: full: "AWS Cognito User Pool Deletion Protection is not enabled" contextual: "User Pool Deletion Protection is not enabled" description: > Ensure that Amazon Cognito user pools have deletion protection enabled. Deletion protection helps prevent accidental removal of a user pool and reduces the risk of authentication outages and recovery work caused by unintended deletion. type: "COMPLIANCE_POLICY" categories: - "RELIABILITY" frameworkMappings: - "/frameworks/cloudaware/resource-reliability/system-configuration" - "/frameworks/aws-fsbp-v1.0.0/cognito/06" similarPolicies: awsSecurityHub: - name: "[Cognito.6] Cognito user pools should have deletion protection enabled" url: "https://docs.aws.amazon.com/securityhub/latest/userguide/cognito-controls.html#cognito-6" - path: /ce/ca/aws/cognito/user-pool-deletion-protection/prod.logic.yaml md5Hash: DC26430E17D7BE672AC5C26B9CA66D7A content: | --- inputType: "CA10A1__CaAwsCognitoUserPool__c" importExtracts: - file: "/types/CA10A1__CaAwsCognitoUserPool__c/object.extracts.yaml" testData: - file: "test-data.json" conditions: - status: "COMPLIANT" currentStateMessage: "Deletion protection is enabled for the Cognito user pool." check: IS_EQUAL: left: EXTRACT: "CA10A1__deletionProtection__c" right: TEXT: "ACTIVE" - status: "INCOMPLIANT" currentStateMessage: "Deletion protection is not enabled for the Cognito user pool." remediationMessage: "Enable deletion protection to require an explicit configuration change before the Cognito user pool can be deleted." check: IS_EQUAL: left: EXTRACT: "CA10A1__deletionProtection__c" right: TEXT: "INACTIVE" otherwise: status: "UNDETERMINED" currentStateMessage: "Unexpected value in the Cognito user pool deletion protection setting." - path: /ce/ca/aws/cognito/user-pool-deletion-protection/test-data.json md5Hash: 7EF58B055B4804D1075AFF04917116BA content: | [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10A1__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2026-04-16T12:00:00Z" }, "CA10A1__disappearanceTime__c": "2026-04-15T12:00:00Z", "CA10A1__deletionProtection__c": "ACTIVE", "Id": "test1" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "199", "conditionText": "extract('CA10A1__deletionProtection__c') == 'ACTIVE'", "runtimeError": null }, "context": { "snapshotTime": "2026-04-16T12:00:00Z" }, "CA10A1__disappearanceTime__c": null, "CA10A1__deletionProtection__c": "ACTIVE", "Id": "test2" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10A1__deletionProtection__c') == 'INACTIVE'", "runtimeError": null }, "context": { "snapshotTime": "2026-04-16T12:00:00Z" }, "CA10A1__disappearanceTime__c": null, "CA10A1__deletionProtection__c": "INACTIVE", "Id": "test3" }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-16T12:00:00Z" }, "CA10A1__disappearanceTime__c": null, "CA10A1__deletionProtection__c": "UNKNOWN", "Id": "test4" } ] - path: /types/CA10A1__CaAwsCognitoUserPool__c/object.extracts.yaml md5Hash: 603EF3950C35BC470402E6CAE7F5DF68 content: | --- extracts: # Values: ACTIVE | INACTIVE. Not nullable. Retrieved via cognito-idp:DescribeUserPool - name: CA10A1__deletionProtection__c value: FIELD: path: CA10A1__deletionProtection__c undeterminedIf: isEmpty: "Deletion Protection should not be empty. Possibly corrupted data." # Values: OFF | ON | OPTIONAL. Not nullable. Retrieved via cognito-idp:DescribeUserPool - name: CA10A1__mfaConfiguration__c value: FIELD: path: CA10A1__mfaConfiguration__c undeterminedIf: isEmpty: "MFA Configuration should not be empty. Possibly corrupted data." # Number. Not nullable. Retrieved via cognito-idp:DescribeUserPool - name: CA10A1__passwordPolicyMinimumLength__c value: FIELD: path: CA10A1__passwordPolicyMinimumLength__c # Values: true | false. Not nullable. Retrieved via cognito-idp:DescribeUserPool - name: CA10A1__passwordPolicyIsRequireLowercase__c value: FIELD: path: CA10A1__passwordPolicyIsRequireLowercase__c undeterminedIf: isEmpty: "Password Policy Require Lowercase should not be empty. Possibly corrupted data." - name: CA10A1__passwordPolicyIsRequireUppercase__c value: FIELD: path: CA10A1__passwordPolicyIsRequireUppercase__c undeterminedIf: isEmpty: "Password Policy Require Uppercase should not be empty. Possibly corrupted data." - name: CA10A1__passwordPolicyIsRequireNumbers__c value: FIELD: path: CA10A1__passwordPolicyIsRequireNumbers__c undeterminedIf: isEmpty: "Password Policy Require Numbers should not be empty. Possibly corrupted data." - name: CA10A1__passwordPolicyIsRequireSymbols__c value: FIELD: path: CA10A1__passwordPolicyIsRequireSymbols__c undeterminedIf: isEmpty: "Password Policy Require Symbols should not be empty. Possibly corrupted data." # Number. Not nullable. Retrieved via cognito-idp:DescribeUserPool - name: CA10A1__passwordPolicyTemporaryValidityDays__c value: FIELD: path: CA10A1__passwordPolicyTemporaryValidityDays__c 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" : "COMPLIANT", "conditionIndex" : "199", "conditionText" : "extract('CA10A1__deletionProtection__c') == 'ACTIVE'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10A1__deletionProtection__c') == 'INACTIVE'", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10A1__CaAwsCognitoUserPool__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-16T12:00:00Z") }, "CA10A1__disappearanceTime__c" : new Date("2026-04-15T12:00:00Z"), "CA10A1__deletionProtection__c" : "ACTIVE", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2026-04-16T12:00:00Z") }, "CA10A1__deletionProtection__c" : "ACTIVE", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2026-04-16T12:00:00Z") }, "CA10A1__deletionProtection__c" : "INACTIVE", "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2026-04-16T12:00:00Z") }, "CA10A1__deletionProtection__c" : "UNKNOWN", "Id" : "test4" } ]; """; CREATE TEMP FUNCTION process_CA10A1__CaAwsCognitoUserPool__c( obj STRUCT< CA10A1__disappearanceTime__c TIMESTAMP, CA10A1__deletionProtection__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" 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 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 fieldChecked4() { if (TextLib.isEmpty(obj.CA10A1__deletionProtection__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10A1__deletionProtection__c.isEmpty()", currentStateMessage: "Deletion Protection should not be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10A1__deletionProtection__c; } function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Deletion Protection [obj.CA10A1__deletionProtection__c]: ' + obj.CA10A1__deletionProtection__c); try { if (TextLib.equal(extract3.call(extract3), 'ACTIVE')) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10A1__deletionProtection__c') == 'ACTIVE'", currentStateMessage: "Deletion protection is enabled for the Cognito user pool.", 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 (TextLib.isEmpty(obj.CA10A1__deletionProtection__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10A1__deletionProtection__c.isEmpty()", currentStateMessage: "Deletion Protection should not be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10A1__deletionProtection__c; } function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; }; try { if (TextLib.equal(extract6.call(extract6), 'INACTIVE')) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10A1__deletionProtection__c') == 'INACTIVE'", currentStateMessage: "Deletion protection is not enabled for the Cognito user pool.", currentStateReferences: references1.join('\n'), remediation: "Enable deletion protection to require an explicit configuration change before the Cognito user pool can be deleted.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'UNDETERMINED', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Unexpected value in the Cognito user pool deletion protection setting.", 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__deletionProtection__c AS CA10A1__deletionProtection__c, sObject.Id AS Id, process_CA10A1__CaAwsCognitoUserPool__c( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__deletionProtection__c AS CA10A1__deletionProtection__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10A1__CaAwsCognitoUserPool__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;