--- policy: /ce/ca/automated-provisioning/aws-ec2-image logic: /ce/ca/automated-provisioning/aws-ec2-image/prod.logic.yaml executionTime: 2026-09-22T15:05:14.446387058Z generationMs: 112 executionMs: 1099 rows: - id: test-aws-backup-source-resource match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:backup:source-resource')) actual: CA10__tagsJson__c.hasExact(bytes('aws:backup:source-resource')) runtimeError: {} - id: test-aws-dlm-ami-tags match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-policy-id')) && CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-schedule-name')) && CA10__tagsJson__c.hasExact(bytes('dlm:managed')) actual: CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-policy-id')) && CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-schedule-name')) && CA10__tagsJson__c.hasExact(bytes('dlm:managed')) runtimeError: {} - id: test-aws-servicecatalog-portfolioarn match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 399 actual: 399 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: 499 actual: 499 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: 599 actual: 599 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: 699 actual: 699 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: 799 actual: 799 conditionText: expected: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningArtifactIdentifier')) actual: CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningArtifactIdentifier')) runtimeError: {} - id: test-no-automatic-provisioning-tags match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 800 actual: 800 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test-aws-backup-managed-resource-not-supported match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 800 actual: 800 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test-aws-application-migration-service-not-supported-for-ami match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 800 actual: 800 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test-aws-elastic-disaster-recovery-not-supported-for-ami match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 800 actual: 800 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test-aws-rds-custom-not-supported-for-ami match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 800 actual: 800 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test-aws-dlm-incomplete-tags match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 800 actual: 800 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/automated-provisioning/aws-ec2-image/policy.yaml md5Hash: E1AF9E8E5D6AB3EF2EBB7AFC1CFAEA0E content: | --- names: full: "AWS EC2 Image auto-provisioning status" contextual: "EC2 Image auto-provisioning status" description: "Identify AWS EC2 AMIs with AWS-managed tag evidence that may indicate\ \ creation or management by AWS Backup, Amazon Data Lifecycle Manager, or AWS Service Catalog." type: COMPLIANCE_POLICY categories: - RELIABILITY - path: /ce/ca/automated-provisioning/aws-ec2-image/prod.logic.yaml md5Hash: EA91BFA4952E4A60A0FE26DD52B0B2D7 content: | --- inputType: "CA10__CaAwsImage__c" testData: - file: "test-data.json" conditions: - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is AWS Backup." check: TAG_EXISTS: name: BYTES: "aws:backup:source-resource" - status: "COMPLIANT" currentStateMessage: "The automated provisioning source is Amazon Data Lifecycle Manager." check: AND: args: - TAG_EXISTS: name: BYTES: "aws:dlm:lifecycle-policy-id" - TAG_EXISTS: name: BYTES: "aws:dlm:lifecycle-schedule-name" - TAG_EXISTS: name: BYTES: "dlm:managed" - 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-ec2-image/test-data.json md5Hash: 5741D1A8F9887B336B2D2A87E90D8F0E content: | [ { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "199", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:backup:source-resource'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-backup-source-resource", "Name": "test-aws-backup-source-resource", "CA10__tagsJson__c": "{\"aws:backup:source-resource\":\"arn:aws:ec2:us-east-1:123456789012:volume/vol-0123456789abcdef0\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "299", "conditionText": "CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-policy-id')) && CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-schedule-name')) && CA10__tagsJson__c.hasExact(bytes('dlm:managed'))", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-dlm-ami-tags", "Name": "test-aws-dlm-ami-tags", "CA10__tagsJson__c": "{\"aws:dlm:lifecycle-policy-id\":\"policy-0123456789abcdef0\",\"aws:dlm:lifecycle-schedule-name\":\"Daily AMIs\",\"dlm:managed\":\"true\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "399", "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": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "499", "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": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "599", "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": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "699", "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": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "799", "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": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "800", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-no-automatic-provisioning-tags", "Name": "test-no-automatic-provisioning-tags", "CA10__tagsJson__c": "{\"Owner\":\"platform-team\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "800", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-backup-managed-resource-not-supported", "Name": "test-aws-backup-managed-resource-not-supported", "CA10__tagsJson__c": "{\"AWSBackupManagedResource\":\"2026-06-23T00:00:00Z\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "800", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-application-migration-service-not-supported-for-ami", "Name": "test-aws-application-migration-service-not-supported-for-ami", "CA10__tagsJson__c": "{\"AWSApplicationMigrationServiceManaged\":\"mgn.amazonaws.com\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "800", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-elastic-disaster-recovery-not-supported-for-ami", "Name": "test-aws-elastic-disaster-recovery-not-supported-for-ami", "CA10__tagsJson__c": "{\"AWSElasticDisasterRecoveryManaged\":\"drs.amazonaws.com\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "800", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-rds-custom-not-supported-for-ami", "Name": "test-aws-rds-custom-not-supported-for-ami", "CA10__tagsJson__c": "{\"AWSRDSCustom\":\"custom-sqlserver\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "800", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-06-23T00:00:00Z" }, "Id": "test-aws-dlm-incomplete-tags", "Name": "test-aws-dlm-incomplete-tags", "CA10__tagsJson__c": "{\"aws:dlm:lifecycle-policy-id\":\"policy-0123456789abcdef0\",\"aws:dlm:lifecycle-schedule-name\":\"Daily AMIs\"}", "CA10__disappearanceTime__c": null, "RecordTypeId": "rtId", "RecordType": { "DeveloperName": "RecordType1", "Id": "rtId" } } ] script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test-aws-backup-source-resource", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:backup:source-resource'))", "runtimeError" : null } }, { "Id" : "test-aws-dlm-ami-tags", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "299", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-policy-id')) && CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-schedule-name')) && CA10__tagsJson__c.hasExact(bytes('dlm:managed'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-portfolioarn", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "399", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:portfolioArn'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-productarn", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "499", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:productArn'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-provisioningprincipalarn", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "599", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningPrincipalArn'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-provisionedproductarn", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "699", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisionedProductArn'))", "runtimeError" : null } }, { "Id" : "test-aws-servicecatalog-provisioningartifactidentifier", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "799", "conditionText" : "CA10__tagsJson__c.hasExact(bytes('aws:servicecatalog:provisioningArtifactIdentifier'))", "runtimeError" : null } }, { "Id" : "test-no-automatic-provisioning-tags", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "800", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test-aws-backup-managed-resource-not-supported", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "800", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test-aws-application-migration-service-not-supported-for-ami", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "800", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test-aws-elastic-disaster-recovery-not-supported-for-ami", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "800", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test-aws-rds-custom-not-supported-for-ami", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "800", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test-aws-dlm-incomplete-tags", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "800", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsImage__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:backup:source-resource\":\"arn:aws:ec2:us-east-1:123456789012:volume/vol-0123456789abcdef0\"}", "Id" : "test-aws-backup-source-resource" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:dlm:lifecycle-policy-id\":\"policy-0123456789abcdef0\",\"aws:dlm:lifecycle-schedule-name\":\"Daily AMIs\",\"dlm:managed\":\"true\"}", "Id" : "test-aws-dlm-ami-tags" }, { "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" }, { "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" }, { "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" }, { "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" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:servicecatalog:provisioningArtifactIdentifier\":\"pa-abc123\"}", "Id" : "test-aws-servicecatalog-provisioningartifactidentifier" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"Owner\":\"platform-team\"}", "Id" : "test-no-automatic-provisioning-tags" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"AWSBackupManagedResource\":\"2026-06-23T00:00:00Z\"}", "Id" : "test-aws-backup-managed-resource-not-supported" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"AWSApplicationMigrationServiceManaged\":\"mgn.amazonaws.com\"}", "Id" : "test-aws-application-migration-service-not-supported-for-ami" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"AWSElasticDisasterRecoveryManaged\":\"drs.amazonaws.com\"}", "Id" : "test-aws-elastic-disaster-recovery-not-supported-for-ami" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"AWSRDSCustom\":\"custom-sqlserver\"}", "Id" : "test-aws-rds-custom-not-supported-for-ami" }, { "context" : { "snapshotTime" : new Date("2026-06-23T00:00:00Z") }, "CA10__tagsJson__c" : "{\"aws:dlm:lifecycle-policy-id\":\"policy-0123456789abcdef0\",\"aws:dlm:lifecycle-schedule-name\":\"Daily AMIs\"}", "Id" : "test-aws-dlm-incomplete-tags" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsImage__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__tagsJson__c STRING, Id 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 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('Tags JSON [obj.CA10__tagsJson__c]: ' + obj.CA10__tagsJson__c); if (TagsLib.tagExists('aws:backup:source-resource', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:backup:source-resource'))", currentStateMessage: "The automated provisioning source is AWS Backup.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] if (TagsLib.tagExists('aws:dlm:lifecycle-policy-id', true, obj.CA10__tagsJson__c) && TagsLib.tagExists('aws:dlm:lifecycle-schedule-name', true, obj.CA10__tagsJson__c) && TagsLib.tagExists('dlm:managed', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-policy-id')) && CA10__tagsJson__c.hasExact(bytes('aws:dlm:lifecycle-schedule-name')) && CA10__tagsJson__c.hasExact(bytes('dlm:managed'))", currentStateMessage: "The automated provisioning source is Amazon Data Lifecycle Manager.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[3], conditionIndex:[300..399] if (TagsLib.tagExists('aws:servicecatalog:portfolioArn', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 399, 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[4], conditionIndex:[400..499] if (TagsLib.tagExists('aws:servicecatalog:productArn', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 499, 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[5], conditionIndex:[500..599] if (TagsLib.tagExists('aws:servicecatalog:provisioningPrincipalArn', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 599, 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[6], conditionIndex:[600..699] if (TagsLib.tagExists('aws:servicecatalog:provisionedProductArn', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 699, 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[7], conditionIndex:[700..799] if (TagsLib.tagExists('aws:servicecatalog:provisioningArtifactIdentifier', true, obj.CA10__tagsJson__c)) { return {status: 'COMPLIANT', conditionIndex: 799, 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: 800, 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, sObject.CA10__tagsJson__c AS CA10__tagsJson__c, sObject.Id AS Id, process_CA10__CaAwsImage__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__tagsJson__c AS CA10__tagsJson__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsImage__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;