---
policy: /ce/ca/aws/account/ebs-volume-encryption-attribute-in-all-regions
logic: /ce/ca/aws/account/ebs-volume-encryption-attribute-in-all-regions/prod.logic.yaml
executionTime: 2025-04-24T23:44:07.434669248Z
rows:
  - id: a01
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__AWS_Account_Regions__r.has(INCOMPLIANT)
      actual: CA10__AWS_Account_Regions__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: a02
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_Account_Regions__r.has(UNDETERMINED)
      actual: CA10__AWS_Account_Regions__r.has(UNDETERMINED)
    runtimeError: {}
  - id: a03
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: CA10__AWS_Account_Regions__r.has(COMPLIANT)
      actual: CA10__AWS_Account_Regions__r.has(COMPLIANT)
    runtimeError: {}
  - id: a04
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 400
      actual: 400
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/account/ebs-volume-encryption-attribute-in-all-regions/policy.yaml
    md5Hash: 1098E00504C14BFE621CC615231D0845
    content: |
      ---
      names:
        full: AWS Account EBS Volume Encryption Attribute is not enabled in all regions
        contextual: EBS Volume Encryption Attribute is not enabled in all regions
      description: "Elastic Compute Cloud (EC2) supports encryption at rest when using the\
        \ Elastic Block Store (EBS) service. While disabled by default, forcing encryption\
        \ at EBS volume creation is supported."
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-aws-v5.0.0/05/01/01"
        - "/frameworks/cloudaware/resource-security/data-encryption"
        - "/frameworks/aws-fsbp-v1.0.0/ec2/07"
      similarPolicies:
        internal:
          - dec-x-0bdcd276
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity-staging/knowledge-base/aws/EBS/configure-default-encryption.html
            name: Enable Encryption by Default for EBS Volumes
  - path: /ce/ca/aws/account/ebs-volume-encryption-attribute-in-all-regions/prod.logic.yaml
    md5Hash: 5827CA8DE9AF040F66AF5D74622CA621
    content: "---\ninputType: \"CA10__CaAwsAccount__c\"\ntestData:\n  - file: test-data.json\n\
      importExtracts:\n  - file: /types/CA10__CaAwsAccount__c/object.extracts.yaml\n\
      conditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage: \"Default\
      \ encryption of EBS volume disabled\"\n    remediationMessage: \"Enable EBS\
      \ Volume Encryption\"\n    check:\n      RELATED_LIST_HAS:\n        status:\
      \ \"INCOMPLIANT\"\n        relationshipName: \"CA10__AWS_Account_Regions__r\"\
      \n  - status: \"UNDETERMINED\"\n    currentStateMessage: \"Can't determine default\
      \ status of EBS encryption\"\n    check:\n     RELATED_LIST_HAS:\n      status:\
      \ \"UNDETERMINED\"\n      relationshipName: \"CA10__AWS_Account_Regions__r\"\
      \n  - status: \"COMPLIANT\"\n    currentStateMessage: \"Default encryption of\
      \ EBS volume enabled\"\n    check:\n      RELATED_LIST_HAS:\n        status:\
      \ \"COMPLIANT\"\n        relationshipName: \"CA10__AWS_Account_Regions__r\"\n\
      otherwise:\n  status: \"INAPPLICABLE\"\n  currentStateMessage: \"Region not\
      \ in use\"\nrelatedLists:\n  - relationshipName: \"CA10__AWS_Account_Regions__r\"\
      \n    importExtracts:\n    - file: \"/types/CA10__CaAwsAccountRegion__c/object.extracts.yaml\"\
      \n    conditions:\n      - status: \"UNDETERMINED\"\n        currentStateMessage:\
      \ \"Can't determine default status of EBS encryption\"\n        check:\n   \
      \       AND:\n            args:\n              - NOT_EQUAL: \n             \
      \     left:\n                    EXTRACT: \"CA10__status__c\"\n            \
      \      right:\n                    TEXT: \"not-opted-in\"\n              - IS_EMPTY:\n\
      \                  arg:\n                    EXTRACT: \"CA10__ebsStorageEncryption__c\"\
      \n      - status: \"INCOMPLIANT\"\n        currentStateMessage: \"Default encryption\
      \ of EBS volume disabled for region\"\n        check:\n          AND:\n    \
      \        args:\n              - NOT_EQUAL: \n                  left:\n     \
      \               EXTRACT: \"CA10__status__c\"\n                  right:\n   \
      \                 TEXT: \"not-opted-in\"\n              - IS_EQUAL:\n      \
      \            left:\n                    EXTRACT: \"CA10__ebsStorageEncryption__c\"\
      \n                  right:\n                    TEXT: \"Disabled\"\n      -\
      \ status: \"COMPLIANT\"\n        currentStateMessage: \"Default encryption of\
      \ EBS volume enabled for region\"\n        check:\n          AND:\n        \
      \    args:\n              - NOT_EQUAL: \n                  left:\n         \
      \           EXTRACT: \"CA10__status__c\"\n                  right:\n       \
      \             TEXT: \"not-opted-in\"\n              - IS_EQUAL:\n          \
      \        left:\n                    EXTRACT: \"CA10__ebsStorageEncryption__c\"\
      \n                  right:\n                    TEXT: \"Enabled\"\n    otherwise:\n\
      \      status: \"INAPPLICABLE\"\n      currentStateMessage: \"Region should\
      \ be in-use.\""
  - path: /ce/ca/aws/account/ebs-volume-encryption-attribute-in-all-regions/test-data.json
    md5Hash: 5ADF34894BF702702382EF2ECD3C4D35
    content: |
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "CA10__AWS_Account_Regions__r.has(INCOMPLIANT)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-06-04T19:44:50Z" },
          "Id": "a01",
          "CA10__AWS_Account_Regions__r": [
            {
              "Id": "aD1",
              "CA10__status__c": "not-opted-in",
              "CA10__ebsStorageEncryption__c": "",
              "CA10__account__c": "a01"
            },
            {
              "Id": "aD2",
              "CA10__status__c": "opt-in-not-required",
              "CA10__ebsStorageEncryption__c": "Enabled",
              "CA10__account__c": "a01"
            },
            {
              "Id": "aD3",
              "CA10__status__c": "opt-in-not-required",
              "CA10__ebsStorageEncryption__c": "Disabled",
              "CA10__account__c": "a01"
            }
          ]
        },
        {
          "expectedResult": {
            "status": "UNDETERMINED",
            "conditionIndex": "299",
            "conditionText": "CA10__AWS_Account_Regions__r.has(UNDETERMINED)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-06-04T19:44:50Z" },
          "Id": "a02",
          "CA10__AWS_Account_Regions__r": [
            {
              "Id": "aD12",
              "CA10__status__c": "not-opted-in",
              "CA10__ebsStorageEncryption__c": "",
              "CA10__account__c": "a02"
            },
            {
              "Id": "aD22",
              "CA10__status__c": "opt-in-not-required",
              "CA10__ebsStorageEncryption__c": "",
              "CA10__account__c": "a02"
            },
            {
              "Id": "aD32",
              "CA10__status__c": "opt-in-not-required",
              "CA10__ebsStorageEncryption__c": "Enabled",
              "CA10__account__c": "a02"
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "399",
            "conditionText": "CA10__AWS_Account_Regions__r.has(COMPLIANT)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-06-04T19:44:50Z" },
          "Id": "a03",
          "CA10__AWS_Account_Regions__r": [
            {
              "Id": "aD13",
              "CA10__status__c": "not-opted-in",
              "CA10__ebsStorageEncryption__c": "",
              "CA10__account__c": "a03"
            },
            {
              "Id": "aD23",
              "CA10__status__c": "opt-in-not-required",
              "CA10__ebsStorageEncryption__c": "Enabled",
              "CA10__account__c": "a03"
            },
            {
              "Id": "aD33",
              "CA10__status__c": "opt-in-not-required",
              "CA10__ebsStorageEncryption__c": "Enabled",
              "CA10__account__c": "a03"
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "400",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-06-04T19:44:50Z" },
          "Id": "a04",
          "CA10__AWS_Account_Regions__r": [
            {
              "Id": "aD14",
              "CA10__status__c": "not-opted-in",
              "CA10__ebsStorageEncryption__c": "",
              "CA10__account__c": "a04"
            }
          ]
        }
      ]
  - path: /types/CA10__CaAwsAccountRegion__c/object.extracts.yaml
    md5Hash: B5D54D4844B8E77238E14E730ABEE3C4
    content: "---\nextracts:\n  - name: CA10__status__c\n    value: \n      FIELD:\n\
      \        path: CA10__status__c\n        undeterminedIf:\n          isEmpty:\
      \ \"Account Region status must be specified \"\n  - name: CA10__ebsStorageEncryption__c\n\
      \    value: \n      FIELD:\n        path: CA10__ebsStorageEncryption__c\n  \
      \      undeterminedIf:\n          isEmpty: \"EBS Storage Encryption can not\
      \ be empty. Possibly corrupted data.\""
  - path: /types/CA10__CaAwsAccount__c/object.extracts.yaml
    md5Hash: FF575E27BEBAF3C8E85968E44798945B
    content: "---\nextracts:\n  - name: CA10__accountId__c\n    value: \n      FIELD:\n\
      \        path: CA10__accountId__c\n        undeterminedIf:\n          isEmpty:\
      \ \"Account ID can not be empty. Possibly corrupted data.\"\n  "
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "a01",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__AWS_Account_Regions__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "a02",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_Account_Regions__r.has(UNDETERMINED)",
      "runtimeError" : null
    }
  }, {
    "Id" : "a03",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "CA10__AWS_Account_Regions__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "a04",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "400",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsAccount__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "a01"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "a02"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "a03"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "a04"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsAccountRegion__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__status__c STRING,
      CA10__ebsStorageEncryption__c STRING,
      CA10__account__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD1",
    "CA10__status__c" : "not-opted-in",
    "CA10__ebsStorageEncryption__c" : "",
    "CA10__account__c" : "a01"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD2",
    "CA10__status__c" : "opt-in-not-required",
    "CA10__ebsStorageEncryption__c" : "Enabled",
    "CA10__account__c" : "a01"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD3",
    "CA10__status__c" : "opt-in-not-required",
    "CA10__ebsStorageEncryption__c" : "Disabled",
    "CA10__account__c" : "a01"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD12",
    "CA10__status__c" : "not-opted-in",
    "CA10__ebsStorageEncryption__c" : "",
    "CA10__account__c" : "a02"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD22",
    "CA10__status__c" : "opt-in-not-required",
    "CA10__ebsStorageEncryption__c" : "",
    "CA10__account__c" : "a02"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD32",
    "CA10__status__c" : "opt-in-not-required",
    "CA10__ebsStorageEncryption__c" : "Enabled",
    "CA10__account__c" : "a02"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD13",
    "CA10__status__c" : "not-opted-in",
    "CA10__ebsStorageEncryption__c" : "",
    "CA10__account__c" : "a03"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD23",
    "CA10__status__c" : "opt-in-not-required",
    "CA10__ebsStorageEncryption__c" : "Enabled",
    "CA10__account__c" : "a03"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD33",
    "CA10__status__c" : "opt-in-not-required",
    "CA10__ebsStorageEncryption__c" : "Enabled",
    "CA10__account__c" : "a03"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "Id" : "aD14",
    "CA10__status__c" : "not-opted-in",
    "CA10__ebsStorageEncryption__c" : "",
    "CA10__account__c" : "a04"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsAccount__c(
      obj STRUCT<
          Id STRING,
          CA10__AWS_Account_Regions__r ARRAY<STRUCT<
              Id STRING,
              CA10__status__c STRING,
              CA10__ebsStorageEncryption__c STRING,
              CA10__account__c STRING,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
          >>
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      if (false) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared()", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_Account_Regions__r_INCOMPLIANT2 = 0;
      if (obj.CA10__AWS_Account_Regions__r != null) {
          for (var i3 = 0; i3 < obj.CA10__AWS_Account_Regions__r.length; i3++) {
              if (obj.CA10__AWS_Account_Regions__r[i3].result.status == 'INCOMPLIANT') {
                  count_CA10__AWS_Account_Regions__r_INCOMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__AWS_Account_Regions__r] ' + (count_CA10__AWS_Account_Regions__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__AWS_Account_Regions__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10__AWS_Account_Regions__r.has(INCOMPLIANT)", currentStateMessage: "Default encryption of EBS volume disabled", currentStateReferences: references1.join('\n'), remediation: "Enable EBS Volume Encryption", runtimeError: null};
      }
      var count_CA10__AWS_Account_Regions__r_UNDETERMINED4 = 0;
      if (obj.CA10__AWS_Account_Regions__r != null) {
          for (var i5 = 0; i5 < obj.CA10__AWS_Account_Regions__r.length; i5++) {
              if (obj.CA10__AWS_Account_Regions__r[i5].result.status == 'UNDETERMINED') {
                  count_CA10__AWS_Account_Regions__r_UNDETERMINED4 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      if (count_CA10__AWS_Account_Regions__r_UNDETERMINED4 > 0) {
          return {status: 'UNDETERMINED', conditionIndex: 299, conditionText: "CA10__AWS_Account_Regions__r.has(UNDETERMINED)", currentStateMessage: "Can't determine default status of EBS encryption", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_Account_Regions__r_COMPLIANT6 = 0;
      if (obj.CA10__AWS_Account_Regions__r != null) {
          for (var i7 = 0; i7 < obj.CA10__AWS_Account_Regions__r.length; i7++) {
              if (obj.CA10__AWS_Account_Regions__r[i7].result.status == 'COMPLIANT') {
                  count_CA10__AWS_Account_Regions__r_COMPLIANT6 += 1;
              }
          }
      }
      // condition[3], conditionIndex:[300..399]
      if (count_CA10__AWS_Account_Regions__r_COMPLIANT6 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "CA10__AWS_Account_Regions__r.has(COMPLIANT)", currentStateMessage: "Default encryption of EBS volume enabled", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INAPPLICABLE', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Region not in use", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_Account_Regions__r(
      obj STRUCT<
          Id STRING,
          CA10__status__c STRING,
          CA10__ebsStorageEncryption__c STRING,
          CA10__account__c STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      var TextLib = new function () {
          this.normalize = function(arg) {
              return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
          };
          this.isEmpty = function(arg) {
              return this.normalize(arg) == '';
          };
          this.isNotEmpty = function(arg) {
              return this.normalize(arg) != '';
          };
          this.equal = function(left, right) {
              return this.normalize(left) == this.normalize(right);
          };
          this.notEqual = function(left, right) {
              return this.normalize(left) != this.normalize(right);
          };
          this.startsWith = function(arg, substring) {
              return this.normalize(arg).startsWith(this.normalize(substring));
          };
          this.endsWith = function(arg, substring) {
              return this.normalize(arg).endsWith(this.normalize(substring));
          };
          this.contains = function(arg, substring) {
              return this.normalize(arg).includes(this.normalize(substring));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      if (false) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared()", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__status__c.isEmpty()", currentStateMessage: "Account Region status must be specified ", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__status__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10__ebsStorageEncryption__c)) {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "CA10__ebsStorageEncryption__c.isEmpty()", currentStateMessage: "EBS Storage Encryption can not be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__ebsStorageEncryption__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c);
      references1.push('EBS Storage Encryption [obj.CA10__ebsStorageEncryption__c]: ' + obj.CA10__ebsStorageEncryption__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'not-opted-in') && TextLib.isEmpty(extract6.call(extract6))) {
              return {status: 'UNDETERMINED', conditionIndex: 199, conditionText: "extract('CA10__status__c') != 'not-opted-in' && extract('CA10__ebsStorageEncryption__c').isEmpty()", currentStateMessage: "Can't determine default status of EBS encryption", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked10() {
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__status__c.isEmpty()", currentStateMessage: "Account Region status must be specified ", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__status__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      function fieldChecked13() {
          if (TextLib.isEmpty(obj.CA10__ebsStorageEncryption__c)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "CA10__ebsStorageEncryption__c.isEmpty()", currentStateMessage: "EBS Storage Encryption can not be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__ebsStorageEncryption__c;
      }
      function extract12() { if (!this.out) { this.out = fieldChecked13(); } return this.out; };
      try {
          if (TextLib.notEqual(extract9.call(extract9), 'not-opted-in') && TextLib.equal(extract12.call(extract12), 'Disabled')) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__status__c') != 'not-opted-in' && extract('CA10__ebsStorageEncryption__c') == 'Disabled'", currentStateMessage: "Default encryption of EBS volume disabled for region", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function fieldChecked16() {
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__status__c.isEmpty()", currentStateMessage: "Account Region status must be specified ", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__status__c;
      }
      function extract15() { if (!this.out) { this.out = fieldChecked16(); } return this.out; };
      function fieldChecked19() {
          if (TextLib.isEmpty(obj.CA10__ebsStorageEncryption__c)) {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "CA10__ebsStorageEncryption__c.isEmpty()", currentStateMessage: "EBS Storage Encryption can not be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__ebsStorageEncryption__c;
      }
      function extract18() { if (!this.out) { this.out = fieldChecked19(); } return this.out; };
      try {
          if (TextLib.notEqual(extract15.call(extract15), 'not-opted-in') && TextLib.equal(extract18.call(extract18), 'Enabled')) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__status__c') != 'not-opted-in' && extract('CA10__ebsStorageEncryption__c') == 'Enabled'", currentStateMessage: "Default encryption of EBS volume enabled for region", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'INAPPLICABLE', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Region should be in-use.", 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.Id AS Id,
          `CA10__AWS_Account_Regions__r`.arr AS CA10__AWS_Account_Regions__r,
          process_CA10__CaAwsAccount__c(
              STRUCT(
                  sObject.Id AS Id,
                  `CA10__AWS_Account_Regions__r`.arr AS CA10__AWS_Account_Regions__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsAccount__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10__account__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10__status__c AS CA10__status__c,
                      sObject.CA10__ebsStorageEncryption__c AS CA10__ebsStorageEncryption__c,
                      sObject.CA10__account__c AS CA10__account__c,
                      process_CA10__AWS_Account_Regions__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10__status__c AS CA10__status__c,
                              sObject.CA10__ebsStorageEncryption__c AS CA10__ebsStorageEncryption__c,
                              sObject.CA10__account__c AS CA10__account__c
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsAccountRegion__c()) AS sObject
          GROUP BY sObject.CA10__account__c
      ) AS `CA10__AWS_Account_Regions__r`
          ON sObject.Id = `CA10__AWS_Account_Regions__r`.CA10__account__c
  ) sObject ON sObject.Id = expectedResult.Id;
