---
policy: /ce/ca/aws/autoscaling/group-and-classic-lb-inconsistent-azs
logic: /ce/ca/aws/autoscaling/group-and-classic-lb-inconsistent-azs/prod.logic.yaml
executionTime: 2025-04-24T23:44:24.090261611Z
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: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)
      actual: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)
      actual: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)
      actual: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)
      actual: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(COMPLIANT)
      actual: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(COMPLIANT)
    runtimeError: {}
  - id: test8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 500
      actual: 500
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test9
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(UNDETERMINED)
      actual: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(UNDETERMINED)
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/autoscaling/group-and-classic-lb-inconsistent-azs/policy.yaml
    md5Hash: 25E9AEDE7A1EBB869CBA366B98EB6EE3
    content: "---\nnames:\n  full: AWS EC2 Auto Scaling Group and Classic Load Balancer\
      \ AZs are inconsistent\n  contextual: Auto Scaling Group and Classic Load Balancer\
      \ AZs are inconsistent\ndescription: >\n  Ensure that AWS Auto Scaling Groups\
      \ (ASGs) and Classic Load Balancers (CLBs) \n  are configured to share the same\
      \ Availability Zones (AZs). This helps optimize \n  application performance\
      \ by utilizing AWS's low-latency network links across \n  the scaling environment.\n\
      categories:\n  - \"PERFORMANCE\"\n  - \"COST\"\ntype: \"COMPLIANCE_POLICY\"\n\
      frameworkMappings:\n  - \"/frameworks/cloudaware/resource-performance/performance-tuning\"\
      \n  - \"/frameworks/cloudaware/cost-efficiency-and-optimization/resource-optimization\"\
      \n"
  - path: /ce/ca/aws/autoscaling/group-and-classic-lb-inconsistent-azs/prod.logic.yaml
    md5Hash: 40CAA2A690FBF3082BE184F723A0EC4F
    content: |-
      ---
      inputType: "CA10__CaAwsAutoScalingGroup__c"
      testData:
        - file: "test-data.json"
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "The AGS is linked to a LB through the Target Group or\
            \ the Classic Load Balancer is not present is the CMDB."
          check:
            RELATED_LIST_HAS:
              relationshipName: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r"
              status: "INAPPLICABLE"
        - status: "INCOMPLIANT"
          currentStateMessage: "There is at least one incompliant related Classic Load Balancer."
          remediationMessage: "Consider updating the AZs for either the Load Balancer\
            \ or the Auto Scaling Group."
          check:
            RELATED_LIST_HAS:
              relationshipName: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r"
              status: "INCOMPLIANT"
        - status: "COMPLIANT"
          currentStateMessage: "Unable to determine if AZs match."
          check:
            RELATED_LIST_HAS:
              relationshipName: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r"
              status: "COMPLIANT"
        - status: "UNDETERMINED"
          currentStateMessage: "Unable to determine if AZs match."
          check:
            RELATED_LIST_HAS:
              relationshipName: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r"
              status: "UNDETERMINED"
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The Auto Scaling Group is not linked to an active Load Balancer."
      relatedLists:
        - relationshipName: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r"
          importExtracts:
            - file: /types/CA10__CaAwsAutoScalingGroup__c/object.extracts.yaml
            - file: /types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml
          conditions:
            - status: "INAPPLICABLE"
              currentStateMessage: "The AGS is linked to a LB through a Target Group or\
                \ the Classic Load Balancer is not present is the CMDB."
              check:
                IS_EMPTY_LOOKUP: "CA10__loadBalancer__r"
            - status: "INCOMPLIANT"
              currentStateMessage: "The set of Availability Zones configured on the Auto\
                \ Scaling Group does not match the set configured on Load Balancer."
              remediationMessage: "Adjust the set of Availability Zones either on the Auto\
                \ Scaling Group or the Load Balancer to match."
              check:
                NOT_EQUAL:
                  left:
                    EXTRACT: "CA10__autoScalingGroup__r.caExtract_availabilityZones_asCollection__c"
                  right:
                    EXTRACT: "CA10__loadBalancer__r.caExtract_availabilityZones_asCollection__c"
            - status: "COMPLIANT"
              currentStateMessage: "The set of Availability Zones configured on the Auto\
                \ Scaling Group matches the set configured on Load Balancer."
              check:
                IS_EQUAL:
                  left:
                    EXTRACT: "CA10__autoScalingGroup__r.caExtract_availabilityZones_asCollection__c"
                  right:
                    EXTRACT: "CA10__loadBalancer__r.caExtract_availabilityZones_asCollection__c"
          otherwise:
            status: "UNDETERMINED"
            currentStateMessage: "Unable to determine the AZs."
  - path: /ce/ca/aws/autoscaling/group-and-classic-lb-inconsistent-azs/test-data.json
    md5Hash: C6A46D7E236057B52D0EDF37A3A2154B
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-07T19:25:33Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2024-11-07T19:25:33Z",
              "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [
                  {
                      "Id": "test1_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__autoScalingGroup__c": "test1",
                      "CA10__autoScalingGroupArn__c": "autoScalingGroupArn1",
                      "CA10__autoScalingGroup__r": {
                          "Id": "test1",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1d\nus-east-1f"
                      },
                      "CA10__loadBalancer__c": "loadBalancer1",
                      "CA10__classicLoadBalancerArn__c": "loadBalancerArn1",
                      "CA10__loadBalancer__r": {
                          "Id": "loadBalancer1",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1d\nus-east-1f\nus-east-1e"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-07T19:25:33Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [
                  {
                      "Id": "test2_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__autoScalingGroup__c": "test2",
                      "CA10__autoScalingGroupArn__c": "autoScalingGroupArn2",
                      "CA10__loadBalancer__c": null,
                      "CA10__classicLoadBalancerArn__c": "loadBalancerArn2",
                      "CA10__autoScalingGroup__r": {
                          "Id": "test2",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1a\nus-east-1b\nus-east-1c"
                      },
                      "CA10__loadBalancer__r": {
                          "Id": null,
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": null
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-07T19:25:33Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [
                  {
                      "Id": "test3_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__autoScalingGroup__c": "test3",
                      "CA10__autoScalingGroupArn__c": "autoScalingGroupArn3",
                      "CA10__loadBalancer__c": null,
                      "CA10__classicLoadBalancerArn__c": null,
                      "CA10__autoScalingGroup__r": {
                          "Id": "test3",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1a\nus-east-1b\nus-east-1c"
                      },
                      "CA10__loadBalancer__r": {
                          "Id": null,
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": null
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-07T19:25:33Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [
                  {
                      "Id": "test4_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__autoScalingGroup__c": "test4",
                      "CA10__autoScalingGroupArn__c": "autoScalingGroupArn4",
                      "CA10__loadBalancer__c": "loadBalancer4",
                      "CA10__classicLoadBalancerArn__c": "loadBalancerArn4",
                      "CA10__autoScalingGroup__r": {
                          "Id": "test4",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1d"
                      },
                      "CA10__loadBalancer__r": {
                          "Id": "loadBalancer4",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1a"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-07T19:25:33Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [
                  {
                      "Id": "test5_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__autoScalingGroup__c": "test5",
                      "CA10__autoScalingGroupArn__c": "autoScalingGroupArn5",
                      "CA10__loadBalancer__c": "loadBalancer5",
                      "CA10__classicLoadBalancerArn__c": "loadBalancerArn5",
                      "CA10__autoScalingGroup__r": {
                          "Id": "test5",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1a\nus-east-1b"
                      },
                      "CA10__loadBalancer__r": {
                          "Id": "loadBalancer5",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1a\nus-east-1b\nus-east-1c"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-07T19:25:33Z"
              },
              "Id": "test7",
              "CA10__disappearanceTime__c": null,
              "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [
                  {
                      "Id": "test7_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__autoScalingGroup__c": "test7",
                      "CA10__autoScalingGroupArn__c": "autoScalingGroupArn7",
                      "CA10__autoScalingGroup__r": {
                          "Id": "test7",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1a\nus-east-1b\nus-east-1c"
                      },
                      "CA10__loadBalancer__c": "loadBalancer7",
                      "CA10__classicLoadBalancerArn__c": "loadBalancerArn7",
                      "CA10__loadBalancer__r": {
                          "Id": "loadBalancer7",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": "us-east-1a\nus-east-1b\nus-east-1c"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "500",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-07T19:25:33Z"
              },
              "Id": "test8",
              "CA10__disappearanceTime__c": null,
              "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": []
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "499",
                  "conditionText": "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(UNDETERMINED)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-07T19:25:33Z"
              },
              "Id": "test9",
              "CA10__disappearanceTime__c": null,
              "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [
                  {
                      "Id": "test9_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__autoScalingGroup__c": "test9",
                      "CA10__autoScalingGroupArn__c": "autoScalingGroupArn9",
                      "CA10__autoScalingGroup__r": {
                          "Id": "test9",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": null
                      },
                      "CA10__loadBalancer__c": "loadBalancer9",
                      "CA10__classicLoadBalancerArn__c": "loadBalancerArn9",
                      "CA10__loadBalancer__r": {
                          "Id": "loadBalancer9",
                          "CA10__disappearanceTime__c": null,
                          "CA10__availabilityZones__c": null
                      }
                  }

              ]
          }
      ]
  - path: /types/CA10__CaAwsAutoScalingGroup__c/object.extracts.yaml
    md5Hash: DD41D736933C31B7EA43278E6396A5FC
    content: "---\nextracts:\n  # AvailabilityZones.member.N\n  # One or more Availability\
      \ Zones for the group.\n  # Type: Array of strings\n  # Length Constraints:\
      \ Minimum length of 1. Maximum length of 255.\n  # Pattern: [\\u0020-\\uD7FF\\\
      uE000-\\uFFFD\\uD800\\uDC00-\\uDBFF\\uDFFF\\r\\n\\t]*\n  # Required: Yes\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: caExtract_availabilityZones_asCollection__c\n\
      \    value: \n      COLLECTION_FROM:\n        separator: \"\\n\"\n        arg:\n\
      \          EXTRACT: CA10__availabilityZones__c\n# A comma-separated value string\
      \ of one or more health check types.\n# Values: EC2, EBS, ELB, VPC_LATTICE.\
      \  Not nullable. Can't have no access, retrieved via autoscaling:DescribeAutoScalingGroups\n\
      \  - name: CA10__healthCheckType__c\n    value: \n      FIELD:\n        path:\
      \ CA10__healthCheckType__c          \n"
  - path: /types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml
    md5Hash: 9B0F1EF468082165E868C853B7DDD997
    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: caExtract_availabilityZones_asCollection__c\n    value: \n      COLLECTION_FROM:\n\
      \        separator: \"\\n\"\n        arg:\n          EXTRACT: CA10__availabilityZones__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" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "500",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test9",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "499",
      "conditionText" : "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(UNDETERMINED)",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsAutoScalingGroup__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__availabilityZones__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2024-11-07T19:25:33Z"),
    "CA10__availabilityZones__c" : "us-east-1d\nus-east-1f"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test2",
    "CA10__availabilityZones__c" : "us-east-1a\nus-east-1b\nus-east-1c"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test3",
    "CA10__availabilityZones__c" : "us-east-1a\nus-east-1b\nus-east-1c"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test4",
    "CA10__availabilityZones__c" : "us-east-1d"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test5",
    "CA10__availabilityZones__c" : "us-east-1a\nus-east-1b"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test7",
    "CA10__availabilityZones__c" : "us-east-1a\nus-east-1b\nus-east-1c"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test8"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test9",
    "CA10__availabilityZones__c" : null
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsAutoScalingGroupTrafficSourceLink__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__loadBalancer__c STRING,
      CA10__classicLoadBalancerArn__c STRING,
      CA10__autoScalingGroup__c STRING,
      CA10__autoScalingGroupArn__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test1_1",
    "CA10__loadBalancer__c" : "loadBalancer1",
    "CA10__classicLoadBalancerArn__c" : "loadBalancerArn1",
    "CA10__autoScalingGroup__c" : "test1",
    "CA10__autoScalingGroupArn__c" : "autoScalingGroupArn1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test2_1",
    "CA10__loadBalancer__c" : null,
    "CA10__classicLoadBalancerArn__c" : "loadBalancerArn2",
    "CA10__autoScalingGroup__c" : "test2",
    "CA10__autoScalingGroupArn__c" : "autoScalingGroupArn2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test3_1",
    "CA10__loadBalancer__c" : null,
    "CA10__classicLoadBalancerArn__c" : null,
    "CA10__autoScalingGroup__c" : "test3",
    "CA10__autoScalingGroupArn__c" : "autoScalingGroupArn3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test4_1",
    "CA10__loadBalancer__c" : "loadBalancer4",
    "CA10__classicLoadBalancerArn__c" : "loadBalancerArn4",
    "CA10__autoScalingGroup__c" : "test4",
    "CA10__autoScalingGroupArn__c" : "autoScalingGroupArn4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test5_1",
    "CA10__loadBalancer__c" : "loadBalancer5",
    "CA10__classicLoadBalancerArn__c" : "loadBalancerArn5",
    "CA10__autoScalingGroup__c" : "test5",
    "CA10__autoScalingGroupArn__c" : "autoScalingGroupArn5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test7_1",
    "CA10__loadBalancer__c" : "loadBalancer7",
    "CA10__classicLoadBalancerArn__c" : "loadBalancerArn7",
    "CA10__autoScalingGroup__c" : "test7",
    "CA10__autoScalingGroupArn__c" : "autoScalingGroupArn7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "test9_1",
    "CA10__loadBalancer__c" : "loadBalancer9",
    "CA10__classicLoadBalancerArn__c" : "loadBalancerArn9",
    "CA10__autoScalingGroup__c" : "test9",
    "CA10__autoScalingGroupArn__c" : "autoScalingGroupArn9"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancer__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__availabilityZones__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "loadBalancer1",
    "CA10__availabilityZones__c" : "us-east-1d\nus-east-1f\nus-east-1e"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : null,
    "CA10__availabilityZones__c" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "loadBalancer4",
    "CA10__availabilityZones__c" : "us-east-1a"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "loadBalancer5",
    "CA10__availabilityZones__c" : "us-east-1a\nus-east-1b\nus-east-1c"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "loadBalancer7",
    "CA10__availabilityZones__c" : "us-east-1a\nus-east-1b\nus-east-1c"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-07T19:25:33Z")
    },
    "Id" : "loadBalancer9",
    "CA10__availabilityZones__c" : null
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsAutoScalingGroup__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r ARRAY<STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__loadBalancer__c STRING,
              CA10__classicLoadBalancerArn__c STRING,
              CA10__autoScalingGroup__c STRING,
              CA10__autoScalingGroupArn__c STRING,
              CA10__loadBalancer__r STRUCT<
                  Id STRING,
                  CA10__disappearanceTime__c TIMESTAMP,
                  CA10__availabilityZones__c STRING
              >,
              CA10__autoScalingGroup__r STRUCT<
                  Id STRING,
                  CA10__disappearanceTime__c TIMESTAMP,
                  CA10__availabilityZones__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]
      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};
      }
      var count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_INAPPLICABLE2 = 0;
      if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r != null) {
          for (var i3 = 0; i3 < obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.length; i3++) {
              if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r[i3].result.status == 'INAPPLICABLE') {
                  count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_INAPPLICABLE2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r] ' + (count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_INAPPLICABLE2 > 0 ? 'has' : 'does not have') + ' objects in INAPPLICABLE status');
      if (count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_INAPPLICABLE2 > 0) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INAPPLICABLE)", currentStateMessage: "The AGS is linked to a LB through the Target Group or the Classic Load Balancer is not present is the CMDB.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_INCOMPLIANT4 = 0;
      if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r != null) {
          for (var i5 = 0; i5 < obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.length; i5++) {
              if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r[i5].result.status == 'INCOMPLIANT') {
                  count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_INCOMPLIANT4 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      if (count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_INCOMPLIANT4 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(INCOMPLIANT)", currentStateMessage: "There is at least one incompliant related Classic Load Balancer.", currentStateReferences: references1.join('\n'), remediation: "Consider updating the AZs for either the Load Balancer or the Auto Scaling Group.", runtimeError: null};
      }
      var count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_COMPLIANT6 = 0;
      if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r != null) {
          for (var i7 = 0; i7 < obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.length; i7++) {
              if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r[i7].result.status == 'COMPLIANT') {
                  count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_COMPLIANT6 += 1;
              }
          }
      }
      // condition[3], conditionIndex:[300..399]
      if (count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_COMPLIANT6 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(COMPLIANT)", currentStateMessage: "Unable to determine if AZs match.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_UNDETERMINED8 = 0;
      if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r != null) {
          for (var i9 = 0; i9 < obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.length; i9++) {
              if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r[i9].result.status == 'UNDETERMINED') {
                  count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_UNDETERMINED8 += 1;
              }
          }
      }
      // condition[4], conditionIndex:[400..499]
      if (count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_UNDETERMINED8 > 0) {
          return {status: 'UNDETERMINED', conditionIndex: 499, conditionText: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.has(UNDETERMINED)", currentStateMessage: "Unable to determine if AZs match.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "The Auto Scaling Group is not linked to an active Load Balancer.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__loadBalancer__c STRING,
          CA10__classicLoadBalancerArn__c STRING,
          CA10__autoScalingGroup__c STRING,
          CA10__autoScalingGroupArn__c STRING,
          CA10__loadBalancer__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__availabilityZones__c STRING
          >,
          CA10__autoScalingGroup__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__availabilityZones__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 CollectionLib = new function () {
          this.parse = function(arg, separator) {
              let out = new Set();
              if (arg == null) {
                  return out;
              }
              arg.split(separator).forEach(el => {if (TextLib.isNotEmpty(el)) {out.add(TextLib.normalize(el))}});
              return out;
          };
          this.fromArray = function(arr) {
              let out = new Set();
              if (arr == null) {
                  return out;
              }
              arr.forEach(el => {if (TextLib.isNotEmpty(el)) {out.add(TextLib.normalize(el))}});
              return out;
          };
          this.equal = function(left, right) {
              left = left == null ? new Set() : left;
              right = right == null ? new Set() : right;
              return left.size === right.size && new Set([...left, ...right]).size === left.size;
          };
          this.notEqual = function(left, right) {
              left = left == null ? new Set() : left;
              right = right == null ? new Set() : right;
              return left.size !== right.size || new Set([...left, ...right]).size !== left.size;
          };
          this.contains = function(collection, search) {
              if (collection == null || TextLib.isEmpty(search)) {
                  return false;
              }
              return collection.has(TextLib.normalize(search));
          };
          this.size = function(collection) {
              return collection == null ? 0 : collection.size;
          };
      }();
      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]
      if (TextLib.isEmpty(obj.CA10__classicLoadBalancerArn__c) || TextLib.isEmpty(obj.CA10__loadBalancer__c) || obj.CA10__loadBalancer__r.CA10__disappearanceTime__c != null) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "isEmptyLookup('CA10__loadBalancer__r')", currentStateMessage: "The AGS is linked to a LB through a Target Group or the Classic Load Balancer is not present is the CMDB.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extractChecked2() {
          if (TextLib.isEmpty(obj.CA10__autoScalingGroupArn__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extractCheck(obj.CA10__autoScalingGroupArn__c)", currentStateMessage: "Related object via CA10__autoScalingGroupArn__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__autoScalingGroup__c)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extractCheck(obj.CA10__autoScalingGroup__c)", currentStateMessage: "Related object via CA10__autoScalingGroup__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__autoScalingGroup__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extractCheck(obj.CA10__autoScalingGroup__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__autoScalingGroup__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract3.call(extract3);
      }
      function fieldChecked6() {
          if (TextLib.isEmpty(obj.CA10__autoScalingGroup__r.CA10__availabilityZones__c)) {
              throw new Error("UNDETERMINED condition:204", {cause: {status: 'UNDETERMINED', conditionIndex: 204, conditionText: "CA10__availabilityZones__c.isEmpty()", currentStateMessage: "Corrupted data. Availability zones should always present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__autoScalingGroup__r.CA10__availabilityZones__c;
      }
      function extract5() { if (!this.out) { this.out = fieldChecked6(); } return this.out; };
      function extract3() { if (!this.out) { this.out = CollectionLib.parse(extract5.call(extract5), '\n'); } return this.out; };
      function extractChecked8() {
          if (TextLib.isEmpty(obj.CA10__classicLoadBalancerArn__c)) {
              throw new Error("UNDETERMINED condition:205", {cause: {status: 'UNDETERMINED', conditionIndex: 205, conditionText: "extractCheck(obj.CA10__classicLoadBalancerArn__c)", currentStateMessage: "Related object via CA10__classicLoadBalancerArn__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__loadBalancer__c)) {
              throw new Error("UNDETERMINED condition:206", {cause: {status: 'UNDETERMINED', conditionIndex: 206, conditionText: "extractCheck(obj.CA10__loadBalancer__c)", currentStateMessage: "Related object via CA10__loadBalancer__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__loadBalancer__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:207", {cause: {status: 'UNDETERMINED', conditionIndex: 207, conditionText: "extractCheck(obj.CA10__loadBalancer__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__loadBalancer__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract9.call(extract9);
      }
      function fieldChecked12() {
          if (TextLib.isEmpty(obj.CA10__loadBalancer__r.CA10__availabilityZones__c)) {
              throw new Error("UNDETERMINED condition:208", {cause: {status: 'UNDETERMINED', conditionIndex: 208, conditionText: "CA10__availabilityZones__c.isEmpty()", currentStateMessage: "Corrupted data. Availability zones should always present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__loadBalancer__r.CA10__availabilityZones__c;
      }
      function extract11() { if (!this.out) { this.out = fieldChecked12(); } return this.out; };
      function extract9() { if (!this.out) { this.out = CollectionLib.parse(extract11.call(extract11), '\n'); } return this.out; };
      references1.push('Availability Zones [obj.CA10__autoScalingGroup__r.CA10__availabilityZones__c]: ' + obj.CA10__autoScalingGroup__r.CA10__availabilityZones__c);
      references1.push('Availability Zones [obj.CA10__loadBalancer__r.CA10__availabilityZones__c]: ' + obj.CA10__loadBalancer__r.CA10__availabilityZones__c);
      try {
          if (CollectionLib.notEqual(extractChecked2(), extractChecked8())) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__autoScalingGroup__r.caExtract_availabilityZones_asCollection__c') != extract('CA10__loadBalancer__r.caExtract_availabilityZones_asCollection__c')", currentStateMessage: "The set of Availability Zones configured on the Auto Scaling Group does not match the set configured on Load Balancer.", currentStateReferences: references1.join('\n'), remediation: "Adjust the set of Availability Zones either on the Auto Scaling Group or the Load Balancer to match.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function extractChecked14() {
          if (TextLib.isEmpty(obj.CA10__autoScalingGroupArn__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "extractCheck(obj.CA10__autoScalingGroupArn__c)", currentStateMessage: "Related object via CA10__autoScalingGroupArn__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__autoScalingGroup__c)) {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "extractCheck(obj.CA10__autoScalingGroup__c)", currentStateMessage: "Related object via CA10__autoScalingGroup__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__autoScalingGroup__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:303", {cause: {status: 'UNDETERMINED', conditionIndex: 303, conditionText: "extractCheck(obj.CA10__autoScalingGroup__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__autoScalingGroup__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract15.call(extract15);
      }
      function fieldChecked18() {
          if (TextLib.isEmpty(obj.CA10__autoScalingGroup__r.CA10__availabilityZones__c)) {
              throw new Error("UNDETERMINED condition:304", {cause: {status: 'UNDETERMINED', conditionIndex: 304, conditionText: "CA10__availabilityZones__c.isEmpty()", currentStateMessage: "Corrupted data. Availability zones should always present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__autoScalingGroup__r.CA10__availabilityZones__c;
      }
      function extract17() { if (!this.out) { this.out = fieldChecked18(); } return this.out; };
      function extract15() { if (!this.out) { this.out = CollectionLib.parse(extract17.call(extract17), '\n'); } return this.out; };
      function extractChecked20() {
          if (TextLib.isEmpty(obj.CA10__classicLoadBalancerArn__c)) {
              throw new Error("UNDETERMINED condition:305", {cause: {status: 'UNDETERMINED', conditionIndex: 305, conditionText: "extractCheck(obj.CA10__classicLoadBalancerArn__c)", currentStateMessage: "Related object via CA10__classicLoadBalancerArn__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__loadBalancer__c)) {
              throw new Error("UNDETERMINED condition:306", {cause: {status: 'UNDETERMINED', conditionIndex: 306, conditionText: "extractCheck(obj.CA10__loadBalancer__c)", currentStateMessage: "Related object via CA10__loadBalancer__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__loadBalancer__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:307", {cause: {status: 'UNDETERMINED', conditionIndex: 307, conditionText: "extractCheck(obj.CA10__loadBalancer__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__loadBalancer__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract21.call(extract21);
      }
      function fieldChecked24() {
          if (TextLib.isEmpty(obj.CA10__loadBalancer__r.CA10__availabilityZones__c)) {
              throw new Error("UNDETERMINED condition:308", {cause: {status: 'UNDETERMINED', conditionIndex: 308, conditionText: "CA10__availabilityZones__c.isEmpty()", currentStateMessage: "Corrupted data. Availability zones should always present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__loadBalancer__r.CA10__availabilityZones__c;
      }
      function extract23() { if (!this.out) { this.out = fieldChecked24(); } return this.out; };
      function extract21() { if (!this.out) { this.out = CollectionLib.parse(extract23.call(extract23), '\n'); } return this.out; };
      try {
          if (CollectionLib.equal(extractChecked14(), extractChecked20())) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__autoScalingGroup__r.caExtract_availabilityZones_asCollection__c') == extract('CA10__loadBalancer__r.caExtract_availabilityZones_asCollection__c')", currentStateMessage: "The set of Availability Zones configured on the Auto Scaling Group matches the set configured on Load Balancer.", 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: 400, conditionText: "otherwise", currentStateMessage: "Unable to determine the AZs.", 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,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          `CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r`.arr AS CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r,
          process_CA10__CaAwsAutoScalingGroup__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  `CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r`.arr AS CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsAutoScalingGroup__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10__autoScalingGroup__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__loadBalancer__c AS CA10__loadBalancer__c,
                      sObject.CA10__classicLoadBalancerArn__c AS CA10__classicLoadBalancerArn__c,
                      sObject.CA10__autoScalingGroup__c AS CA10__autoScalingGroup__c,
                      sObject.CA10__autoScalingGroupArn__c AS CA10__autoScalingGroupArn__c,
                      STRUCT (
                          `CA10__loadBalancer__r`.Id AS Id,
                          `CA10__loadBalancer__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                          `CA10__loadBalancer__r`.CA10__availabilityZones__c AS CA10__availabilityZones__c
                      ) AS CA10__loadBalancer__r,
                      STRUCT (
                          `CA10__autoScalingGroup__r`.Id AS Id,
                          `CA10__autoScalingGroup__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                          `CA10__autoScalingGroup__r`.CA10__availabilityZones__c AS CA10__availabilityZones__c
                      ) AS CA10__autoScalingGroup__r,
                      process_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__loadBalancer__c AS CA10__loadBalancer__c,
                              sObject.CA10__classicLoadBalancerArn__c AS CA10__classicLoadBalancerArn__c,
                              sObject.CA10__autoScalingGroup__c AS CA10__autoScalingGroup__c,
                              sObject.CA10__autoScalingGroupArn__c AS CA10__autoScalingGroupArn__c,
                              STRUCT (
                                  `CA10__loadBalancer__r`.Id AS Id,
                                  `CA10__loadBalancer__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                                  `CA10__loadBalancer__r`.CA10__availabilityZones__c AS CA10__availabilityZones__c
                              ) AS CA10__loadBalancer__r,
                              STRUCT (
                                  `CA10__autoScalingGroup__r`.Id AS Id,
                                  `CA10__autoScalingGroup__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                                  `CA10__autoScalingGroup__r`.CA10__availabilityZones__c AS CA10__availabilityZones__c
                              ) AS CA10__autoScalingGroup__r
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsAutoScalingGroupTrafficSourceLink__c()) AS sObject
          LEFT JOIN UNNEST(mock_CA10__CaAwsLoadBalancer__c()) AS `CA10__loadBalancer__r`
              ON sObject.CA10__loadBalancer__c = `CA10__loadBalancer__r`.Id
          LEFT JOIN UNNEST(mock_CA10__CaAwsAutoScalingGroup__c()) AS `CA10__autoScalingGroup__r`
              ON sObject.CA10__autoScalingGroup__c = `CA10__autoScalingGroup__r`.Id
          GROUP BY sObject.CA10__autoScalingGroup__c
      ) AS `CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r`
          ON sObject.Id = `CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r`.CA10__autoScalingGroup__c
  ) sObject ON sObject.Id = expectedResult.Id;
