--- policy: /ce/ca/aws/apigateway/rest-api-detailed-cloudwatch-metrics logic: /ce/ca/aws/apigateway/rest-api-detailed-cloudwatch-metrics/prod.logic.yaml executionTime: 2026-02-10T22:32:31.577832886Z generationMs: 100 executionMs: 991 rows: - id: '001' match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: "not(setOfText(['restApi']).contains(RecordType.DeveloperName))" actual: "not(setOfText(['restApi']).contains(RecordType.DeveloperName))" runtimeError: {} - id: '002' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__AWS_API_Gateway_Stages__r.count(COMPLIANT) == number(0.0) actual: CA10__AWS_API_Gateway_Stages__r.count(COMPLIANT) == number(0.0) runtimeError: {} - id: '003' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT) actual: CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT) runtimeError: {} - id: '004' match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/apigateway/rest-api-detailed-cloudwatch-metrics/policy.yaml md5Hash: 91CD4D218AA2945DC5AA2903AEA04011 content: "---\nnames:\n full: AWS API Gateway REST API Detailed CloudWatch Metrics\ \ are not enabled\n contextual: REST API Detailed CloudWatch Metrics are not\ \ enabled\ndescription: >\n Ensure that detailed CloudWatch metrics are enabled\ \ for all APIs created with \n AWS API Gateway service in order to monitor\ \ API stages caching, latency and \n detected errors at a more granular level\ \ and set alarms accordingly.\ncategories:\n - \"RELIABILITY\"\ntype: \"COMPLIANCE_POLICY\"\ \nframeworkMappings:\n - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\ \n - \"/frameworks/aws-well-architected/rel/06/02\"\nsimilarPolicies:\n cloudConformity:\n\ \ - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/APIGateway/detailed-cloudwatch-metrics.html\n\ \ name: APIs Detailed CloudWatch Metrics" - path: /ce/ca/aws/apigateway/rest-api-detailed-cloudwatch-metrics/prod.logic.yaml md5Hash: FFD5E744348825736B54EA1DD5622CBB content: | --- inputType: "CA10__CaAwsApiGatewayRestApi__c" testData: - file: test-data.json recordTypes: - restApi conditions: - status: "INCOMPLIANT" currentStateMessage: "No related API stage has CloudWatch metrics enabled." remediationMessage: "Enable CloudWatch metrics for the API stage." check: IS_EQUAL: left: RELATED_LIST_COUNT: status: "COMPLIANT" relationshipName: "CA10__AWS_API_Gateway_Stages__r" right: NUMBER: 0.0 - status: "INCOMPLIANT" currentStateMessage: "At least one API stage does not have CloudWatch metrics enabled." remediationMessage: "Enable CloudWatch metrics for the API stage." check: RELATED_LIST_HAS: relationshipName: "CA10__AWS_API_Gateway_Stages__r" status: "INCOMPLIANT" otherwise: status: "COMPLIANT" currentStateMessage: "CloudWatch metrics are enabled for all API stages." relatedLists: - relationshipName: "CA10__AWS_API_Gateway_Stages__r" importExtracts: - file: "/types/CA10__CaAwsApiGatewayStage__c/object.extracts.yaml" conditions: - status: "INCOMPLIANT" currentStateMessage: "CloudWatch metrics are not enabled for this API stage." remediationMessage: "Enable CloudWatch metrics for this API stage." check: IS_EQUAL: left: EXTRACT: "CA10__cloudWatchMetricsEnabled__c" right: BOOLEAN: false otherwise: status: "COMPLIANT" currentStateMessage: "CloudWatch metrics are enabled for this API stage." - path: /ce/ca/aws/apigateway/rest-api-detailed-cloudwatch-metrics/test-data.json md5Hash: FC9F638A748647E918277495758C2A22 content: | [ { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "not(setOfText(['restApi']).contains(RecordType.DeveloperName))", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "Id": "001", "RecordTypeId": "rt001", "RecordType": { "DeveloperName": "httpApi", "Id": "rt001" }, "CA10__AWS_API_Gateway_Stages__r": [ { "CA10__disappearanceTime__c": null, "CA10__cloudWatchMetricsEnabled__c": true, "CA10__restApi__c": "001", "Id": "gs001", "RecordTypeId": "rt001", "RecordType": { "Id": "rt001" } } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "CA10__AWS_API_Gateway_Stages__r.count(COMPLIANT) == number(0.0)", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "Id": "002", "RecordTypeId": "rt002", "RecordType": { "DeveloperName": "restApi", "Id": "rt002" }, "CA10__AWS_API_Gateway_Stages__r": [] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "399", "conditionText": "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "Id": "003", "RecordTypeId": "rt002", "RecordType": { "DeveloperName": "restApi", "Id": "rt002" }, "CA10__AWS_API_Gateway_Stages__r": [ { "CA10__disappearanceTime__c": null, "CA10__cloudWatchMetricsEnabled__c": false, "CA10__restApi__c": "003", "Id": "gs003", "RecordTypeId": "rt003", "RecordType": { "Id": "rt003" } }, { "CA10__disappearanceTime__c": null, "CA10__cloudWatchMetricsEnabled__c": true, "CA10__restApi__c": "003", "Id": "gs003-2", "RecordTypeId": "rt003", "RecordType": { "Id": "rt003" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "400", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "Id": "004", "RecordTypeId": "rt002", "RecordType": { "DeveloperName": "restApi", "Id": "rt002" }, "CA10__AWS_API_Gateway_Stages__r": [ { "CA10__disappearanceTime__c": null, "CA10__cloudWatchMetricsEnabled__c": true, "CA10__restApi__c": "004", "Id": "gs004", "RecordTypeId": "rt003", "RecordType": { "Id": "rt003" } } ] } ] - path: /types/CA10__CaAwsApiGatewayStage__c/object.extracts.yaml md5Hash: 4C63240D980BDDAFE321E6FFAC8F9034 content: "---\nextracts:\n# Values: OFF | INFO | ERROR. Nullable. Can't have no\ \ access, retrieved via apigateway:GetStages.\n - name: CA10__cloudWatchLogLevel__c\n\ \ value: \n FIELD:\n path: CA10__cloudWatchLogLevel__c\n# Values:\ \ Yes | No. Not nullable. Can't have no access, retrieved via apigateway:GetStages.\n\ \ - name: CA10__xrayTracingEnabled__c\n value: \n FIELD:\n path:\ \ CA10__xrayTracingEnabled__c\n# Nullable. Can't have no access, retrieved via\ \ apigateway:GetStages.\n - name: CA10__webAclArn__c\n value: \n FIELD:\n\ \ path: CA10__webAclArn__c\n# Nullable. Checkbox\n - name: CA10__cloudWatchMetricsEnabled__c\n\ \ value: \n FIELD:\n path: CA10__cloudWatchMetricsEnabled__c" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "001", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "not(setOfText(['restApi']).contains(RecordType.DeveloperName))", "runtimeError" : null } }, { "Id" : "002", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "CA10__AWS_API_Gateway_Stages__r.count(COMPLIANT) == number(0.0)", "runtimeError" : null } }, { "Id" : "003", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "399", "conditionText" : "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "004", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "400", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayRestApi__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "001", "RecordTypeId" : "rt001" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "002", "RecordTypeId" : "rt002" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "003", "RecordTypeId" : "rt002" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "004", "RecordTypeId" : "rt002" } ]; """; CREATE TEMP FUNCTION mock_RecordType() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "DeveloperName" : "httpApi", "Id" : "rt001" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "DeveloperName" : "restApi", "Id" : "rt002" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "rt003" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayStage__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__cloudWatchMetricsEnabled__c" : true, "CA10__restApi__c" : "001", "Id" : "gs001", "RecordTypeId" : "rt001" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__cloudWatchMetricsEnabled__c" : false, "CA10__restApi__c" : "003", "Id" : "gs003", "RecordTypeId" : "rt003" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__cloudWatchMetricsEnabled__c" : true, "CA10__restApi__c" : "003", "Id" : "gs003-2", "RecordTypeId" : "rt003" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__cloudWatchMetricsEnabled__c" : true, "CA10__restApi__c" : "004", "Id" : "gs004", "RecordTypeId" : "rt003" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsApiGatewayRestApi__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, Id STRING, RecordTypeId STRING, RecordType STRUCT< DeveloperName STRING, Id STRING >, CA10__AWS_API_Gateway_Stages__r ARRAY, result STRUCT >> >, 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 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] references1.push('Record Type Name [obj.RecordType.DeveloperName]: ' + obj.RecordType.DeveloperName); if (!CollectionLib.contains(CollectionLib.fromArray(['restApi'], true, true, true, true), obj.RecordType.DeveloperName, true)) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['restApi']).contains(RecordType.DeveloperName))", currentStateMessage: "Object record type is not applicable", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } var count_CA10__AWS_API_Gateway_Stages__r_COMPLIANT3 = 0; if (obj.CA10__AWS_API_Gateway_Stages__r != null) { for (var i4 = 0; i4 < obj.CA10__AWS_API_Gateway_Stages__r.length; i4++) { if (typeof(obj.CA10__AWS_API_Gateway_Stages__r[i4].status) !== 'undefined') { if (obj.CA10__AWS_API_Gateway_Stages__r[i4].status == 'COMPLIANT') { count_CA10__AWS_API_Gateway_Stages__r_COMPLIANT3 += obj.CA10__AWS_API_Gateway_Stages__r[i4].count; } } else { if (obj.CA10__AWS_API_Gateway_Stages__r[i4].result.status == 'COMPLIANT') { count_CA10__AWS_API_Gateway_Stages__r_COMPLIANT3 += 1; } } } } // condition[2], conditionIndex:[200..299] references1.push('Related list [CA10__AWS_API_Gateway_Stages__r] has ' + count_CA10__AWS_API_Gateway_Stages__r_COMPLIANT3 + ' objects in COMPLIANT status'); if (count_CA10__AWS_API_Gateway_Stages__r_COMPLIANT3 == 0.0) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_API_Gateway_Stages__r.count(COMPLIANT) == number(0.0)", currentStateMessage: "No related API stage has CloudWatch metrics enabled.", currentStateReferences: references1.join('\n'), remediation: "Enable CloudWatch metrics for the API stage.", runtimeError: null}; } var count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT5 = 0; if (obj.CA10__AWS_API_Gateway_Stages__r != null) { for (var i6 = 0; i6 < obj.CA10__AWS_API_Gateway_Stages__r.length; i6++) { if (typeof(obj.CA10__AWS_API_Gateway_Stages__r[i6].status) !== 'undefined') { if (obj.CA10__AWS_API_Gateway_Stages__r[i6].status == 'INCOMPLIANT') { count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT5 += obj.CA10__AWS_API_Gateway_Stages__r[i6].count; } } else { if (obj.CA10__AWS_API_Gateway_Stages__r[i6].result.status == 'INCOMPLIANT') { count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT5 += 1; } } } } // condition[3], conditionIndex:[300..399] if (count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT5 > 0) { return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)", currentStateMessage: "At least one API stage does not have CloudWatch metrics enabled.", currentStateReferences: references1.join('\n'), remediation: "Enable CloudWatch metrics for the API stage.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "CloudWatch metrics are enabled for all API stages.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10__AWS_API_Gateway_Stages__r( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__cloudWatchMetricsEnabled__c BOOLEAN, CA10__restApi__c STRING, Id STRING, RecordTypeId STRING, RecordType STRUCT< Id STRING > >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" 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__cloudWatchMetricsEnabled__c; } return this.out; }; references1.push('CloudWatch Detailed Metrics Enabled [obj.CA10__cloudWatchMetricsEnabled__c]: ' + obj.CA10__cloudWatchMetricsEnabled__c); if (extract3.call(extract3) == false) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__cloudWatchMetricsEnabled__c') == false", currentStateMessage: "CloudWatch metrics are not enabled for this API stage.", currentStateReferences: references1.join('\n'), remediation: "Enable CloudWatch metrics for this API stage.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "CloudWatch metrics are enabled for this API stage.", 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.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, `CA10__AWS_API_Gateway_Stages__r`.arr AS CA10__AWS_API_Gateway_Stages__r, process_CA10__CaAwsApiGatewayRestApi__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, `CA10__AWS_API_Gateway_Stages__r`.arr AS CA10__AWS_API_Gateway_Stages__r ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsApiGatewayRestApi__c()) AS sObject LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType` ON sObject.RecordTypeId = `RecordType`.Id LEFT JOIN ( SELECT sObject.CA10__restApi__c, ARRAY_AGG( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__cloudWatchMetricsEnabled__c AS CA10__cloudWatchMetricsEnabled__c, sObject.CA10__restApi__c AS CA10__restApi__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `RecordType`.Id AS Id ) AS RecordType, process_CA10__AWS_API_Gateway_Stages__r( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__cloudWatchMetricsEnabled__c AS CA10__cloudWatchMetricsEnabled__c, sObject.CA10__restApi__c AS CA10__restApi__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `RecordType`.Id AS Id ) AS RecordType ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10__CaAwsApiGatewayStage__c()) AS sObject LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType` ON sObject.RecordTypeId = `RecordType`.Id GROUP BY sObject.CA10__restApi__c ) AS `CA10__AWS_API_Gateway_Stages__r` ON sObject.Id = `CA10__AWS_API_Gateway_Stages__r`.CA10__restApi__c ) sObject ON sObject.Id = expectedResult.Id;