--- policy: /ce/ca/aws/athena/workgroup-cloudwatch-metrics logic: /ce/ca/aws/athena/workgroup-cloudwatch-metrics/prod.logic.yaml executionTime: 2026-06-06T12:02:30.19859845Z generationMs: 53 executionMs: 1170 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: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Disabled' actual: extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Disabled' runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Enabled' actual: extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Enabled' runtimeError: {} usedFiles: - path: /ce/ca/aws/athena/workgroup-cloudwatch-metrics/policy.yaml md5Hash: 24D3DAE755FFB60DE85E15D20486C267 content: | --- names: full: AWS Athena Workgroup CloudWatch Metrics are not enabled contextual: Workgroup CloudWatch Metrics are not enabled description: > Ensure that AWS Athena Workgroup has CloudWatch Metrics enabled. categories: - "RELIABILITY" type: "COMPLIANCE_POLICY" frameworkMappings: - "/frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration" - "/frameworks/aws-fsbp-v1.0.0/athena/04" - path: /ce/ca/aws/athena/workgroup-cloudwatch-metrics/prod.logic.yaml md5Hash: 617C80FDC435DB3FD72EC03A0A715347 content: | --- inputType: "CA10A1__CaAwsAthenaWorkGroup__c" importExtracts: - file: "/types/CA10A1__CaAwsAthenaWorkGroup__c/object.extracts.yaml" testData: - file: "test-data.json" conditions: - status: "INCOMPLIANT" currentStateMessage: "CloudWatch metrics are not enabled for the Athena workgroup." remediationMessage: "Enable CloudWatch metrics for the Athena workgroup." check: IS_EQUAL: left: EXTRACT: "CA10A1__configPublishCloudWatchMetrics__c" right: TEXT: "Disabled" - status: "COMPLIANT" currentStateMessage: "CloudWatch metrics are enabled for the Athena workgroup." check: IS_EQUAL: left: EXTRACT: "CA10A1__configPublishCloudWatchMetrics__c" right: TEXT: "Enabled" otherwise: status: "UNDETERMINED" currentStateMessage: "Unable to determine the CloudWatch metrics status for the Athena workgroup." - path: /ce/ca/aws/athena/workgroup-cloudwatch-metrics/test-data.json md5Hash: 4981CF99050916A6DD4C0EC955E8787E content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10A1__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2025-04-15T04:50:48Z" }, "Id": "test1", "CA10A1__disappearanceTime__c": "2025-04-15T04:50:48Z", "CA10A1__configPublishCloudWatchMetrics__c": "Enabled" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Disabled'", "runtimeError": null }, "context": { "snapshotTime": "2025-04-15T04:50:48Z" }, "Id": "test2", "CA10A1__disappearanceTime__c": null, "CA10A1__configPublishCloudWatchMetrics__c": "Disabled" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Enabled'", "runtimeError": null }, "context": { "snapshotTime": "2025-04-15T04:50:48Z" }, "Id": "test3", "CA10A1__disappearanceTime__c": null, "CA10A1__configPublishCloudWatchMetrics__c": "Enabled" } ] - path: /types/CA10A1__CaAwsAthenaWorkGroup__c/object.extracts.yaml md5Hash: A10204D88A52AEF2DE3D9AE308BF92C7 content: "---\nextracts:\n#Values: Enabled | Disabled. Not Nullable.\n - name:\ \ CA10A1__configPublishCloudWatchMetrics__c\n value: \n FIELD:\n \ \ path: CA10A1__configPublishCloudWatchMetrics__c\n undeterminedIf:\n\ \ noAccessDelegate:\n path: CA10A1__configPublishCloudWatchMetrics__c\n\ \ currentStateMessage: \"Publish CloudWatch Metrics cannot be empty.\ \ Possible permission issues with athena:GetWorkGroup.\"" 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" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Disabled'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Enabled'", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10A1__CaAwsAthenaWorkGroup__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-04-15T04:50:48Z") }, "CA10A1__disappearanceTime__c" : new Date("2025-04-15T04:50:48Z"), "CA10A1__configPublishCloudWatchMetrics__c" : "Enabled", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-04-15T04:50:48Z") }, "CA10A1__configPublishCloudWatchMetrics__c" : "Disabled", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-04-15T04:50:48Z") }, "CA10A1__configPublishCloudWatchMetrics__c" : "Enabled", "Id" : "test3" } ]; """; CREATE TEMP FUNCTION process_CA10A1__CaAwsAthenaWorkGroup__c( obj STRUCT< CA10A1__disappearanceTime__c TIMESTAMP, CA10A1__configPublishCloudWatchMetrics__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__configPublishCloudWatchMetrics__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10A1__configPublishCloudWatchMetrics__c.delegatedTo(CA10A1__configPublishCloudWatchMetrics__c).isEmpty()", currentStateMessage: "Publish CloudWatch Metrics cannot be empty. Possible permission issues with athena:GetWorkGroup.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10A1__configPublishCloudWatchMetrics__c; } function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Config: Publish Cloud Watch Metrics [obj.CA10A1__configPublishCloudWatchMetrics__c]: ' + obj.CA10A1__configPublishCloudWatchMetrics__c); try { if (TextLib.equal(extract3.call(extract3), 'Disabled')) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Disabled'", currentStateMessage: "CloudWatch metrics are not enabled for the Athena workgroup.", currentStateReferences: references1.join('\n'), remediation: "Enable CloudWatch metrics for the Athena workgroup.", 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__configPublishCloudWatchMetrics__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10A1__configPublishCloudWatchMetrics__c.delegatedTo(CA10A1__configPublishCloudWatchMetrics__c).isEmpty()", currentStateMessage: "Publish CloudWatch Metrics cannot be empty. Possible permission issues with athena:GetWorkGroup.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10A1__configPublishCloudWatchMetrics__c; } function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; }; try { if (TextLib.equal(extract6.call(extract6), 'Enabled')) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10A1__configPublishCloudWatchMetrics__c') == 'Enabled'", currentStateMessage: "CloudWatch metrics are enabled for the Athena workgroup.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'UNDETERMINED', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Unable to determine the CloudWatch metrics status for the Athena workgroup.", 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__configPublishCloudWatchMetrics__c AS CA10A1__configPublishCloudWatchMetrics__c, sObject.Id AS Id, process_CA10A1__CaAwsAthenaWorkGroup__c( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__configPublishCloudWatchMetrics__c AS CA10A1__configPublishCloudWatchMetrics__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10A1__CaAwsAthenaWorkGroup__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;