---
policy: /ce/ca/aws/elb/load-balancer-cross-zone
logic: /ce/ca/aws/elb/load-balancer-cross-zone/prod.logic.yaml
executionTime: 2025-10-18T12:01:40.979092897Z
generationMs: 88
executionMs: 646
rows:
  - id: test1
    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: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c')
        == false
      actual: extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c')
        == false
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c')
        == true
      actual: extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c')
        == true
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: "(extract('CA10__type__c') == 'network' || extract('CA10__type__c')\
        \ == 'gateway') && extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled:\
        \ false')"
      actual: "(extract('CA10__type__c') == 'network' || extract('CA10__type__c')\
        \ == 'gateway') && extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled:\
        \ false')"
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(INCOMPLIANT)
      actual: extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(COMPLIANT)
      actual: extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(COMPLIANT)
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 699
      actual: 699
    conditionText:
      expected: "extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled:\
        \ true')"
      actual: "extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled:\
        \ true')"
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/elb/load-balancer-cross-zone/policy.yaml
    md5Hash: 4394C90B0B38FFF9BBF151C957630904
    content: "---\nnames:\n  full: \"AWS ELB Load Balancer Cross-Zone Load Balancing\
      \ is not enabled\"\n  contextual: \"Load Balancer Cross-Zone Load Balancing\
      \ is not enabled\"\ndescription: >\n  Ensures that AWS ELB Load Balancers have\
      \ cross-zone load balancing enabled to \n  distribute traffic evenly across\
      \ all registered instances in all enabled \n  Availability Zones.\ntype: \"\
      COMPLIANCE_POLICY\"\ncategories:\n  - \"RELIABILITY\"\n  - \"PERFORMANCE\"\n\
      frameworkMappings:\n  - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\
      \n  - \"/frameworks/cloudaware/resource-performance/performance-tuning\"\n \
      \ - \"/frameworks/aws-well-architected/perf/04/04\"\n  - \"/frameworks/aws-fsbp-v1.0.0/elb/09\"\
      \nsimilarPolicies:\n  awsSecurityHub:\n    - name: \"[ELB.9] Classic Load Balancers\
      \ should have cross-zone load balancing enabled\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/elb-controls.html#elb-9\""
  - path: /ce/ca/aws/elb/load-balancer-cross-zone/prod.logic.yaml
    md5Hash: 7E292DBE6E0B64F5059AB332786F14DF
    content: |-
      ---
      inputType: "CA10__CaAwsLoadBalancer__c"
      importExtracts:
        - file: "/types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml"
      # recordTypes:
      #   - "caAwsLoadBalancerApplication"
      #   - "caAwsLoadBalancerClassic"
      testData:
        - file: "test-data.json"
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "Cross-zone load balancing is disabled for this Classic Load Balancer."
          remediationMessage: "Enable cross-zone load balancing in the Load Balancer's attributes."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__type__c"
                    right:
                      TEXT: "classic"
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__crossZoneLoadBalancing__c"
                    right:
                      BOOLEAN: false
        - status: "COMPLIANT"
          currentStateMessage: "Cross-zone load balancing is enabled for this Classic Load Balancer."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__type__c"
                    right:
                      TEXT: "classic"
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__crossZoneLoadBalancing__c"
                    right:
                      BOOLEAN: true
        - status: "INCOMPLIANT"
          currentStateMessage: "Cross-zone load balancing is disabled for this Load Balancer."
          remediationMessage: "Enable the 'load_balancing.cross_zone.enabled' attribute for the Load Balancer."
          check:
            AND:
              args:
                - OR:
                    args:
                      - IS_EQUAL:
                          left:
                            EXTRACT: "CA10__type__c"
                          right:
                            TEXT: "network"
                      - IS_EQUAL:
                          left:
                            EXTRACT: "CA10__type__c"
                          right:
                            TEXT: "gateway"
                - CONTAINS:
                    arg:
                      EXTRACT: "caSetFrom_additionalAttributes__c"
                    search:
                      TEXT: "load_balancing.cross_zone.enabled: false"
        - status: "INCOMPLIANT"
          currentStateMessage: "Cross-zone load balancing is disabled on at least one\
            \ of the target groups associated with this Application Load Balancer."
          remediationMessage: "Enable the 'load_balancing.cross_zone.enabled' attribute\
            \ for all associated target groups."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__type__c"
                    right:
                      TEXT: "application"
                - RELATED_LIST_HAS:
                    status: "INCOMPLIANT"
                    relationshipName: "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r"
        - status: "COMPLIANT"
          currentStateMessage: "Cross-zone load balancing is enabled for this Load Balancer."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__type__c"
                    right:
                      TEXT: "application"
                - RELATED_LIST_HAS:
                    status: "COMPLIANT"
                    relationshipName: "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r"
        - status: "COMPLIANT"
          currentStateMessage: "Cross-zone load balancing is enabled for this Load Balancer."
          check:
            CONTAINS:
              arg:
                EXTRACT: "caSetFrom_additionalAttributes__c"
              search:
                TEXT: "load_balancing.cross_zone.enabled: true"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected values in the fields."
      relatedLists:
        - relationshipName: "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r"
          importExtracts:
            - file: /types/CA10__CaAwsLoadBalancerTargetGroup__c/object.extracts.yaml
          conditions:
            - status: "INCOMPLIANT"
              currentStateMessage: "The 'load_balancing.cross_zone.enabled' attribute is set to 'false' on this target group."
              remediationMessage: "Enable cross-zone load balancing for this target group."
              check:
                CONTAINS:
                  arg:
                    EXTRACT: "CA10__targetGroup__r.caSetFrom_attributes__c"
                  search:
                    TEXT: "load_balancing.cross_zone.enabled: false"
            - status: "COMPLIANT"
              currentStateMessage: "The 'load_balancing.cross_zone.enabled' attribute is set to 'true'."
              check:
                CONTAINS_ANY:
                  arg:
                    EXTRACT: "CA10__targetGroup__r.caSetFrom_attributes__c"
                  search:
                    SET:
                      itemType: TEXT
                      items:
                        - "load_balancing.cross_zone.enabled: true"
                        - "load_balancing.cross_zone.enabled: use_load_balancer_configuration"
          otherwise:
            status: "UNDETERMINED"
            currentStateMessage: "The 'load_balancing.cross_zone.enabled' attribute does not exist."
  - path: /ce/ca/aws/elb/load-balancer-cross-zone/test-data.json
    md5Hash: 24E3F6B8FC84E764DFD3A3AA352FA216
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-14T08:05:54Z"
              },
              "CA10__disappearanceTime__c": "2025-10-09T18:15:30Z",
              "CA10__type__c": "network",
              "CA10__crossZoneLoadBalancing__c": false,
              "CA10__additionalAttributes__c": "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: false",
              "Id": "test1",
              "RecordTypeId": "RecordTypeId1",
              "RecordType": {
                  "Id": "RecordTypeId1"
              },
              "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c') == false",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-14T08:05:54Z"
              },
              "CA10__disappearanceTime__c": null,
              "CA10__type__c": "classic",
              "CA10__crossZoneLoadBalancing__c": false,
              "CA10__additionalAttributes__c": "elb.http.desyncmitigationmode: defensive",
              "Id": "test2",
              "RecordTypeId": "RecordTypeId2",
              "RecordType": {
                  "Id": "RecordTypeId2"
              },
              "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r": []
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c') == true",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-14T08:05:54Z"
              },
              "CA10__disappearanceTime__c": null,
              "CA10__type__c": "classic",
              "CA10__crossZoneLoadBalancing__c": true,
              "CA10__additionalAttributes__c": "elb.http.desyncmitigationmode: defensive",
              "Id": "test3",
              "RecordTypeId": "RecordTypeId2",
              "RecordType": {
                  "Id": "RecordTypeId2"
              },
              "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "(extract('CA10__type__c') == 'network' || extract('CA10__type__c') == 'gateway') && extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled: false')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-14T08:05:54Z"
              },
              "CA10__disappearanceTime__c": null,
              "CA10__type__c": "network",
              "CA10__crossZoneLoadBalancing__c": false,
              "CA10__additionalAttributes__c": "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: false",
              "Id": "test4",
              "RecordTypeId": "RecordTypeId1",
              "RecordType": {
                  "Id": "RecordTypeId1"
              },
              "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-14T08:05:54Z"
              },
              "CA10__disappearanceTime__c": null,
              "CA10__type__c": "application",
              "CA10__crossZoneLoadBalancing__c": false,
              "CA10__additionalAttributes__c": "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: true",
              "Id": "test5",
              "RecordTypeId": "RecordTypeId1",
              "RecordType": {
                  "Id": "RecordTypeId1"
              },
              "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r": [
                  {
                      "CA10__disappearanceTime__c": null,
                      "CA10__targetGroup__c": "test5_1",
                      "CA10__targetGroupArn__c": "targetGroupArn",
                      "CA10__loadBalancer__c": "test5",
                      "Id": "test5_2",
                      "CA10__targetGroup__r": {
                          "Id": "test5_1",
                          "CA10__disappearanceTime__c": null,
                          "CA10__attributes__c": "load_balancing.algorithm.type: round_robin\nload_balancing.cross_zone.enabled: false"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-14T08:05:54Z"
              },
              "CA10__disappearanceTime__c": null,
              "CA10__type__c": "application",
              "CA10__crossZoneLoadBalancing__c": false,
              "CA10__additionalAttributes__c": "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: true",
              "Id": "test6",
              "RecordTypeId": "RecordTypeId1",
              "RecordType": {
                  "Id": "RecordTypeId1"
              },
              "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r": [
                  {
                      "CA10__disappearanceTime__c": null,
                      "CA10__targetGroup__c": "test6_1",
                      "CA10__targetGroupArn__c": "targetGroupArn",
                      "CA10__loadBalancer__c": "test6",
                      "Id": "test6_2",
                      "CA10__targetGroup__r": {
                          "Id": "test6_1",
                          "CA10__disappearanceTime__c": null,
                          "CA10__attributes__c": "load_balancing.algorithm.type: round_robin\nload_balancing.cross_zone.enabled: true"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "699",
                  "conditionText": "extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled: true')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-14T08:05:54Z"
              },
              "CA10__disappearanceTime__c": null,
              "CA10__type__c": "application",
              "CA10__crossZoneLoadBalancing__c": false,
              "CA10__additionalAttributes__c": "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: true",
              "Id": "test7",
              "RecordTypeId": "RecordTypeId1",
              "RecordType": {
                  "Id": "RecordTypeId1"
              },
              "CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r": []
          }
      ]
  - path: /types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml
    md5Hash: 7D6D518BF9242B273982FC96DEB57121
    content: "---\nextracts:\n  # The subnets for the load balancer.\n  # Type: Array\
      \ of AvailabilityZone objects\n  # Required: No\n  # \n  # apparently it could\
      \ be empty according to documentation, but I don't believe so and can't find\
      \ any LB without AZs\n  - name: CA10__availabilityZones__c\n    value: \n  \
      \    FIELD:\n        path: CA10__availabilityZones__c\n        undeterminedIf:\n\
      \          isEmpty: Corrupted data. Availability zones should always present\n\
      \  - name: caSetFrom_availabilityZones__c\n    value: \n      SET_FROM:\n  \
      \      separator: \"\\n\"\n        arg:\n          EXTRACT: CA10__availabilityZones__c\n\
      # Checkbox for Classic load balancer record type.\n  - name: CA10__crossZoneLoadBalancing__c\n\
      \    value: \n      FIELD:\n        path: CA10__crossZoneLoadBalancing__c\n\
      # Values: classic | application | network | gateway. Not nullable\n  - name:\
      \ CA10__type__c\n    value: \n      FIELD:\n        path: CA10__type__c\n  \
      \      undeterminedIf:\n          isEmpty: \"Corrupted data. Load Balancer Type\
      \ cannot be empty.\"\n  - name: CA10__additionalAttributes__c\n    value: \n\
      \      FIELD:\n        path: CA10__additionalAttributes__c\n  - name: caSetFrom_additionalAttributes__c\n\
      \    value: \n      SET_FROM:\n        separator: \"\\n\"\n        arg:\n  \
      \        EXTRACT: CA10__additionalAttributes__c\n"
  - path: /types/CA10__CaAwsLoadBalancerTargetGroup__c/object.extracts.yaml
    md5Hash: 8BCADEB8A83A60F6076714BAB02A79AF
    content: "---\nextracts:\n  - name: CA10__attributes__c\n    value: \n      FIELD:\n\
      \        path: CA10__attributes__c\n  - name: caSetFrom_attributes__c\n    value:\
      \ \n      SET_FROM:\n        separator: \"\\n\"\n        arg:\n          EXTRACT:\
      \ CA10__attributes__c\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" : "test1",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c') == false",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c') == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "(extract('CA10__type__c') == 'network' || extract('CA10__type__c') == 'gateway') && extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled: false')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "699",
      "conditionText" : "extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled: true')",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancer__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__type__c STRING,
      CA10__crossZoneLoadBalancing__c BOOLEAN,
      CA10__additionalAttributes__c STRING,
      Id STRING,
      RecordTypeId STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__disappearanceTime__c" : new Date("2025-10-09T18:15:30Z"),
    "CA10__type__c" : "network",
    "CA10__crossZoneLoadBalancing__c" : false,
    "CA10__additionalAttributes__c" : "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: false",
    "Id" : "test1",
    "RecordTypeId" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__type__c" : "classic",
    "CA10__crossZoneLoadBalancing__c" : false,
    "CA10__additionalAttributes__c" : "elb.http.desyncmitigationmode: defensive",
    "Id" : "test2",
    "RecordTypeId" : "RecordTypeId2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__type__c" : "classic",
    "CA10__crossZoneLoadBalancing__c" : true,
    "CA10__additionalAttributes__c" : "elb.http.desyncmitigationmode: defensive",
    "Id" : "test3",
    "RecordTypeId" : "RecordTypeId2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__type__c" : "network",
    "CA10__crossZoneLoadBalancing__c" : false,
    "CA10__additionalAttributes__c" : "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: false",
    "Id" : "test4",
    "RecordTypeId" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__type__c" : "application",
    "CA10__crossZoneLoadBalancing__c" : false,
    "CA10__additionalAttributes__c" : "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: true",
    "Id" : "test5",
    "RecordTypeId" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__type__c" : "application",
    "CA10__crossZoneLoadBalancing__c" : false,
    "CA10__additionalAttributes__c" : "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: true",
    "Id" : "test6",
    "RecordTypeId" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__type__c" : "application",
    "CA10__crossZoneLoadBalancing__c" : false,
    "CA10__additionalAttributes__c" : "access_logs.s3.enabled: false\nload_balancing.cross_zone.enabled: true",
    "Id" : "test7",
    "RecordTypeId" : "RecordTypeId1"
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "Id" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "Id" : "RecordTypeId2"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancerTargetGroupLink__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__targetGroup__c STRING,
      CA10__targetGroupArn__c STRING,
      CA10__loadBalancer__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__targetGroup__c" : "test5_1",
    "CA10__targetGroupArn__c" : "targetGroupArn",
    "CA10__loadBalancer__c" : "test5",
    "Id" : "test5_2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "CA10__targetGroup__c" : "test6_1",
    "CA10__targetGroupArn__c" : "targetGroupArn",
    "CA10__loadBalancer__c" : "test6",
    "Id" : "test6_2"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancerTargetGroup__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__attributes__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "Id" : "test5_1",
    "CA10__attributes__c" : "load_balancing.algorithm.type: round_robin\nload_balancing.cross_zone.enabled: false"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-14T08:05:54Z")
    },
    "Id" : "test6_1",
    "CA10__attributes__c" : "load_balancing.algorithm.type: round_robin\nload_balancing.cross_zone.enabled: true"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsLoadBalancer__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__type__c STRING,
          CA10__crossZoneLoadBalancing__c BOOLEAN,
          CA10__additionalAttributes__c STRING,
          Id STRING,
          RecordTypeId STRING,
          RecordType STRUCT<
              Id STRING
          >,
          CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r ARRAY<STRUCT<
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__targetGroup__c STRING,
              CA10__targetGroupArn__c STRING,
              CA10__loadBalancer__c STRING,
              Id STRING,
              CA10__targetGroup__r STRUCT<
                  Id STRING,
                  CA10__disappearanceTime__c TIMESTAMP,
                  CA10__attributes__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 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 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 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 fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__type__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__type__c.isEmpty()", currentStateMessage: "Corrupted data. Load Balancer Type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__type__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      function extract6() { if (!this.out) { this.out = obj.CA10__crossZoneLoadBalancing__c; } return this.out; };
      references1.push('Type [obj.CA10__type__c]: ' + obj.CA10__type__c);
      references1.push('Cross-Zone Load Balancing [obj.CA10__crossZoneLoadBalancing__c]: ' + obj.CA10__crossZoneLoadBalancing__c);
      try {
          if (TextLib.equal(extract3.call(extract3), 'classic') && extract6.call(extract6) == false) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c') == false", currentStateMessage: "Cross-zone load balancing is disabled for this Classic Load Balancer.", currentStateReferences: references1.join('\n'), remediation: "Enable cross-zone load balancing in the Load Balancer's attributes.", 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__type__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__type__c.isEmpty()", currentStateMessage: "Corrupted data. Load Balancer Type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__type__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      function extract12() { if (!this.out) { this.out = obj.CA10__crossZoneLoadBalancing__c; } return this.out; };
      try {
          if (TextLib.equal(extract9.call(extract9), 'classic') && extract12.call(extract12) == true) {
              return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__type__c') == 'classic' && extract('CA10__crossZoneLoadBalancing__c') == true", currentStateMessage: "Cross-zone load balancing is enabled for this Classic Load Balancer.", 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__type__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__type__c.isEmpty()", currentStateMessage: "Corrupted data. Load Balancer Type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__type__c;
      }
      function extract15() { if (!this.out) { this.out = fieldChecked16(); } return this.out; };
      function extract21() { if (!this.out) { this.out = obj.CA10__additionalAttributes__c; } return this.out; };
      function extract19() { if (!this.out) { this.out = CollectionLib.parse(extract21.call(extract21), '\n', true, true, true, true); } return this.out; };
      references1.push('Additional Attributes [obj.CA10__additionalAttributes__c]: ' + obj.CA10__additionalAttributes__c);
      try {
          if ((TextLib.equal(extract15.call(extract15), 'network') || TextLib.equal(extract15.call(extract15), 'gateway')) && CollectionLib.contains(extract19.call(extract19), 'load_balancing.cross_zone.enabled: false', true)) {
              return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "(extract('CA10__type__c') == 'network' || extract('CA10__type__c') == 'gateway') && extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled: false')", currentStateMessage: "Cross-zone load balancing is disabled for this Load Balancer.", currentStateReferences: references1.join('\n'), remediation: "Enable the 'load_balancing.cross_zone.enabled' attribute for the Load Balancer.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      var count_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r_INCOMPLIANT27 = 0;
      if (obj.CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r != null) {
          for (var i28 = 0; i28 < obj.CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.length; i28++) {
              if (obj.CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r[i28].result.status == 'INCOMPLIANT') {
                  count_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r_INCOMPLIANT27 += 1;
              }
          }
      }
      // condition[4], conditionIndex:[400..499]
      function fieldChecked26() {
          if (TextLib.isEmpty(obj.CA10__type__c)) {
              throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "CA10__type__c.isEmpty()", currentStateMessage: "Corrupted data. Load Balancer Type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__type__c;
      }
      function extract25() { if (!this.out) { this.out = fieldChecked26(); } return this.out; };
      references1.push('Related list [CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r] ' + (count_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r_INCOMPLIANT27 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      try {
          if (TextLib.equal(extract25.call(extract25), 'application') && count_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r_INCOMPLIANT27 > 0) {
              return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(INCOMPLIANT)", currentStateMessage: "Cross-zone load balancing is disabled on at least one of the target groups associated with this Application Load Balancer.", currentStateReferences: references1.join('\n'), remediation: "Enable the 'load_balancing.cross_zone.enabled' attribute for all associated target groups.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      var count_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r_COMPLIANT32 = 0;
      if (obj.CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r != null) {
          for (var i33 = 0; i33 < obj.CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.length; i33++) {
              if (obj.CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r[i33].result.status == 'COMPLIANT') {
                  count_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r_COMPLIANT32 += 1;
              }
          }
      }
      // condition[5], conditionIndex:[500..599]
      function fieldChecked31() {
          if (TextLib.isEmpty(obj.CA10__type__c)) {
              throw new Error("UNDETERMINED condition:501", {cause: {status: 'UNDETERMINED', conditionIndex: 501, conditionText: "CA10__type__c.isEmpty()", currentStateMessage: "Corrupted data. Load Balancer Type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__type__c;
      }
      function extract30() { if (!this.out) { this.out = fieldChecked31(); } return this.out; };
      try {
          if (TextLib.equal(extract30.call(extract30), 'application') && count_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r_COMPLIANT32 > 0) {
              return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "extract('CA10__type__c') == 'application' && CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r.has(COMPLIANT)", currentStateMessage: "Cross-zone load balancing is enabled for this Load Balancer.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[6], conditionIndex:[600..699]
      function extract37() { if (!this.out) { this.out = obj.CA10__additionalAttributes__c; } return this.out; };
      function extract35() { if (!this.out) { this.out = CollectionLib.parse(extract37.call(extract37), '\n', true, true, true, true); } return this.out; };
      if (CollectionLib.contains(extract35.call(extract35), 'load_balancing.cross_zone.enabled: true', true)) {
          return {status: 'COMPLIANT', conditionIndex: 699, conditionText: "extract('caSetFrom_additionalAttributes__c').contains('load_balancing.cross_zone.enabled: true')", currentStateMessage: "Cross-zone load balancing is enabled for this Load Balancer.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 700, conditionText: "otherwise", currentStateMessage: "Unexpected values in the fields.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__targetGroup__c STRING,
          CA10__targetGroupArn__c STRING,
          CA10__loadBalancer__c STRING,
          Id STRING,
          CA10__targetGroup__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__attributes__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 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 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 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 extractChecked2() {
          if (TextLib.isEmpty(obj.CA10__targetGroupArn__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "extractCheck(obj.CA10__targetGroupArn__c)", currentStateMessage: "Related object via CA10__targetGroupArn__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__targetGroup__c)) {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "extractCheck(obj.CA10__targetGroup__c)", currentStateMessage: "Related object via CA10__targetGroup__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__targetGroup__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:103", {cause: {status: 'UNDETERMINED', conditionIndex: 103, conditionText: "extractCheck(obj.CA10__targetGroup__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__targetGroup__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract3.call(extract3);
      }
      function extract5() { if (!this.out) { this.out = obj.CA10__targetGroup__r.CA10__attributes__c; } return this.out; };
      function extract3() { if (!this.out) { this.out = CollectionLib.parse(extract5.call(extract5), '\n', true, true, true, true); } return this.out; };
      references1.push('Attributes [obj.CA10__targetGroup__r.CA10__attributes__c]: ' + obj.CA10__targetGroup__r.CA10__attributes__c);
      try {
          if (CollectionLib.contains(extractChecked2(), 'load_balancing.cross_zone.enabled: false', true)) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__targetGroup__r.caSetFrom_attributes__c').contains('load_balancing.cross_zone.enabled: false')", currentStateMessage: "The 'load_balancing.cross_zone.enabled' attribute is set to 'false' on this target group.", currentStateReferences: references1.join('\n'), remediation: "Enable cross-zone load balancing for this target group.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function extractChecked8() {
          if (TextLib.isEmpty(obj.CA10__targetGroupArn__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extractCheck(obj.CA10__targetGroupArn__c)", currentStateMessage: "Related object via CA10__targetGroupArn__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__targetGroup__c)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extractCheck(obj.CA10__targetGroup__c)", currentStateMessage: "Related object via CA10__targetGroup__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__targetGroup__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extractCheck(obj.CA10__targetGroup__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__targetGroup__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract9.call(extract9);
      }
      function extract11() { if (!this.out) { this.out = obj.CA10__targetGroup__r.CA10__attributes__c; } return this.out; };
      function extract9() { if (!this.out) { this.out = CollectionLib.parse(extract11.call(extract11), '\n', true, true, true, true); } return this.out; };
      try {
          if (CollectionLib.containsAny(extractChecked8(), CollectionLib.fromArray(['load_balancing.cross_zone.enabled: true', 'load_balancing.cross_zone.enabled: use_load_balancer_configuration'], true, true, true, true), true)) {
              return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__targetGroup__r.caSetFrom_attributes__c').containsAny(setOfText(['load_balancing.cross_zone.enabled: true', 'load_balancing.cross_zone.enabled: use_load_balancer_configuration']))", currentStateMessage: "The 'load_balancing.cross_zone.enabled' attribute is set to 'true'.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'UNDETERMINED', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The 'load_balancing.cross_zone.enabled' attribute does not exist.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__type__c AS CA10__type__c,
          sObject.CA10__crossZoneLoadBalancing__c AS CA10__crossZoneLoadBalancing__c,
          sObject.CA10__additionalAttributes__c AS CA10__additionalAttributes__c,
          sObject.Id AS Id,
          sObject.RecordTypeId AS RecordTypeId,
          STRUCT (
              `RecordType`.Id AS Id
          ) AS RecordType,
          `CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r`.arr AS CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r,
          process_CA10__CaAwsLoadBalancer__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__type__c AS CA10__type__c,
                  sObject.CA10__crossZoneLoadBalancing__c AS CA10__crossZoneLoadBalancing__c,
                  sObject.CA10__additionalAttributes__c AS CA10__additionalAttributes__c,
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  STRUCT (
                      `RecordType`.Id AS Id
                  ) AS RecordType,
                  `CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r`.arr AS CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsLoadBalancer__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
      LEFT JOIN (
          SELECT
              sObject.CA10__loadBalancer__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__targetGroup__c AS CA10__targetGroup__c,
                      sObject.CA10__targetGroupArn__c AS CA10__targetGroupArn__c,
                      sObject.CA10__loadBalancer__c AS CA10__loadBalancer__c,
                      sObject.Id AS Id,
                      STRUCT (
                          `CA10__targetGroup__r`.Id AS Id,
                          `CA10__targetGroup__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                          `CA10__targetGroup__r`.CA10__attributes__c AS CA10__attributes__c
                      ) AS CA10__targetGroup__r,
                      process_CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r(
                          STRUCT(
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__targetGroup__c AS CA10__targetGroup__c,
                              sObject.CA10__targetGroupArn__c AS CA10__targetGroupArn__c,
                              sObject.CA10__loadBalancer__c AS CA10__loadBalancer__c,
                              sObject.Id AS Id,
                              STRUCT (
                                  `CA10__targetGroup__r`.Id AS Id,
                                  `CA10__targetGroup__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                                  `CA10__targetGroup__r`.CA10__attributes__c AS CA10__attributes__c
                              ) AS CA10__targetGroup__r
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsLoadBalancerTargetGroupLink__c()) AS sObject
          LEFT JOIN UNNEST(mock_CA10__CaAwsLoadBalancerTargetGroup__c()) AS `CA10__targetGroup__r`
              ON sObject.CA10__targetGroup__c = `CA10__targetGroup__r`.Id
          GROUP BY sObject.CA10__loadBalancer__c
      ) AS `CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r`
          ON sObject.Id = `CA10__AWS_EC2_Load_Balancer_Target_Group_Links__r`.CA10__loadBalancer__c
  ) sObject ON sObject.Id = expectedResult.Id;
