---
policy: /ce/ca/aws/cloudfront/distribution-traffic-encryption-to-custom-origins
logic: /ce/ca/aws/cloudfront/distribution-traffic-encryption-to-custom-origins/prod.logic.yaml
executionTime: 2025-07-08T23:23:03.694894804Z
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: "not(setOfText(['caWebDistribution']).contains(RecordType.DeveloperName))"
      actual: "not(setOfText(['caWebDistribution']).contains(RecordType.DeveloperName))"
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_CloudFront_Origins__r.has(INCOMPLIANT)
      actual: CA10__AWS_CloudFront_Origins__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && CA10__AWS_CloudFront_Cache_Behaviors__r.has(INCOMPLIANT)
      actual: CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && CA10__AWS_CloudFront_Cache_Behaviors__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && extract('CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c')
        == 'allow-all'
      actual: CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && extract('CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c')
        == 'allow-all'
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 700
      actual: 700
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 699
      actual: 699
    conditionText:
      expected: CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED)
        && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)
      actual: CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED)
        && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)
    runtimeError: {}
  - id: test8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 700
      actual: 700
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test9
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: isEmptyLookup('CA10__defaultCacheBehavior__r')
      actual: isEmptyLookup('CA10__defaultCacheBehavior__r')
    runtimeError: {}
  - id: test10
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 699
      actual: 699
    conditionText:
      expected: CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED)
        && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)
      actual: CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED)
        && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/cloudfront/distribution-traffic-encryption-to-custom-origins/policy.yaml
    md5Hash: 30DBBDAE30867E248F1CCDC696DA0FA7
    content: "---\nnames:\n  full: AWS CloudFront Web Distribution does not encrypt\
      \ traffic to Custom Origins\n  contextual: Web Distribution does not encrypt\
      \ traffic to Custom Origins\ndescription: >\n  Ensure that CloudFront Distributions\
      \ are configured to use connections over \n  HTTPS when communicating with custom\
      \ origins.\ncategories:\n  - \"SECURITY\"\ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/resource-security/data-encryption\"\n  - \"/frameworks/aws-fsbp-v1.0.0/cloudfront/09\"\
      \nsimilarPolicies:\n  awsSecurityHub:\n    - name: \"[CloudFront.9] CloudFront\
      \ distributions should encrypt traffic to custom origins\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/cloudfront-controls.html#cloudfront-9\"\
      \n  internal:\n    - \"dec-x-3181f359\""
  - path: /ce/ca/aws/cloudfront/distribution-traffic-encryption-to-custom-origins/prod.logic.yaml
    md5Hash: 4E35383A31E8A0CF298A264638FFFC01
    content: "---\ninputType: \"CA10__CaAwsDistribution__c\"\nimportExtracts:\n  -\
      \ file: \"/types/CA10__CaAwsCacheBehavior2__c/object.extracts.yaml\"\ntestData:\n\
      \  - file: \"test-data.json\"  \nrecordTypes:\n  - \"caWebDistribution\"\nconditions:\n\
      \  - status: \"INCOMPLIANT\"\n    currentStateMessage: \"The Distribution has\
      \ at least one custom origin that is set to HTTP Only.\"\n    remediationMessage:\
      \ \"Update the Origin Protocol Policy for the custom origins to HTTPS Only.\"\
      \n    check:\n      RELATED_LIST_HAS:\n        status: \"INCOMPLIANT\"\n   \
      \     relationshipName: \"CA10__AWS_CloudFront_Origins__r\"\n  - status: \"\
      UNDETERMINED\"\n    currentStateMessage: \"The Distribution has at least one\
      \ custom origin that is set to Match Viewer\\\n      \\ but the default cache\
      \ behavior is not present in the CMDB.\"\n    check:\n      IS_EMPTY_LOOKUP:\
      \ \"CA10__defaultCacheBehavior__r\"\n  - status: \"INCOMPLIANT\"\n    currentStateMessage:\
      \ \"The Distribution has at least one custom origin that is set to Match Viewer\\\
      \n      \\ while Viewers can use both protocols.\"\n    remediationMessage:\
      \ \"Update the Origin Protocol Policy for the custom origins to HTTPS Only.\"\
      \n    check:\n      AND:\n        args:\n          - RELATED_LIST_HAS:\n   \
      \           status: \"COMPLIANT\"\n              relationshipName: \"CA10__AWS_CloudFront_Origins__r\"\
      \n          - IS_EQUAL:\n              left:\n                EXTRACT: \"CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c\"\
      \n              right:\n                TEXT: \"allow-all\"\n  - status: \"\
      INCOMPLIANT\"\n    currentStateMessage: \"The Distribution has at least one\
      \ custom origin that is set to Match Viewer\\\n      \\ while Viewers can use\
      \ both protocols.\"\n    remediationMessage: \"Update the Origin Protocol Policy\
      \ for the custom origins to HTTPS Only.\"\n    check:\n      AND:\n        args:\n\
      \          - RELATED_LIST_HAS:\n              status: \"COMPLIANT\"\n      \
      \        relationshipName: \"CA10__AWS_CloudFront_Origins__r\"\n          -\
      \ RELATED_LIST_HAS:\n              status: \"INCOMPLIANT\"\n              relationshipName:\
      \ \"CA10__AWS_CloudFront_Cache_Behaviors__r\"\n  - status: \"UNDETERMINED\"\n\
      \    currentStateMessage: \"The Distribution doesn't have any Origins in the\
      \ CMDB.\"\n    check:\n      AND:\n        args:\n          - RELATED_LIST_HAS_NO:\n\
      \              status: \"INAPPLICABLE\"\n              relationshipName: \"\
      CA10__AWS_CloudFront_Origins__r\"\n          - RELATED_LIST_HAS_NO:\n      \
      \        status: \"UNDETERMINED\"\n              relationshipName: \"CA10__AWS_CloudFront_Origins__r\"\
      \n          - RELATED_LIST_HAS_NO:\n              status: \"COMPLIANT\"\n  \
      \            relationshipName: \"CA10__AWS_CloudFront_Origins__r\"\notherwise:\n\
      \  status: \"COMPLIANT\"\n  currentStateMessage: \"All custom Origins for this\
      \ Distribution are configured to use\\\n    \\ encrypted traffic whenever applicable.\"\
      \nrelatedLists:\n  - relationshipName: \"CA10__AWS_CloudFront_Origins__r\"\n\
      \    importExtracts:\n      - file: \"/types/CA10__CaAwsOrigin2__c/object.extracts.yaml\"\
      \n    conditions:\n      - status: \"INAPPLICABLE\"\n        currentStateMessage:\
      \ \"This is not a custom origin.\"\n        check:\n          IS_EMPTY:\n  \
      \          arg:\n              EXTRACT: \"CA10__configProtocolPolicy__c\"\n\
      \      - status: \"INAPPLICABLE\"\n        currentStateMessage: \"This origin\
      \ is an S3 bucket configured for static website hosting,\\\n          \\ which\
      \ does not support HTTPS.\"\n        check:\n          CONTAINS:\n         \
      \   arg:\n              EXTRACT: \"CA10__domainName__c\"\n            search:\n\
      \              TEXT: \"s3-website\"\n      - status: \"INCOMPLIANT\"\n     \
      \   currentStateMessage: \"The protocol policy for this custom origin is http-only,\\\
      \n          \\ allowing unencrypted traffic.\"\n        check:\n          IS_EQUAL:\n\
      \            left:\n              EXTRACT: \"CA10__configProtocolPolicy__c\"\
      \n            right:\n              TEXT: \"http-only\"\n      # match-viewer\
      \ is set to COMPLIANT only to make it easier to distinguish from INCOMPLIANT\
      \ in the main body of the policy\n      - status: \"COMPLIANT\"\n        currentStateMessage:\
      \ \"The protocol policy for this custom origin depends on\\\n          \\ the\
      \ protocol of the viewer request.\"\n        check:\n          IS_EQUAL:\n \
      \           left:\n              EXTRACT: \"CA10__configProtocolPolicy__c\"\n\
      \            right:\n              TEXT: \"match-viewer\"\n    # This is set\
      \ to UNDETERMINED since COMPLIANT status is already reserved for the purpose\
      \ above\n    otherwise:\n      status: \"UNDETERMINED\"\n      currentStateMessage:\
      \ \"The protocol policy for this custom origin enforces encrypted traffic.\"\
      \n  - relationshipName: \"CA10__AWS_CloudFront_Cache_Behaviors__r\"\n    conditions:\n\
      \      - status: \"INCOMPLIANT\"\n        currentStateMessage: \"The viewer\
      \ protocol policy for this cache behavior is set to allow-all.\"\n        check:\n\
      \          IS_EQUAL:\n            left:\n              EXTRACT: \"CA10__viewerProtocolPolicy__c\"\
      \n            right:\n              TEXT: \"allow-all\"\n    otherwise:\n  \
      \    status: \"COMPLIANT\"\n      currentStateMessage: \"The viewer protocol\
      \ policy for this cache behavior encrypts communications.\"\n"
  - path: /types/CA10__CaAwsCacheBehavior2__c/object.extracts.yaml
    md5Hash: 9FCFD18140FB8C38265EB37003668054
    content: |-
      ---
      extracts:
      # Values: allow-all | https-only | redirect-to-https. Not Nullable. Can't have no access, retrieved via cloudfront:GetDistribution
        - name: "CA10__viewerProtocolPolicy__c"
          value:
            FIELD:
              path: CA10__viewerProtocolPolicy__c
              undeterminedIf:
                  isEmpty: "Corrupted data. Viewer Protocol Policy cannot be empty."
  - path: /ce/ca/aws/cloudfront/distribution-traffic-encryption-to-custom-origins/test-data.json
    md5Hash: EFD068FD5F22ADB0C47C3D2898F784DE
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test1",
              "RecordTypeId": "RecordTypeId1",
              "CA10__disappearanceTime__c": "2025-05-10T18:55:17Z",
              "CA10__defaultCacheBehavior__c": "",
              "CA10__defaultCacheBehaviorUniqueId__c": "",
              "RecordType": {
                  "DeveloperName": "caRtmpDistribution",
                  "Id": "RecordTypeId1"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": null,
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": null
              },
              "CA10__AWS_CloudFront_Origins__r": [],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": []
          },{
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "not(setOfText(['caWebDistribution']).contains(RecordType.DeveloperName))",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test2",
              "RecordTypeId": "RecordTypeId1",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "",
              "CA10__defaultCacheBehaviorUniqueId__c": "",
              "RecordType": {
                  "DeveloperName": "caRtmpDistribution",
                  "Id": "RecordTypeId1"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": null,
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": null
              },
              "CA10__AWS_CloudFront_Origins__r": [],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10__AWS_CloudFront_Origins__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test3",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "defaultCacheBehavior3_1",
              "CA10__defaultCacheBehaviorUniqueId__c": "defaultCacheBehaviorUniqueId3",
              "RecordType": {
                  "DeveloperName": "caWebDistribution",
                  "Id": "RecordTypeId2"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": "defaultCacheBehavior3_1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": "redirect-to-https"
              },
              "CA10__AWS_CloudFront_Origins__r": [
                  {
                      "Id": "test3_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__configProtocolPolicy__c": "http-only",
                      "CA10__domainName__c": "domainName",
                      "CA10__distribution__c": "test3"
                  }
              ],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": [
                  {
                      "Id": "defaultCacheBehavior3_2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__viewerProtocolPolicy__c": "redirect-to-https",
                      "CA10__distribution__c": "test3"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && CA10__AWS_CloudFront_Cache_Behaviors__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test4",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "defaultCacheBehavior4_1",
              "CA10__defaultCacheBehaviorUniqueId__c": "defaultCacheBehaviorUniqueId4",
              "RecordType": {
                  "DeveloperName": "caWebDistribution",
                  "Id": "RecordTypeId2"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": "defaultCacheBehavior4_1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": "redirect-to-https"
              },
              "CA10__AWS_CloudFront_Origins__r": [
                  {
                      "Id": "test4_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__configProtocolPolicy__c": "match-viewer",
                      "CA10__domainName__c": "domainName",
                      "CA10__distribution__c": "test4"
                  }
              ],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": [
                  {
                      "Id": "defaultCacheBehavior4_2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__viewerProtocolPolicy__c": "allow-all",
                      "CA10__distribution__c": "test4"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && extract('CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c') == 'allow-all'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test5",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "defaultCacheBehavior5_1",
              "CA10__defaultCacheBehaviorUniqueId__c": "defaultCacheBehaviorUniqueId5",
              "RecordType": {
                  "DeveloperName": "caWebDistribution",
                  "Id": "RecordTypeId2"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": "defaultCacheBehavior5_1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": "allow-all"
              },
              "CA10__AWS_CloudFront_Origins__r": [
                  {
                      "Id": "test5_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__configProtocolPolicy__c": "match-viewer",
                      "CA10__domainName__c": "domainName",
                      "CA10__distribution__c": "test5"
                  }
              ],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": [
                  {
                      "Id": "defaultCacheBehavior5_2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__viewerProtocolPolicy__c": "redirect-to-https",
                      "CA10__distribution__c": "test5"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "700",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test6",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "defaultCacheBehavior6_1",
              "CA10__defaultCacheBehaviorUniqueId__c": "defaultCacheBehaviorUniqueId6",
              "RecordType": {
                  "DeveloperName": "caWebDistribution",
                  "Id": "RecordTypeId2"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": "defaultCacheBehavior6_1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": "redirect-to-https"
              },
              "CA10__AWS_CloudFront_Origins__r": [
                  {
                      "Id": "test6_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__configProtocolPolicy__c": "https-only",
                      "CA10__domainName__c": "domainName",
                      "CA10__distribution__c": "test6"
                  }
              ],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": [
                  {
                      "Id": "defaultCacheBehavior6_2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__viewerProtocolPolicy__c": "redirect-to-https",
                      "CA10__distribution__c": "test6"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "699",
                  "conditionText": "CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED) && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test7",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "defaultCacheBehavior7_1",
              "CA10__defaultCacheBehaviorUniqueId__c": "defaultCacheBehaviorUniqueId7",
              "RecordType": {
                  "DeveloperName": "caWebDistribution",
                  "Id": "RecordTypeId2"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": "defaultCacheBehavior7_1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": "redirect-to-https"
              },
              "CA10__AWS_CloudFront_Origins__r": [
                  {
                      "Id": "test7_1",
                      "CA10__disappearanceTime__c": "2025-05-10T18:55:17Z",
                      "CA10__configProtocolPolicy__c": "http-only",
                      "CA10__domainName__c": "domainName",
                      "CA10__distribution__c": "test7"
                  }
              ],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": [
                  {
                      "Id": "defaultCacheBehavior7_2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__viewerProtocolPolicy__c": "redirect-to-https",
                      "CA10__distribution__c": "test7"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "700",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test8",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "defaultCacheBehavior8_1",
              "CA10__defaultCacheBehaviorUniqueId__c": "defaultCacheBehaviorUniqueId8",
              "RecordType": {
                  "DeveloperName": "caWebDistribution",
                  "Id": "RecordTypeId2"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": "defaultCacheBehavior8_1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": "redirect-to-https"
              },
              "CA10__AWS_CloudFront_Origins__r": [
                  {
                      "Id": "test8_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__configProtocolPolicy__c": "http-only",
                      "CA10__domainName__c": "domainName.s3-website-region",
                      "CA10__distribution__c": "test8"
                  }
              ],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": [
                  {
                      "Id": "defaultCacheBehavior8_2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__viewerProtocolPolicy__c": "redirect-to-https",
                      "CA10__distribution__c": "test8"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "399",
                  "conditionText": "isEmptyLookup('CA10__defaultCacheBehavior__r')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test9",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "defaultCacheBehavior9_1",
              "CA10__defaultCacheBehaviorUniqueId__c": "defaultCacheBehaviorUniqueId9",
              "RecordType": {
                  "DeveloperName": "caWebDistribution",
                  "Id": "RecordTypeId2"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": "defaultCacheBehavior9_1",
                  "CA10__disappearanceTime__c": "2025-05-10T18:55:17Z",
                  "CA10__viewerProtocolPolicy__c": "redirect-to-https"
              },
              "CA10__AWS_CloudFront_Origins__r": [
                  {
                      "Id": "test9_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__configProtocolPolicy__c": "match-viewer",
                      "CA10__domainName__c": "domainName",
                      "CA10__distribution__c": "test9"
                  }
              ],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": [
                  {
                      "Id": "defaultCacheBehavior9_2",
                      "CA10__disappearanceTime__c": "2025-05-10T18:55:17Z",
                      "CA10__viewerProtocolPolicy__c": "redirect-to-https",
                      "CA10__distribution__c": "test9"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "699",
                  "conditionText": "CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED) && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-10T18:55:17Z"
              },
              "Id": "test10",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__defaultCacheBehavior__c": "defaultCacheBehavior10_1",
              "CA10__defaultCacheBehaviorUniqueId__c": "defaultCacheBehaviorUniqueId10",
              "RecordType": {
                  "DeveloperName": "caWebDistribution",
                  "Id": "RecordTypeId2"
              },
              "CA10__defaultCacheBehavior__r": {
                  "Id": "defaultCacheBehavior10_1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__viewerProtocolPolicy__c": "redirect-to-https"
              },
              "CA10__AWS_CloudFront_Origins__r": [],
              "CA10__AWS_CloudFront_Cache_Behaviors__r": [
                  {
                      "Id": "defaultCacheBehavior10_2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__viewerProtocolPolicy__c": "redirect-to-https",
                      "CA10__distribution__c": "test10"
                  }
              ]
          }
      ]
  - path: /types/CA10__CaAwsOrigin2__c/object.extracts.yaml
    md5Hash: 6B8CD26CEA48D96F7C7123252B2102AF
    content: "---\nextracts:\n# Values: http-only | match-viewer | https-only. Nullable.\
      \ In case it's a Custom Origin, cannot be null. \n# Can't have no access, retrieved\
      \ via cloudfront:GetDistribution.\n  - name: \"CA10__configProtocolPolicy__c\"\
      \n    value:\n      FIELD:\n        path: CA10__configProtocolPolicy__c\n# Not\
      \ Nullable. Can't have no access, retrieved via cloudfront:GetDistribution.\n\
      \  - name: \"CA10__domainName__c\"\n    value:\n      FIELD:\n        path:\
      \ CA10__domainName__c\n        undeterminedIf:\n          isEmpty: \"Corrupted\
      \ data. Origin Domain Name cannot be empty.\"\n# Values: SSLv3 | TLSv1 | TLSv1.1\
      \ | TLSv1.2. Nullable. In case it's a Custom Origin, cannot be null. \n# Can't\
      \ have no access, retrieved via cloudfront:GetDistribution.\n  - name: \"CA10__customOriginConfigOriginSslProtocols__c\"\
      \n    value:\n      FIELD:\n        path: CA10__customOriginConfigOriginSslProtocols__c\n\
      \  - name: CA10__customOriginConfigOriginSslProtocolsAsCollection__c\n    value:\n\
      \      SET_FROM:\n        separator: \"\\n\"\n        arg:\n          EXTRACT:\
      \ \"CA10__customOriginConfigOriginSslProtocols__c\""
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" : "not(setOfText(['caWebDistribution']).contains(RecordType.DeveloperName))",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_CloudFront_Origins__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && CA10__AWS_CloudFront_Cache_Behaviors__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && extract('CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c') == 'allow-all'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "700",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "699",
      "conditionText" : "CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED) && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "700",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test9",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "399",
      "conditionText" : "isEmptyLookup('CA10__defaultCacheBehavior__r')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test10",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "699",
      "conditionText" : "CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED) && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsDistribution__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__defaultCacheBehavior__c STRING,
      CA10__defaultCacheBehaviorUniqueId__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test1",
    "RecordTypeId" : "RecordTypeId1",
    "CA10__disappearanceTime__c" : new Date("2025-05-10T18:55:17Z"),
    "CA10__defaultCacheBehavior__c" : "",
    "CA10__defaultCacheBehaviorUniqueId__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test2",
    "RecordTypeId" : "RecordTypeId1",
    "CA10__defaultCacheBehavior__c" : "",
    "CA10__defaultCacheBehaviorUniqueId__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test3",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__defaultCacheBehavior__c" : "defaultCacheBehavior3_1",
    "CA10__defaultCacheBehaviorUniqueId__c" : "defaultCacheBehaviorUniqueId3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test4",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__defaultCacheBehavior__c" : "defaultCacheBehavior4_1",
    "CA10__defaultCacheBehaviorUniqueId__c" : "defaultCacheBehaviorUniqueId4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test5",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__defaultCacheBehavior__c" : "defaultCacheBehavior5_1",
    "CA10__defaultCacheBehaviorUniqueId__c" : "defaultCacheBehaviorUniqueId5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test6",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__defaultCacheBehavior__c" : "defaultCacheBehavior6_1",
    "CA10__defaultCacheBehaviorUniqueId__c" : "defaultCacheBehaviorUniqueId6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test7",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__defaultCacheBehavior__c" : "defaultCacheBehavior7_1",
    "CA10__defaultCacheBehaviorUniqueId__c" : "defaultCacheBehaviorUniqueId7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test8",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__defaultCacheBehavior__c" : "defaultCacheBehavior8_1",
    "CA10__defaultCacheBehaviorUniqueId__c" : "defaultCacheBehaviorUniqueId8"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test9",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__defaultCacheBehavior__c" : "defaultCacheBehavior9_1",
    "CA10__defaultCacheBehaviorUniqueId__c" : "defaultCacheBehaviorUniqueId9"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test10",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__defaultCacheBehavior__c" : "defaultCacheBehavior10_1",
    "CA10__defaultCacheBehaviorUniqueId__c" : "defaultCacheBehaviorUniqueId10"
  } ];
  """;

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

  CREATE TEMP FUNCTION mock_CA10__CaAwsCacheBehavior2__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__viewerProtocolPolicy__c STRING,
      CA10__distribution__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : null,
    "CA10__viewerProtocolPolicy__c" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior3_1",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior3_2",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https",
    "CA10__distribution__c" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior4_1",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior4_2",
    "CA10__viewerProtocolPolicy__c" : "allow-all",
    "CA10__distribution__c" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior5_1",
    "CA10__viewerProtocolPolicy__c" : "allow-all"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior5_2",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https",
    "CA10__distribution__c" : "test5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior6_1",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior6_2",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https",
    "CA10__distribution__c" : "test6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior7_1",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior7_2",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https",
    "CA10__distribution__c" : "test7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior8_1",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior8_2",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https",
    "CA10__distribution__c" : "test8"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior9_1",
    "CA10__disappearanceTime__c" : new Date("2025-05-10T18:55:17Z"),
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior9_2",
    "CA10__disappearanceTime__c" : new Date("2025-05-10T18:55:17Z"),
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https",
    "CA10__distribution__c" : "test9"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior10_1",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "defaultCacheBehavior10_2",
    "CA10__viewerProtocolPolicy__c" : "redirect-to-https",
    "CA10__distribution__c" : "test10"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsOrigin2__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__configProtocolPolicy__c STRING,
      CA10__domainName__c STRING,
      CA10__distribution__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test3_1",
    "CA10__configProtocolPolicy__c" : "http-only",
    "CA10__domainName__c" : "domainName",
    "CA10__distribution__c" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test4_1",
    "CA10__configProtocolPolicy__c" : "match-viewer",
    "CA10__domainName__c" : "domainName",
    "CA10__distribution__c" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test5_1",
    "CA10__configProtocolPolicy__c" : "match-viewer",
    "CA10__domainName__c" : "domainName",
    "CA10__distribution__c" : "test5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test6_1",
    "CA10__configProtocolPolicy__c" : "https-only",
    "CA10__domainName__c" : "domainName",
    "CA10__distribution__c" : "test6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test7_1",
    "CA10__disappearanceTime__c" : new Date("2025-05-10T18:55:17Z"),
    "CA10__configProtocolPolicy__c" : "http-only",
    "CA10__domainName__c" : "domainName",
    "CA10__distribution__c" : "test7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test8_1",
    "CA10__configProtocolPolicy__c" : "http-only",
    "CA10__domainName__c" : "domainName.s3-website-region",
    "CA10__distribution__c" : "test8"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-10T18:55:17Z")
    },
    "Id" : "test9_1",
    "CA10__configProtocolPolicy__c" : "match-viewer",
    "CA10__domainName__c" : "domainName",
    "CA10__distribution__c" : "test9"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsDistribution__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__defaultCacheBehavior__c STRING,
          CA10__defaultCacheBehaviorUniqueId__c STRING,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >,
          CA10__defaultCacheBehavior__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__viewerProtocolPolicy__c STRING
          >,
          CA10__AWS_CloudFront_Origins__r ARRAY<STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__configProtocolPolicy__c STRING,
              CA10__domainName__c STRING,
              CA10__distribution__c STRING,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
          >>,
          CA10__AWS_CloudFront_Cache_Behaviors__r ARRAY<STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__viewerProtocolPolicy__c STRING,
              CA10__distribution__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 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 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 BytesLib = new function () {
          this.normalize = function(arg) {
              return arg == null ? '' : arg;
          };
          this.isEmpty = function(arg) {
              return this.normalize(arg) == '';
          };
          this.isNotEmpty = function(arg) {
              return this.normalize(arg) != '';
          };
          this.equal = function(left, right) {
              return this.normalize(left) == this.normalize(right);
          };
          this.notEqual = function(left, right) {
              return this.normalize(left) != this.normalize(right);
          };
          this.startsWith = function(arg, substring) {
              return this.normalize(arg).startsWith(this.normalize(substring));
          };
          this.endsWith = function(arg, substring) {
              return this.normalize(arg).endsWith(this.normalize(substring));
          };
          this.contains = function(arg, substring) {
              return this.normalize(arg).includes(this.normalize(substring));
          };
          this.containsAll = function(arg, substrings) {
              if (substrings == null || substrings.length === 0) return false;
              let normalizedArg = this.normalize(arg);
              return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
          };
          this.containsAny = function(arg, substrings) {
              if (substrings == null || substrings.length === 0) return false;
              let normalizedArg = this.normalize(arg);
              return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Record Type Name [obj.RecordType.DeveloperName]: ' + obj.RecordType.DeveloperName);
      if (!CollectionLib.contains(CollectionLib.fromArray(['caWebDistribution'], true, true, true, true), obj.RecordType.DeveloperName, true)) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['caWebDistribution']).contains(RecordType.DeveloperName))", currentStateMessage: "Object record type is not applicable", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_CloudFront_Origins__r_INCOMPLIANT3 = 0;
      if (obj.CA10__AWS_CloudFront_Origins__r != null) {
          for (var i4 = 0; i4 < obj.CA10__AWS_CloudFront_Origins__r.length; i4++) {
              if (obj.CA10__AWS_CloudFront_Origins__r[i4].result.status == 'INCOMPLIANT') {
                  count_CA10__AWS_CloudFront_Origins__r_INCOMPLIANT3 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      references1.push('Related list [CA10__AWS_CloudFront_Origins__r] ' + (count_CA10__AWS_CloudFront_Origins__r_INCOMPLIANT3 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__AWS_CloudFront_Origins__r_INCOMPLIANT3 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_CloudFront_Origins__r.has(INCOMPLIANT)", currentStateMessage: "The Distribution has at least one custom origin that is set to HTTP Only.", currentStateReferences: references1.join('\n'), remediation: "Update the Origin Protocol Policy for the custom origins to HTTPS Only.", runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      if (TextLib.isEmpty(obj.CA10__defaultCacheBehaviorUniqueId__c) || TextLib.isEmpty(obj.CA10__defaultCacheBehavior__c) || obj.CA10__defaultCacheBehavior__r.CA10__disappearanceTime__c != null) {
          return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "isEmptyLookup('CA10__defaultCacheBehavior__r')", currentStateMessage: "The Distribution has at least one custom origin that is set to Match Viewer but the default cache behavior is not present in the CMDB.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 = 0;
      if (obj.CA10__AWS_CloudFront_Origins__r != null) {
          for (var i9 = 0; i9 < obj.CA10__AWS_CloudFront_Origins__r.length; i9++) {
              if (obj.CA10__AWS_CloudFront_Origins__r[i9].result.status == 'COMPLIANT') {
                  count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 += 1;
              }
          }
      }
      // condition[4], conditionIndex:[400..499]
      function extractChecked6() {
          if (TextLib.isEmpty(obj.CA10__defaultCacheBehaviorUniqueId__c)) {
              throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "extractCheck(obj.CA10__defaultCacheBehaviorUniqueId__c)", currentStateMessage: "Related object via CA10__defaultCacheBehaviorUniqueId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__defaultCacheBehavior__c)) {
              throw new Error("UNDETERMINED condition:402", {cause: {status: 'UNDETERMINED', conditionIndex: 402, conditionText: "extractCheck(obj.CA10__defaultCacheBehavior__c)", currentStateMessage: "Related object via CA10__defaultCacheBehavior__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__defaultCacheBehavior__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:403", {cause: {status: 'UNDETERMINED', conditionIndex: 403, conditionText: "extractCheck(obj.CA10__defaultCacheBehavior__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__defaultCacheBehavior__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract7.call(extract7);
      }
      function fieldChecked8() {
          if (TextLib.isEmpty(obj.CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c)) {
              throw new Error("UNDETERMINED condition:404", {cause: {status: 'UNDETERMINED', conditionIndex: 404, conditionText: "CA10__viewerProtocolPolicy__c.isEmpty()", currentStateMessage: "Corrupted data. Viewer Protocol Policy cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c;
      }
      function extract7() { if (!this.out) { this.out = fieldChecked8(); } return this.out; };
      references1.push('Viewer Protocol Policy [obj.CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c]: ' + obj.CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c);
      try {
          if (count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 > 0 && TextLib.equal(extractChecked6(), 'allow-all')) {
              return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && extract('CA10__defaultCacheBehavior__r.CA10__viewerProtocolPolicy__c') == 'allow-all'", currentStateMessage: "The Distribution has at least one custom origin that is set to Match Viewer while Viewers can use both protocols.", currentStateReferences: references1.join('\n'), remediation: "Update the Origin Protocol Policy for the custom origins to HTTPS Only.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      var count_CA10__AWS_CloudFront_Cache_Behaviors__r_INCOMPLIANT10 = 0;
      if (obj.CA10__AWS_CloudFront_Cache_Behaviors__r != null) {
          for (var i11 = 0; i11 < obj.CA10__AWS_CloudFront_Cache_Behaviors__r.length; i11++) {
              if (obj.CA10__AWS_CloudFront_Cache_Behaviors__r[i11].result.status == 'INCOMPLIANT') {
                  count_CA10__AWS_CloudFront_Cache_Behaviors__r_INCOMPLIANT10 += 1;
              }
          }
      }
      var count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 = 0;
      if (obj.CA10__AWS_CloudFront_Origins__r != null) {
          for (var i12 = 0; i12 < obj.CA10__AWS_CloudFront_Origins__r.length; i12++) {
              if (obj.CA10__AWS_CloudFront_Origins__r[i12].result.status == 'COMPLIANT') {
                  count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 += 1;
              }
          }
      }
      // condition[5], conditionIndex:[500..599]
      references1.push('Related list [CA10__AWS_CloudFront_Cache_Behaviors__r] ' + (count_CA10__AWS_CloudFront_Cache_Behaviors__r_INCOMPLIANT10 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 > 0 && count_CA10__AWS_CloudFront_Cache_Behaviors__r_INCOMPLIANT10 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "CA10__AWS_CloudFront_Origins__r.has(COMPLIANT) && CA10__AWS_CloudFront_Cache_Behaviors__r.has(INCOMPLIANT)", currentStateMessage: "The Distribution has at least one custom origin that is set to Match Viewer while Viewers can use both protocols.", currentStateReferences: references1.join('\n'), remediation: "Update the Origin Protocol Policy for the custom origins to HTTPS Only.", runtimeError: null};
      }
      var count_CA10__AWS_CloudFront_Origins__r_UNDETERMINED14 = 0;
      var count_CA10__AWS_CloudFront_Origins__r_INAPPLICABLE13 = 0;
      var count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 = 0;
      if (obj.CA10__AWS_CloudFront_Origins__r != null) {
          for (var i15 = 0; i15 < obj.CA10__AWS_CloudFront_Origins__r.length; i15++) {
              if (obj.CA10__AWS_CloudFront_Origins__r[i15].result.status == 'UNDETERMINED') {
                  count_CA10__AWS_CloudFront_Origins__r_UNDETERMINED14 += 1;
              }
              if (obj.CA10__AWS_CloudFront_Origins__r[i15].result.status == 'INAPPLICABLE') {
                  count_CA10__AWS_CloudFront_Origins__r_INAPPLICABLE13 += 1;
              }
              if (obj.CA10__AWS_CloudFront_Origins__r[i15].result.status == 'COMPLIANT') {
                  count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 += 1;
              }
          }
      }
      // condition[6], conditionIndex:[600..699]
      if (count_CA10__AWS_CloudFront_Origins__r_INAPPLICABLE13 == 0 && count_CA10__AWS_CloudFront_Origins__r_UNDETERMINED14 == 0 && count_CA10__AWS_CloudFront_Origins__r_COMPLIANT5 == 0) {
          return {status: 'UNDETERMINED', conditionIndex: 699, conditionText: "CA10__AWS_CloudFront_Origins__r.hasNo(INAPPLICABLE) && CA10__AWS_CloudFront_Origins__r.hasNo(UNDETERMINED) && CA10__AWS_CloudFront_Origins__r.hasNo(COMPLIANT)", currentStateMessage: "The Distribution doesn't have any Origins in the CMDB.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 700, conditionText: "otherwise", currentStateMessage: "All custom Origins for this Distribution are configured to use encrypted traffic whenever applicable.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_CloudFront_Cache_Behaviors__r(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__viewerProtocolPolicy__c STRING,
          CA10__distribution__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));
          };
          this.containsAll = function(arg, substrings) {
              if (substrings == null || substrings.length === 0) return false;
              let normalizedArg = this.normalize(arg);
              return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
          };
          this.containsAny = function(arg, substrings) {
              if (substrings == null || substrings.length === 0) return false;
              let normalizedArg = this.normalize(arg);
              return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__viewerProtocolPolicy__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__viewerProtocolPolicy__c.isEmpty()", currentStateMessage: "Corrupted data. Viewer Protocol Policy cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__viewerProtocolPolicy__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Viewer Protocol Policy [obj.CA10__viewerProtocolPolicy__c]: ' + obj.CA10__viewerProtocolPolicy__c);
      try {
          if (TextLib.equal(extract3.call(extract3), 'allow-all')) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__viewerProtocolPolicy__c') == 'allow-all'", currentStateMessage: "The viewer protocol policy for this cache behavior is set to allow-all.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The viewer protocol policy for this cache behavior encrypts communications.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_CloudFront_Origins__r(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__configProtocolPolicy__c STRING,
          CA10__domainName__c STRING,
          CA10__distribution__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));
          };
          this.containsAll = function(arg, substrings) {
              if (substrings == null || substrings.length === 0) return false;
              let normalizedArg = this.normalize(arg);
              return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
          };
          this.containsAny = function(arg, substrings) {
              if (substrings == null || substrings.length === 0) return false;
              let normalizedArg = this.normalize(arg);
              return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function extract3() { if (!this.out) { this.out = obj.CA10__configProtocolPolicy__c; } return this.out; };
      references1.push('Custom Origin Config Protocol Policy [obj.CA10__configProtocolPolicy__c]: ' + obj.CA10__configProtocolPolicy__c);
      if (TextLib.isEmpty(extract3.call(extract3))) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__configProtocolPolicy__c').isEmpty()", currentStateMessage: "This is not a custom origin.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10__domainName__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__domainName__c.isEmpty()", currentStateMessage: "Corrupted data. Origin Domain Name cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__domainName__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      references1.push('Domain Name [obj.CA10__domainName__c]: ' + obj.CA10__domainName__c);
      try {
          if (TextLib.contains(extract6.call(extract6), 's3-website')) {
              return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__domainName__c').contains('s3-website')", currentStateMessage: "This origin is an S3 bucket configured for static website hosting, which does not support HTTPS.", 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 extract9() { if (!this.out) { this.out = obj.CA10__configProtocolPolicy__c; } return this.out; };
      if (TextLib.equal(extract9.call(extract9), 'http-only')) {
          return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__configProtocolPolicy__c') == 'http-only'", currentStateMessage: "The protocol policy for this custom origin is http-only, allowing unencrypted traffic.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      function extract12() { if (!this.out) { this.out = obj.CA10__configProtocolPolicy__c; } return this.out; };
      if (TextLib.equal(extract12.call(extract12), 'match-viewer')) {
          return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__configProtocolPolicy__c') == 'match-viewer'", currentStateMessage: "The protocol policy for this custom origin depends on the protocol of the viewer request.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "The protocol policy for this custom origin enforces encrypted traffic.", 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.RecordTypeId AS RecordTypeId,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__defaultCacheBehavior__c AS CA10__defaultCacheBehavior__c,
          sObject.CA10__defaultCacheBehaviorUniqueId__c AS CA10__defaultCacheBehaviorUniqueId__c,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          STRUCT (
              `CA10__defaultCacheBehavior__r`.Id AS Id,
              `CA10__defaultCacheBehavior__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
              `CA10__defaultCacheBehavior__r`.CA10__viewerProtocolPolicy__c AS CA10__viewerProtocolPolicy__c
          ) AS CA10__defaultCacheBehavior__r,
          `CA10__AWS_CloudFront_Origins__r`.arr AS CA10__AWS_CloudFront_Origins__r,
          `CA10__AWS_CloudFront_Cache_Behaviors__r`.arr AS CA10__AWS_CloudFront_Cache_Behaviors__r,
          process_CA10__CaAwsDistribution__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__defaultCacheBehavior__c AS CA10__defaultCacheBehavior__c,
                  sObject.CA10__defaultCacheBehaviorUniqueId__c AS CA10__defaultCacheBehaviorUniqueId__c,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType,
                  STRUCT (
                      `CA10__defaultCacheBehavior__r`.Id AS Id,
                      `CA10__defaultCacheBehavior__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      `CA10__defaultCacheBehavior__r`.CA10__viewerProtocolPolicy__c AS CA10__viewerProtocolPolicy__c
                  ) AS CA10__defaultCacheBehavior__r,
                  `CA10__AWS_CloudFront_Origins__r`.arr AS CA10__AWS_CloudFront_Origins__r,
                  `CA10__AWS_CloudFront_Cache_Behaviors__r`.arr AS CA10__AWS_CloudFront_Cache_Behaviors__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsDistribution__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
      LEFT JOIN UNNEST(mock_CA10__CaAwsCacheBehavior2__c()) AS `CA10__defaultCacheBehavior__r`
          ON sObject.CA10__defaultCacheBehavior__c = `CA10__defaultCacheBehavior__r`.Id
      LEFT JOIN (
          SELECT
              sObject.CA10__distribution__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__configProtocolPolicy__c AS CA10__configProtocolPolicy__c,
                      sObject.CA10__domainName__c AS CA10__domainName__c,
                      sObject.CA10__distribution__c AS CA10__distribution__c,
                      process_CA10__AWS_CloudFront_Origins__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__configProtocolPolicy__c AS CA10__configProtocolPolicy__c,
                              sObject.CA10__domainName__c AS CA10__domainName__c,
                              sObject.CA10__distribution__c AS CA10__distribution__c
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsOrigin2__c()) AS sObject
          GROUP BY sObject.CA10__distribution__c
      ) AS `CA10__AWS_CloudFront_Origins__r`
          ON sObject.Id = `CA10__AWS_CloudFront_Origins__r`.CA10__distribution__c
      LEFT JOIN (
          SELECT
              sObject.CA10__distribution__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__viewerProtocolPolicy__c AS CA10__viewerProtocolPolicy__c,
                      sObject.CA10__distribution__c AS CA10__distribution__c,
                      process_CA10__AWS_CloudFront_Cache_Behaviors__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__viewerProtocolPolicy__c AS CA10__viewerProtocolPolicy__c,
                              sObject.CA10__distribution__c AS CA10__distribution__c
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsCacheBehavior2__c()) AS sObject
          GROUP BY sObject.CA10__distribution__c
      ) AS `CA10__AWS_CloudFront_Cache_Behaviors__r`
          ON sObject.Id = `CA10__AWS_CloudFront_Cache_Behaviors__r`.CA10__distribution__c
  ) sObject ON sObject.Id = expectedResult.Id;
