---
policy: /ce/ca/aws/ec2/instance-imdsv2
logic: /ce/ca/aws/ec2/instance-imdsv2/prod.logic.yaml
executionTime: 2025-04-24T23:44:32.081563147Z
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: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__metadataState__c') == 'applied' && extract('CA10__metadataHttpTokens__c')
        == 'required'
      actual: extract('CA10__metadataState__c') == 'applied' && extract('CA10__metadataHttpTokens__c')
        == 'required'
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__metadataHttpTokens__c') == 'optional'
      actual: extract('CA10__metadataHttpTokens__c') == 'optional'
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__metadataState__c') == 'pending'
      actual: extract('CA10__metadataState__c') == 'pending'
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 101
      actual: 101
    conditionText:
      expected: CA10__metadataState__c.isEmpty()
      actual: CA10__metadataState__c.isEmpty()
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 201
      actual: 201
    conditionText:
      expected: CA10__metadataHttpTokens__c.isEmpty()
      actual: CA10__metadataHttpTokens__c.isEmpty()
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 400
      actual: 400
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/ec2/instance-imdsv2/policy.yaml
    md5Hash: 02A9D80FF09EB4F967A079E3ACFBB95A
    content: |
      ---
      names:
        full: AWS EC2 Instance IMDSv2 is not enabled
        contextual: Instance IMDSv2 is not enabled
      description: "When enabling the Metadata Service on AWS EC2 instances, users have\
        \ the option of using either Instance Metadata Service Version 1 (IMDSv1; a request/response\
        \ method) or Instance Metadata Service Version 2 (IMDSv2; a session-oriented method)."
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-aws-v5.0.0/05/07"
        - "/frameworks/cloudaware/resource-security/secure-access"
        - "/frameworks/aws-fsbp-v1.0.0/ec2/08"
      similarPolicies:
        internal:
          - dec-x-b42fae78
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/EC2/require-imds-v2.html
            name: Require IMDSv2 for EC2 Instances
  - path: /ce/ca/aws/ec2/instance-imdsv2/prod.logic.yaml
    md5Hash: A035737E150271BB53CD210618468949
    content: |
      ---
      inputType: "CA10__CaAwsInstance__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10__CaAwsInstance__c/object.extracts.yaml"
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "EC2 Instance IMDSv2 is not enabled."
          remediationMessage: "Consider enabling EC2 Instance IMDSv2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__metadataState__c"
              right:
                TEXT: "pending"
        - status: "INCOMPLIANT"
          currentStateMessage: "EC2 Instance IMDSv2 is not required."
          remediationMessage: "Ensure that EC2 Instance IMDSv2 is required."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__metadataHttpTokens__c"
              right:
                TEXT: "optional"
        - status: "COMPLIANT"
          currentStateMessage: "EC2 Metadata Service only allows IMDSv2."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__metadataState__c"
                    right:
                      TEXT: "applied"
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__metadataHttpTokens__c"
                    right:
                      TEXT: "required"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected values in the fields."
  - path: /types/CA10__CaAwsInstance__c/object.extracts.yaml
    md5Hash: 802FA80DBDE640AF85A69B42E51E0CCD
    content: "---\nextracts:\n# Values pending, applied. Not nullable. Can't have\
      \ no access, retrieved via ec2:DescribeInstances\n  - name: \"CA10__metadataState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__metadataState__c\"\n    \
      \    undeterminedIf:\n          isEmpty: \"Corrupted data. EC2 Instances Metadata\
      \ State cannot be empty.\"\n# Values: optional, required. Not nullable. Can't\
      \ have no access, retrieved via ec2:DescribeInstances\n  - name: \"CA10__metadataHttpTokens__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__metadataHttpTokens__c\"\n\
      \        undeterminedIf:\n          isEmpty: \"Corrupted data. EC2 Instances\
      \ Metadata Http Token cannot be empty.\"\n  - name: CA10__iamInstanceProfileArn__c\n\
      \    value:\n      FIELD: \n        path: CA10__iamInstanceProfileArn__c\n#\
      \ Nullable. Can't have no access, retrieved via ec2:DescribeInstances\n  - name:\
      \ \"CA10__publicIpAddress__c\"\n    value: \n      FIELD:\n        path: \"\
      CA10__publicIpAddress__c\"\n# Values: enabled, disabled. Not nullable. Can't\
      \ have no access, retrieved via ec2:DescribeInstances\n  - name: \"CA10__monitoringState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__monitoringState__c\"\n  \
      \      undeterminedIf:\n          isEmpty: \"Corrupted data. EC2 Instances Detailed\
      \ Monitoring State cannot be empty.\"\n# Values: pending | running | shutting-down\
      \ | terminated | stopping | stopped. Not nullable.\n  - name: \"CA10__stateName__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__stateName__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__stateName__c\"\n   \
      \         currentStateMessage: \"Unable to determine EC2 Instances State Name.\
      \ Possible permission issue with ec2:DescribeInstanceStatus\"\n# Number of Days.\
      \ Nullable. Can't have no access, retrieved via ec2:DescribeInstances\n  - name:\
      \ \"CA10__currentRunningTime__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__currentRunningTime__c\"      \n# Nullable.\n  - name: \"CA10__averageCpuTwoWeeks__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__averageCpuTwoWeeks__c\" \
      \     \n# Nullable.\n  - name: \"CA10__maxCpuTwoWeeks__c\"\n    value: \n  \
      \    FIELD:\n        path: \"CA10__maxCpuTwoWeeks__c\"      \n# Nullable.\n\
      \  - name: \"CA10__sumTwoWeekNetworkOutMb__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__sumTwoWeekNetworkOutMb__c\"      \n# Nullable.\n  - name:\
      \ \"CA10__sumTwoWeekNetworkInMb__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__sumTwoWeekNetworkInMb__c\"      \n"
  - path: /ce/ca/aws/ec2/instance-imdsv2/test-data.json
    md5Hash: AA284E089A556B08A30C3AF21CCA2EC6
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-05-27T22:21:00Z"
              },
              "Id": "test1",
              "Name": "security-group-1",
              "CA10__disappearanceTime__c": "2024-05-27T01:18:46Z",
              "CA10__metadataState__c": "applied",
              "CA10__metadataHttpTokens__c": "required"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('CA10__metadataState__c') == 'applied' && extract('CA10__metadataHttpTokens__c') == 'required'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-05-27T22:21:00Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__metadataState__c": "applied",
              "CA10__metadataHttpTokens__c": "required"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('CA10__metadataHttpTokens__c') == 'optional'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-05-27T22:21:00Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__metadataState__c": "applied",
              "CA10__metadataHttpTokens__c": "optional"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__metadataState__c') == 'pending'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-05-27T22:21:00Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__metadataState__c": "pending",
              "CA10__metadataHttpTokens__c": "required"
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "101",
                  "conditionText": "CA10__metadataState__c.isEmpty()",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-05-27T22:21:00Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__metadataState__c": "",
              "CA10__metadataHttpTokens__c": "required"
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "201",
                  "conditionText": "CA10__metadataHttpTokens__c.isEmpty()",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-05-27T22:21:00Z"
              },
              "Id": "test6",
              "CA10__disappearanceTime__c": null,
              "CA10__metadataState__c": "applied",
              "CA10__metadataHttpTokens__c": ""
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "400",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-05-27T22:21:00Z"
              },
              "Id": "test7",
              "CA10__disappearanceTime__c": null,
              "CA10__metadataState__c": "asdf",
              "CA10__metadataHttpTokens__c": "asdf"
          }
      ]
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" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__metadataState__c') == 'applied' && extract('CA10__metadataHttpTokens__c') == 'required'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__metadataHttpTokens__c') == 'optional'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__metadataState__c') == 'pending'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "101",
      "conditionText" : "CA10__metadataState__c.isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "201",
      "conditionText" : "CA10__metadataHttpTokens__c.isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "400",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsInstance__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__metadataState__c STRING,
      CA10__metadataHttpTokens__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-05-27T22:21:00Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2024-05-27T01:18:46Z"),
    "CA10__metadataState__c" : "applied",
    "CA10__metadataHttpTokens__c" : "required"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-05-27T22:21:00Z")
    },
    "Id" : "test2",
    "CA10__metadataState__c" : "applied",
    "CA10__metadataHttpTokens__c" : "required"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-05-27T22:21:00Z")
    },
    "Id" : "test3",
    "CA10__metadataState__c" : "applied",
    "CA10__metadataHttpTokens__c" : "optional"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-05-27T22:21:00Z")
    },
    "Id" : "test4",
    "CA10__metadataState__c" : "pending",
    "CA10__metadataHttpTokens__c" : "required"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-05-27T22:21:00Z")
    },
    "Id" : "test5",
    "CA10__metadataState__c" : "",
    "CA10__metadataHttpTokens__c" : "required"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-05-27T22:21:00Z")
    },
    "Id" : "test6",
    "CA10__metadataState__c" : "applied",
    "CA10__metadataHttpTokens__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-05-27T22:21:00Z")
    },
    "Id" : "test7",
    "CA10__metadataState__c" : "asdf",
    "CA10__metadataHttpTokens__c" : "asdf"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsInstance__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__metadataState__c STRING,
          CA10__metadataHttpTokens__c STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      var TextLib = new function () {
          this.normalize = function(arg) {
              return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
          };
          this.isEmpty = function(arg) {
              return this.normalize(arg) == '';
          };
          this.isNotEmpty = function(arg) {
              return this.normalize(arg) != '';
          };
          this.equal = function(left, right) {
              return this.normalize(left) == this.normalize(right);
          };
          this.notEqual = function(left, right) {
              return this.normalize(left) != this.normalize(right);
          };
          this.startsWith = function(arg, substring) {
              return this.normalize(arg).startsWith(this.normalize(substring));
          };
          this.endsWith = function(arg, substring) {
              return this.normalize(arg).endsWith(this.normalize(substring));
          };
          this.contains = function(arg, substring) {
              return this.normalize(arg).includes(this.normalize(substring));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      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__metadataState__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__metadataState__c.isEmpty()", currentStateMessage: "Corrupted data. EC2 Instances Metadata State cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__metadataState__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Metadata: State [obj.CA10__metadataState__c]: ' + obj.CA10__metadataState__c);
      try {
          if (TextLib.equal(extract3.call(extract3), 'pending')) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__metadataState__c') == 'pending'", currentStateMessage: "EC2 Instance IMDSv2 is not enabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling EC2 Instance IMDSv2.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10__metadataHttpTokens__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__metadataHttpTokens__c.isEmpty()", currentStateMessage: "Corrupted data. EC2 Instances Metadata Http Token cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__metadataHttpTokens__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      references1.push('Metadata: HTTP Tokens [obj.CA10__metadataHttpTokens__c]: ' + obj.CA10__metadataHttpTokens__c);
      try {
          if (TextLib.equal(extract6.call(extract6), 'optional')) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__metadataHttpTokens__c') == 'optional'", currentStateMessage: "EC2 Instance IMDSv2 is not required.", currentStateReferences: references1.join('\n'), remediation: "Ensure that EC2 Instance IMDSv2 is required.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function fieldChecked10() {
          if (TextLib.isEmpty(obj.CA10__metadataState__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__metadataState__c.isEmpty()", currentStateMessage: "Corrupted data. EC2 Instances Metadata State cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__metadataState__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      function fieldChecked13() {
          if (TextLib.isEmpty(obj.CA10__metadataHttpTokens__c)) {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "CA10__metadataHttpTokens__c.isEmpty()", currentStateMessage: "Corrupted data. EC2 Instances Metadata Http Token cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__metadataHttpTokens__c;
      }
      function extract12() { if (!this.out) { this.out = fieldChecked13(); } return this.out; };
      try {
          if (TextLib.equal(extract9.call(extract9), 'applied') && TextLib.equal(extract12.call(extract12), 'required')) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__metadataState__c') == 'applied' && extract('CA10__metadataHttpTokens__c') == 'required'", currentStateMessage: "EC2 Metadata Service only allows IMDSv2.", 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: "Unexpected values in the fields.", 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,
          sObject.CA10__metadataState__c AS CA10__metadataState__c,
          sObject.CA10__metadataHttpTokens__c AS CA10__metadataHttpTokens__c,
          process_CA10__CaAwsInstance__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__metadataState__c AS CA10__metadataState__c,
                  sObject.CA10__metadataHttpTokens__c AS CA10__metadataHttpTokens__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsInstance__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
