--- policy: /ce/ca/aws/redshift/cluster-underutilized logic: /ce/ca/aws/redshift/cluster-underutilized/prod.logic.yaml executionTime: 2026-06-06T12:03:21.455908671Z generationMs: 47 executionMs: 1107 rows: - id: '001' match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__status__c') != 'available' actual: extract('CA10__status__c') != 'available' runtimeError: {} - id: '002' match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: not(extract('CA10__createTime__c').beyondLastDays(30)) actual: not(extract('CA10__createTime__c').beyondLastDays(30)) runtimeError: {} - id: '003' match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('CA10__cpuUtilizationAvg30d__c').isEmpty() || extract('CA10__diskReadIopsAvg30d__c').isEmpty() || extract('CA10__diskWriteIopsAvg30d__c').isEmpty() actual: extract('CA10__cpuUtilizationAvg30d__c').isEmpty() || extract('CA10__diskReadIopsAvg30d__c').isEmpty() || extract('CA10__diskWriteIopsAvg30d__c').isEmpty() runtimeError: {} - id: '004' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: extract('CA10__cpuUtilizationAvg30d__c') < number(20.0) && extract('CA10__diskReadIopsAvg30d__c') < number(50.0) && extract('CA10__diskWriteIopsAvg30d__c') < number(50.0) actual: extract('CA10__cpuUtilizationAvg30d__c') < number(20.0) && extract('CA10__diskReadIopsAvg30d__c') < number(50.0) && extract('CA10__diskWriteIopsAvg30d__c') < number(50.0) runtimeError: {} - id: '005' match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 500 actual: 500 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/redshift/cluster-underutilized/policy.yaml md5Hash: 89DB0905DC1FCCAB9792567A50D22425 content: "---\nnames:\n full: AWS Redshift Cluster is underutilized\n contextual:\ \ Cluster is underutilized\ndescription: \"Clusters are considered underutilized\ \ if their average\\\n \\ CPU utilization is consistently below 20% and their\ \ disk I/O is below 50 IOPS\\\n \\ over a 30-day period. Such instances might\ \ be oversized for their workload.\"\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n\ \ - \"COST\"\n - \"PERFORMANCE\"\nframeworkMappings:\n - \"/frameworks/cloudaware/cost-efficiency-and-optimization/resource-right-sizing\"\ \n - \"/frameworks/cloudaware/resource-performance/workload-efficiency\"\n\ \ " - path: /ce/ca/aws/redshift/cluster-underutilized/prod.logic.yaml md5Hash: C0D9F5F00D5F6DA095D567B9D5228D1D content: | --- inputType: "CA10__CaAwsRedshiftCluster__c" importExtracts: - file: "/types/CA10__CaAwsRedshiftCluster__c/object.extracts.yaml" testData: - file: 'test-data.json' conditions: - status: "INAPPLICABLE" currentStateMessage: "The cluster is not available." check: NOT_EQUAL: left: EXTRACT: "CA10__status__c" right: TEXT: "available" - status: "INAPPLICABLE" currentStateMessage: "The cluster has been created less than 30 days ago." check: NOT: arg: IS_BEYOND_LAST_DAYS: offsetDays: 30 arg: EXTRACT: "CA10__createTime__c" - status: UNDETERMINED currentStateMessage: "There is not enough data in the CMDB to determine whether the cluster is underutilized." check: OR: args: - IS_EMPTY: arg: EXTRACT: "CA10__cpuUtilizationAvg30d__c" - IS_EMPTY: arg: EXTRACT: "CA10__diskReadIopsAvg30d__c" - IS_EMPTY: arg: EXTRACT: "CA10__diskWriteIopsAvg30d__c" - status: "INCOMPLIANT" currentStateMessage: "The cluster is underutilized with average CPU utilization below 20% and average disk I/O below 50 IOPS." remediationMessage: "Rightsize the cluster." check: AND: args: - LESS_THAN: left: EXTRACT: "CA10__cpuUtilizationAvg30d__c" right: NUMBER: 20.0 - LESS_THAN: left: EXTRACT: "CA10__diskReadIopsAvg30d__c" right: NUMBER: 50.0 - LESS_THAN: left: EXTRACT: "CA10__diskWriteIopsAvg30d__c" right: NUMBER: 50.0 otherwise: status: "COMPLIANT" currentStateMessage: "The cluster is not underutilized." - path: /ce/ca/aws/redshift/cluster-underutilized/test-data.json md5Hash: 595C8EFCDD78D5E2A9AC74CFFECCA83F content: | [ { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10__status__c') != 'available'", "runtimeError": null }, "context": { "snapshotTime": "2025-09-01T16:12:36Z" }, "Id": "001", "CA10__disappearanceTime__c": null, "CA10__status__c": "paused", "CA10__createTime__c": "2020-10-22T09:44:18Z", "CA10__cpuUtilizationAvg30d__c": null, "CA10__diskReadIopsAvg30d__c": null, "CA10__diskWriteIopsAvg30d__c": null }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "299", "conditionText": "not(extract('CA10__createTime__c').beyondLastDays(30))", "runtimeError": null }, "context": { "snapshotTime": "2025-09-01T16:12:36Z" }, "Id": "002", "CA10__disappearanceTime__c": null, "CA10__status__c": "available", "CA10__createTime__c": "2025-08-31T16:12:36Z", "CA10__cpuUtilizationAvg30d__c": null, "CA10__diskReadIopsAvg30d__c": null, "CA10__diskWriteIopsAvg30d__c": null }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "399", "conditionText": "extract('CA10__cpuUtilizationAvg30d__c').isEmpty() || extract('CA10__diskReadIopsAvg30d__c').isEmpty() || extract('CA10__diskWriteIopsAvg30d__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-09-01T16:12:36Z" }, "Id": "003", "CA10__disappearanceTime__c": null, "CA10__status__c": "available", "CA10__createTime__c": "2020-10-22T09:44:18Z", "CA10__cpuUtilizationAvg30d__c": null, "CA10__diskReadIopsAvg30d__c": null, "CA10__diskWriteIopsAvg30d__c": null }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "499", "conditionText": "extract('CA10__cpuUtilizationAvg30d__c') < number(20.0) && extract('CA10__diskReadIopsAvg30d__c') < number(50.0) && extract('CA10__diskWriteIopsAvg30d__c') < number(50.0)", "runtimeError": null }, "context": { "snapshotTime": "2025-09-01T16:12:36Z" }, "Id": "004", "CA10__disappearanceTime__c": null, "CA10__status__c": "available", "CA10__createTime__c": "2020-10-22T09:44:18Z", "CA10__cpuUtilizationAvg30d__c": 10, "CA10__diskReadIopsAvg30d__c": 10, "CA10__diskWriteIopsAvg30d__c": 10 }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "500", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-09-01T16:12:36Z" }, "Id": "005", "CA10__disappearanceTime__c": null, "CA10__status__c": "available", "CA10__createTime__c": "2020-10-22T09:44:18Z", "CA10__cpuUtilizationAvg30d__c": 50, "CA10__diskReadIopsAvg30d__c": 10, "CA10__diskWriteIopsAvg30d__c": 10 } ] - path: /types/CA10__CaAwsRedshiftCluster__c/object.extracts.yaml md5Hash: 978033E93A3BC4EEE31B6916039330FF content: | --- extracts: # Nullable. Values: available, modifying, creating ... - name: "CA10__status__c" value: FIELD: path: "CA10__status__c" # Nullable. - name: "CA10__createTime__c" value: FIELD: path: "CA10__createTime__c" # Nullable. - name: "CA10__cpuUtilizationAvg30d__c" value: FIELD: path: "CA10__cpuUtilizationAvg30d__c" # Nullable. - name: "CA10__diskReadIopsAvg30d__c" value: FIELD: path: "CA10__diskReadIopsAvg30d__c" # Nullable. - name: "CA10__diskWriteIopsAvg30d__c" value: FIELD: path: "CA10__diskWriteIopsAvg30d__c" # Nullable. - name: "CA10__logging__c" value: FIELD: path: "CA10__logging__c" # Nullable. - name: "CA10__automatedSnapshotRetentionPeriod__c" value: FIELD: path: "CA10__automatedSnapshotRetentionPeriod__c" # Text. - name: "CA10__encryption__c" value: FIELD: path: "CA10__encryption__c" # Text. - name: "CA10__masterUsername__c" value: FIELD: path: "CA10__masterUsername__c" # Text. - name: "CA10__versionUpgrade__c" value: FIELD: path: "CA10__versionUpgrade__c" # Values: Yes | No. Not nullable. Can't have no access, retrieved via redshift:DescribeClusters - name: "CA10__publiclyAccessible__c" value: FIELD: path: "CA10__publiclyAccessible__c" # Values: Enabled | Disabled. Not nullable. Can't have no access, retrieved via redshift:DescribeClusters - name: "CA10__enhancedVpcRouting2__c" value: FIELD: path: "CA10__enhancedVpcRouting2__c" # Number - name: "CA10__endpointPort2__c" value: FIELD: path: "CA10__endpointPort2__c" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "001", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "extract('CA10__status__c') != 'available'", "runtimeError" : null } }, { "Id" : "002", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "299", "conditionText" : "not(extract('CA10__createTime__c').beyondLastDays(30))", "runtimeError" : null } }, { "Id" : "003", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "399", "conditionText" : "extract('CA10__cpuUtilizationAvg30d__c').isEmpty() || extract('CA10__diskReadIopsAvg30d__c').isEmpty() || extract('CA10__diskWriteIopsAvg30d__c').isEmpty()", "runtimeError" : null } }, { "Id" : "004", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "499", "conditionText" : "extract('CA10__cpuUtilizationAvg30d__c') < number(20.0) && extract('CA10__diskReadIopsAvg30d__c') < number(50.0) && extract('CA10__diskWriteIopsAvg30d__c') < number(50.0)", "runtimeError" : null } }, { "Id" : "005", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "500", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsRedshiftCluster__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-09-01T16:12:36Z") }, "CA10__status__c" : "paused", "CA10__createTime__c" : new Date("2020-10-22T09:44:18Z"), "CA10__cpuUtilizationAvg30d__c" : null, "CA10__diskReadIopsAvg30d__c" : null, "CA10__diskWriteIopsAvg30d__c" : null, "Id" : "001" }, { "context" : { "snapshotTime" : new Date("2025-09-01T16:12:36Z") }, "CA10__status__c" : "available", "CA10__createTime__c" : new Date("2025-08-31T16:12:36Z"), "CA10__cpuUtilizationAvg30d__c" : null, "CA10__diskReadIopsAvg30d__c" : null, "CA10__diskWriteIopsAvg30d__c" : null, "Id" : "002" }, { "context" : { "snapshotTime" : new Date("2025-09-01T16:12:36Z") }, "CA10__status__c" : "available", "CA10__createTime__c" : new Date("2020-10-22T09:44:18Z"), "CA10__cpuUtilizationAvg30d__c" : null, "CA10__diskReadIopsAvg30d__c" : null, "CA10__diskWriteIopsAvg30d__c" : null, "Id" : "003" }, { "context" : { "snapshotTime" : new Date("2025-09-01T16:12:36Z") }, "CA10__status__c" : "available", "CA10__createTime__c" : new Date("2020-10-22T09:44:18Z"), "CA10__cpuUtilizationAvg30d__c" : 10, "CA10__diskReadIopsAvg30d__c" : 10, "CA10__diskWriteIopsAvg30d__c" : 10, "Id" : "004" }, { "context" : { "snapshotTime" : new Date("2025-09-01T16:12:36Z") }, "CA10__status__c" : "available", "CA10__createTime__c" : new Date("2020-10-22T09:44:18Z"), "CA10__cpuUtilizationAvg30d__c" : 50, "CA10__diskReadIopsAvg30d__c" : 10, "CA10__diskWriteIopsAvg30d__c" : 10, "Id" : "005" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsRedshiftCluster__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__status__c STRING, CA10__createTime__c TIMESTAMP, CA10__cpuUtilizationAvg30d__c FLOAT64, CA10__diskReadIopsAvg30d__c FLOAT64, CA10__diskWriteIopsAvg30d__c FLOAT64, 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 todayMinus30Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-30 * 86400000); 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 extract3() { if (!this.out) { this.out = obj.CA10__status__c; } return this.out; }; references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c); if (TextLib.notEqual(extract3.call(extract3), 'available')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__status__c') != 'available'", currentStateMessage: "The cluster is not available.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10__createTime__c; } return this.out; }; references1.push('Create Time [obj.CA10__createTime__c]: ' + obj.CA10__createTime__c); if (!(extract6.call(extract6) != null && extract6.call(extract6).getTime() < todayMinus30Day)) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "not(extract('CA10__createTime__c').beyondLastDays(30))", currentStateMessage: "The cluster has been created less than 30 days ago.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[3], conditionIndex:[300..399] function extract10() { if (!this.out) { this.out = obj.CA10__cpuUtilizationAvg30d__c; } return this.out; }; function extract13() { if (!this.out) { this.out = obj.CA10__diskReadIopsAvg30d__c; } return this.out; }; function extract16() { if (!this.out) { this.out = obj.CA10__diskWriteIopsAvg30d__c; } return this.out; }; references1.push('CloudWatch: CPU, 30-Day [obj.CA10__cpuUtilizationAvg30d__c]: ' + obj.CA10__cpuUtilizationAvg30d__c); references1.push('CloudWatch: Disk Read IOPS, 30-Day [obj.CA10__diskReadIopsAvg30d__c]: ' + obj.CA10__diskReadIopsAvg30d__c); references1.push('CloudWatch: Disk Write IOPS, 30-Day [obj.CA10__diskWriteIopsAvg30d__c]: ' + obj.CA10__diskWriteIopsAvg30d__c); if (IsEmptyLib.simpleIsEmpty(extract10.call(extract10)) || IsEmptyLib.simpleIsEmpty(extract13.call(extract13)) || IsEmptyLib.simpleIsEmpty(extract16.call(extract16))) { return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "extract('CA10__cpuUtilizationAvg30d__c').isEmpty() || extract('CA10__diskReadIopsAvg30d__c').isEmpty() || extract('CA10__diskWriteIopsAvg30d__c').isEmpty()", currentStateMessage: "There is not enough data in the CMDB to determine whether the cluster is underutilized.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[4], conditionIndex:[400..499] function extract20() { if (!this.out) { this.out = obj.CA10__cpuUtilizationAvg30d__c; } return this.out; }; function extract24() { if (!this.out) { this.out = obj.CA10__diskReadIopsAvg30d__c; } return this.out; }; function extract28() { if (!this.out) { this.out = obj.CA10__diskWriteIopsAvg30d__c; } return this.out; }; if ((extract20.call(extract20) != null && 20.0 != null && extract20.call(extract20) < 20.0) && (extract24.call(extract24) != null && 50.0 != null && extract24.call(extract24) < 50.0) && (extract28.call(extract28) != null && 50.0 != null && extract28.call(extract28) < 50.0)) { return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__cpuUtilizationAvg30d__c') < number(20.0) && extract('CA10__diskReadIopsAvg30d__c') < number(50.0) && extract('CA10__diskWriteIopsAvg30d__c') < number(50.0)", currentStateMessage: "The cluster is underutilized with average CPU utilization below 20% and average disk I/O below 50 IOPS.", currentStateReferences: references1.join('\n'), remediation: "Rightsize the cluster.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "The cluster is not underutilized.", 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__status__c AS CA10__status__c, sObject.CA10__createTime__c AS CA10__createTime__c, sObject.CA10__cpuUtilizationAvg30d__c AS CA10__cpuUtilizationAvg30d__c, sObject.CA10__diskReadIopsAvg30d__c AS CA10__diskReadIopsAvg30d__c, sObject.CA10__diskWriteIopsAvg30d__c AS CA10__diskWriteIopsAvg30d__c, sObject.Id AS Id, process_CA10__CaAwsRedshiftCluster__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__status__c AS CA10__status__c, sObject.CA10__createTime__c AS CA10__createTime__c, sObject.CA10__cpuUtilizationAvg30d__c AS CA10__cpuUtilizationAvg30d__c, sObject.CA10__diskReadIopsAvg30d__c AS CA10__diskReadIopsAvg30d__c, sObject.CA10__diskWriteIopsAvg30d__c AS CA10__diskWriteIopsAvg30d__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsRedshiftCluster__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;