--- policy: /ce/ca/automated-provisioning/aws-api-gateway-rest-api logic: /ce/ca/automated-provisioning/aws-api-gateway-rest-api/prod.logic.yaml executionTime: 2026-09-22T15:05:14.35408467Z generationMs: 94 executionMs: 1007 rows: - id: test-disappeared-rest-api 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: test-http-api 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: test-aws-cloudformation-logical-id match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:logical-id')) actual: CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:logical-id')) runtimeError: {} - id: test-aws-cloudformation-stack-id match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-id')) actual: CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-id')) runtimeError: {} - id: test-aws-cloudformation-stack-name match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-name')) actual: CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-name')) runtimeError: {} - id: test-aws-servicecatalog-portfolioarn match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 599 actual: 599 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:portfolioArn')) actual: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:portfolioArn')) runtimeError: {} - id: test-aws-servicecatalog-productarn match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 699 actual: 699 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:productArn')) actual: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:productArn')) runtimeError: {} - id: test-aws-servicecatalog-provisioningprincipalarn match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 799 actual: 799 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningPrincipalArn')) actual: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningPrincipalArn')) runtimeError: {} - id: test-aws-servicecatalog-provisionedproductarn match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 899 actual: 899 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisionedProductArn')) actual: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisionedProductArn')) runtimeError: {} - id: test-aws-servicecatalog-provisioningartifactidentifier match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 999 actual: 999 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningArtifactIdentifier')) actual: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningArtifactIdentifier')) runtimeError: {} - id: test-no-supported-provisioning-tags match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 1000 actual: 1000 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/automated-provisioning/aws-api-gateway-rest-api/policy.yaml md5Hash: 772B4618B72A67A7D9C573C28DFBF177 content: | --- names: full: AWS API Gateway REST API auto-provisioning status contextual: API Gateway REST API auto-provisioning status description: "Identify AWS API Gateway REST APIs with AWS-managed CloudFormation or Service Catalog tags." type: COMPLIANCE_POLICY categories: - RELIABILITY - path: /ce/ca/automated-provisioning/aws-api-gateway-rest-api/prod.logic.yaml md5Hash: ADFA7D2D6BB659B442D82E54190DBE91 content: | --- inputType: "CA10__CaAwsApiGatewayRestApi__c" testData: - file: "test-data.json" recordTypes: - restApi conditions: - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS CloudFormation." check: TAG_EXISTS: name: BYTES: "aws:cloudformation:logical-id" - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS CloudFormation." check: TAG_EXISTS: name: BYTES: "aws:cloudformation:stack-id" - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS CloudFormation." check: TAG_EXISTS: name: BYTES: "aws:cloudformation:stack-name" - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS Service Catalog." check: TAG_EXISTS: name: BYTES: "aws:servicecatalog:portfolioArn" - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS Service Catalog." check: TAG_EXISTS: name: BYTES: "aws:servicecatalog:productArn" - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS Service Catalog." check: TAG_EXISTS: name: BYTES: "aws:servicecatalog:provisioningPrincipalArn" - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS Service Catalog." check: TAG_EXISTS: name: BYTES: "aws:servicecatalog:provisionedProductArn" - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS Service Catalog." check: TAG_EXISTS: name: BYTES: "aws:servicecatalog:provisioningArtifactIdentifier" otherwise: status: "INCOMPLIANT" currentStateMessage: "The automated provisioning source is not identified by supported AWS-managed tag signals." remediationMessage: "Review the automated provisioning source, ownership, and expected management workflow." - path: /ce/ca/automated-provisioning/aws-api-gateway-rest-api/test-data.json md5Hash: 1EF6682D58EDD0B37410830B9F8B5D6A content: | [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-disappeared-rest-api", "Name": "test-disappeared-rest-api", "CA10__tagsJson__c": "{\"Owner\":\"platform-team\"}", "CA10__disappearanceTime__c": "2026-06-22T00:00:00Z", "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "not(setOfText(['restApi']).contains(RecordType.DeveloperName))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-http-api", "Name": "test-http-api", "CA10__tagsJson__c": "{\"aws:cloudformation:stack-id\":\"arn:aws:cloudformation:us-east-1:123456789012:stack/test/test\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-http-api", "RecordType": { "DeveloperName": "httpApi", "Id": "rt-http-api" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "299", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:logical-id'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-cloudformation-logical-id", "Name": "test-aws-cloudformation-logical-id", "CA10__tagsJson__c": "{\"aws:cloudformation:logical-id\":\"MyRestApi\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "399", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-id'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-cloudformation-stack-id", "Name": "test-aws-cloudformation-stack-id", "CA10__tagsJson__c": "{\"aws:cloudformation:stack-id\":\"arn:aws:cloudformation:us-east-1:123456789012:stack/test/test\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "499", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-name'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-cloudformation-stack-name", "Name": "test-aws-cloudformation-stack-name", "CA10__tagsJson__c": "{\"aws:cloudformation:stack-name\":\"test-stack\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "599", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:portfolioArn'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-servicecatalog-portfolioarn", "Name": "test-aws-servicecatalog-portfolioarn", "CA10__tagsJson__c": "{\"aws:servicecatalog:portfolioArn\":\"arn:aws:catalog:us-east-1:123456789012:portfolio/port-abc123\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "699", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:productArn'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-servicecatalog-productarn", "Name": "test-aws-servicecatalog-productarn", "CA10__tagsJson__c": "{\"aws:servicecatalog:productArn\":\"arn:aws:catalog:us-east-1:123456789012:product/prod-abc123\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "799", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningPrincipalArn'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-servicecatalog-provisioningprincipalarn", "Name": "test-aws-servicecatalog-provisioningprincipalarn", "CA10__tagsJson__c": "{\"aws:servicecatalog:provisioningPrincipalArn\":\"arn:aws:iam::123456789012:role/provisioning-role\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "899", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisionedProductArn'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-servicecatalog-provisionedproductarn", "Name": "test-aws-servicecatalog-provisionedproductarn", "CA10__tagsJson__c": "{\"aws:servicecatalog:provisionedProductArn\":\"arn:aws:servicecatalog:us-east-1:123456789012:stack/test/pp-abc123\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "999", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningArtifactIdentifier'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-servicecatalog-provisioningartifactidentifier", "Name": "test-aws-servicecatalog-provisioningartifactidentifier", "CA10__tagsJson__c": "{\"aws:servicecatalog:provisioningArtifactIdentifier\":\"pa-abc123\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "1000", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-no-supported-provisioning-tags", "Name": "test-no-supported-provisioning-tags", "CA10__tagsJson__c": "{\"Owner\":\"platform-team\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rt-rest-api", "RecordType": { "DeveloperName": "restApi", "Id": "rt-rest-api" } } ] script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test-disappeared-rest-api", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test-http-api", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "not(setOfText(['restApi']).contains(RecordType.DeveloperName))", "runtimeError" : null } }, { "Id" : "test-aws-cloudformation-logical-id", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "299", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:logical-id'))", "runtimeError" : null } }, { "Id" : "test-aws-cloudformation-stack-id", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "399", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-id'))", "runtimeError" : null } }, { "Id" : "test-aws-cloudformation-stack-name", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "499", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-name'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-portfolioarn", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "599", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:portfolioArn'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-productarn", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "699", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:productArn'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-provisioningprincipalarn", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "799", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningPrincipalArn'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-provisionedproductarn", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "899", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisionedProductArn'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-provisioningartifactidentifier", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "999", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningArtifactIdentifier'))", "runtimeError" : null } }, { "Id" : "test-no-supported-provisioning-tags", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "1000", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayRestApi__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__disappearanceTime__c" : new Date("2026-06-22T00:00:00Z"), "CA10__tagsJson__c" : "{\"Owner\":\"platform-team\"}", "Id" : "test-disappeared-rest-api", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:cloudformation:stack-id\":\"arn:aws:cloudformation:us-east-1:123456789012:stack/test/test\"}", "Id" : "test-http-api", "RecordTypeId" : "rt-http-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:cloudformation:logical-id\":\"MyRestApi\"}", "Id" : "test-aws-cloudformation-logical-id", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:cloudformation:stack-id\":\"arn:aws:cloudformation:us-east-1:123456789012:stack/test/test\"}", "Id" : "test-aws-cloudformation-stack-id", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:cloudformation:stack-name\":\"test-stack\"}", "Id" : "test-aws-cloudformation-stack-name", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:servicecatalog:portfolioArn\":\"arn:aws:catalog:us-east-1:123456789012:portfolio/port-abc123\"}", "Id" : "test-aws-servicecatalog-portfolioarn", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:servicecatalog:productArn\":\"arn:aws:catalog:us-east-1:123456789012:product/prod-abc123\"}", "Id" : "test-aws-servicecatalog-productarn", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:servicecatalog:provisioningPrincipalArn\":\"arn:aws:iam::123456789012:role/provisioning-role\"}", "Id" : "test-aws-servicecatalog-provisioningprincipalarn", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:servicecatalog:provisionedProductArn\":\"arn:aws:servicecatalog:us-east-1:123456789012:stack/test/pp-abc123\"}", "Id" : "test-aws-servicecatalog-provisionedproductarn", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:servicecatalog:provisioningArtifactIdentifier\":\"pa-abc123\"}", "Id" : "test-aws-servicecatalog-provisioningartifactidentifier", "RecordTypeId" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"Owner\":\"platform-team\"}", "Id" : "test-no-supported-provisioning-tags", "RecordTypeId" : "rt-rest-api" } ]; """; CREATE TEMP FUNCTION mock_RecordType() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "DeveloperName" : "restApi", "Id" : "rt-rest-api" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "DeveloperName" : "httpApi", "Id" : "rt-http-api" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsApiGatewayRestApi__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, RecordType STRUCT< DeveloperName STRING, Id STRING >, CA10__tagsJson__c STRING, Id STRING, RecordTypeId STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var TagsLib = new function () { this.inexact = function(tag) { return tag == null ? null : tag.replace(/[^a-zA-Z0-9]/g, '').toLowerCase(); } this.parseTags = function(tagsJson) { if (tagsJson && tagsJson !== '') { return JSON.parse(tagsJson); } else { return {}; } } this.tagExists = function(tagName, exact, tagsJson) { var checkTag = exact ? tagName : this.inexact(tagName); var parsed = this.parseTags(tagsJson); var exists = false; for (var parsedTagName in parsed) { var currentTagName = exact ? parsedTagName : this.inexact(parsedTagName); if (currentTagName === checkTag) { exists = true; break; } } return exists; } this.tagValue = function(tagName, exact, tagsJson) { var checkTag = exact ? tagName : this.inexact(tagName); var parsed = this.parseTags(tagsJson); var value = ''; for (var parsedTagName in parsed) { var currentTagName = exact ? parsedTagName : this.inexact(parsedTagName); if (currentTagName === checkTag) { value = parsed[parsedTagName]; break; } } return value; } }(); 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 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 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 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}; } // condition[2], conditionIndex:[200..299] references1.push('Tags JSON [obj.CA10__tagsJson__c]: ' + obj.CA10__tagsJson__c); if (TagsLib.tagExists('aws:cloudformation:logical-id', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:logical-id'))", currentStateMessage: "The automated provisioning source is AWS CloudFormation.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[3], conditionIndex:[300..399] if (TagsLib.tagExists('aws:cloudformation:stack-id', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-id'))", currentStateMessage: "The automated provisioning source is AWS CloudFormation.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[4], conditionIndex:[400..499] if (TagsLib.tagExists('aws:cloudformation:stack-name', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:cloudformation:stack-name'))", currentStateMessage: "The automated provisioning source is AWS CloudFormation.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[5], conditionIndex:[500..599] if (TagsLib.tagExists('aws:servicecatalog:portfolioArn', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:portfolioArn'))", currentStateMessage: "The automated provisioning source is AWS Service Catalog.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[6], conditionIndex:[600..699] if (TagsLib.tagExists('aws:servicecatalog:productArn', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 699, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:productArn'))", currentStateMessage: "The automated provisioning source is AWS Service Catalog.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[7], conditionIndex:[700..799] if (TagsLib.tagExists('aws:servicecatalog:provisioningPrincipalArn', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 799, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningPrincipalArn'))", currentStateMessage: "The automated provisioning source is AWS Service Catalog.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[8], conditionIndex:[800..899] if (TagsLib.tagExists('aws:servicecatalog:provisionedProductArn', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 899, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisionedProductArn'))", currentStateMessage: "The automated provisioning source is AWS Service Catalog.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[9], conditionIndex:[900..999] if (TagsLib.tagExists('aws:servicecatalog:provisioningArtifactIdentifier', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 999, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningArtifactIdentifier'))", currentStateMessage: "The automated provisioning source is AWS Service Catalog.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'INCOMPLIANT', conditionIndex: 1000, conditionText: "otherwise", currentStateMessage: "The automated provisioning source is not identified by supported AWS-managed tag signals.", currentStateReferences: references1.join('\n'), remediation: "Review the automated provisioning source, ownership, and expected management workflow.", 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, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, sObject.CA10__tagsJson__c AS CA10__tagsJson__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, process_CA10__CaAwsApiGatewayRestApi__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, sObject.CA10__tagsJson__c AS CA10__tagsJson__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId ), 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 ) sObject ON sObject.Id = expectedResult.Id;