---
policy: /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet
logic: /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/prod.logic.yaml
executionTime: 2025-08-29T17:46:06.286584589Z
generationMs: 95
executionMs: 723
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: 199
      actual: 199
    conditionText:
      expected: extract('CA10__publicIpAddress__c').isEmpty()
      actual: extract('CA10__publicIpAddress__c').isEmpty()
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_EC2_Elastic_IPs__r.has(COMPLIANT)
      actual: CA10__AWS_EC2_Elastic_IPs__r.has(COMPLIANT)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: CA10__vpcSubnet__r.CA10__defaultForAz__c == false
      actual: CA10__vpcSubnet__r.CA10__defaultForAz__c == false
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c == true
      actual: CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c == true
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: isEmptyLookup('CA10__vpcSubnet__r')
      actual: isEmptyLookup('CA10__vpcSubnet__r')
    runtimeError: {}
  - id: test8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 600
      actual: 600
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/policy.yaml
    md5Hash: 55A7FBF38BD08F2A3F87A5D9FB791FC4
    content: "---\nnames:\n  full: AWS EC2 Instance with an auto-assigned public IP\
      \ address is in a default subnet\n  contextual: Instance with an auto-assigned\
      \ public IP address is in a default subnet\ndescription: >\n  EC2 instances\
      \ launched into a default subnet are automatically assigned both \n  public\
      \ and private IPv4 addresses, which may result in unintended public exposure.\n\
      type: COMPLIANCE_POLICY\ncategories:\n  - SECURITY\n  - RELIABILITY\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/resource-security/public-and-anonymous-access\"\
      \n  - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\n\
      \  - \"/frameworks/aws-fsbp-v1.0.0/ec2/09\"\n"
  - path: /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/prod.logic.yaml
    md5Hash: F8BD05FF9F92E6EE445E68BFE6764416
    content: |-
      inputType: "CA10__CaAwsInstance__c"
      importExtracts:
        - file: /types/CA10__CaAwsInstance__c/object.extracts.yaml
        - file: /types/CA10__CaAwsSubnet__c/object.extracts.yaml
      testData:
        - file: "test-data.json"
      conditions:
        - status: "COMPLIANT"
          currentStateMessage: "The instance does not have a public IP address."
          check:
            IS_EMPTY:
              arg:
                EXTRACT: "CA10__publicIpAddress__c"
        - status: "COMPLIANT"
          currentStateMessage: "The instance has an Elastic IP address."
          check:
            RELATED_LIST_HAS:
              status: "COMPLIANT"
              relationshipName: "CA10__AWS_EC2_Elastic_IPs__r"
        - status: "UNDETERMINED"
          currentStateMessage: "Cannot determine if the instance is in a default subnet because subnet information is missing."
          check:
            IS_EMPTY_LOOKUP: "CA10__vpcSubnet__r"
        - status: "COMPLIANT"
          currentStateMessage: "Instance has a public IP address and is located in a custom subnet."
          check:
            IS_EQUAL:
              left:
                FIELD:
                  path: "CA10__vpcSubnet__r.CA10__defaultForAz__c"
              right:
                BOOLEAN: false
        - status: "INCOMPLIANT"
          currentStateMessage: "The instance has an auto-assigned public IP address and is located in a default subnet."
          remediationMessage: "Consider moving the instance to a custom subnet intended\
            \ for public resources or removing its public IP address if internet access is not required."
          check:
            IS_EQUAL:
              left:
                FIELD:
                  path: "CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c"
              right:
                BOOLEAN: true
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The instance has an auto-assigned public IP address but\
          \ the Auto-assign Public IPv4 Address subnet attribute is disabled."
      relatedLists:
        - relationshipName: "CA10__AWS_EC2_Elastic_IPs__r"
          conditions: []
          otherwise:
            status: "COMPLIANT"
            currentStateMessage: "This is an Elastic IP address."
  - path: /types/CA10__CaAwsSubnet__c/object.extracts.yaml
    md5Hash: 7F012284F2BF194EA79A157883554CA2
    content: "---\nextracts:\n# Checkbox. Can't have no access, retrieved via ec2:DescribeSubnets\n\
      \  - name: CA10__defaultForAz__c\n    value: \n      FIELD:\n        path: CA10__defaultForAz__c\n\
      # Checkbox. Can't have no access, retrieved via ec2:DescribeSubnets\n  - name:\
      \ CA10__mapPublicIpOnLaunch__c\n    value: \n      FIELD:\n        path: CA10__mapPublicIpOnLaunch__c\n"
  - 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-with-public-ip-in-default-subnet/test-data.json
    md5Hash: 4A4616F804418A47DA4350988B0C4DB5
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-08-26T05:04:13Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2025-08-25T10:52:57Z",
              "CA10__publicIpAddress__c": "",
              "CA10__vpcSubnet__c": "",
              "CA10__subnetId__c": "",
              "CA10__vpcSubnet__r": {
                  "Id": null,
                  "CA10__disappearanceTime__c": null,
                  "CA10__defaultForAz__c": null,
                  "CA10__mapPublicIpOnLaunch__c": null
              },
              "CA10__AWS_EC2_Elastic_IPs__r": []
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__publicIpAddress__c').isEmpty()",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-08-26T05:04:13Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__publicIpAddress__c": "",
              "CA10__vpcSubnet__c": "vpcSubnet2",
              "CA10__subnetId__c": "subnetId2",
              "CA10__vpcSubnet__r": {
                  "Id": "vpcSubnet2",
                  "CA10__disappearanceTime__c": null,
                  "CA10__defaultForAz__c": false,
                  "CA10__mapPublicIpOnLaunch__c": false
              },
              "CA10__AWS_EC2_Elastic_IPs__r": []
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10__AWS_EC2_Elastic_IPs__r.has(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-08-26T05:04:13Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__publicIpAddress__c": "publicIpAddress4",
              "CA10__vpcSubnet__c": "vpcSubnet4",
              "CA10__subnetId__c": "subnetId4",
              "CA10__vpcSubnet__r": {
                  "Id": "vpcSubnet4",
                  "CA10__disappearanceTime__c": null,
                  "CA10__defaultForAz__c": false,
                  "CA10__mapPublicIpOnLaunch__c": false
              },
              "CA10__AWS_EC2_Elastic_IPs__r": [
                  {
                      "Id": "test4_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__instance2__c": "test4"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "CA10__vpcSubnet__r.CA10__defaultForAz__c == false",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-08-26T05:04:13Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__publicIpAddress__c": "publicIpAddress5",
              "CA10__vpcSubnet__c": "vpcSubnet5",
              "CA10__subnetId__c": "subnetId5",
              "CA10__vpcSubnet__r": {
                  "Id": "vpcSubnet5",
                  "CA10__disappearanceTime__c": null,
                  "CA10__defaultForAz__c": false,
                  "CA10__mapPublicIpOnLaunch__c": false
              },
              "CA10__AWS_EC2_Elastic_IPs__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c == true",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-08-26T05:04:13Z"
              },
              "Id": "test6",
              "CA10__disappearanceTime__c": null,
              "CA10__publicIpAddress__c": "publicIpAddress6",
              "CA10__vpcSubnet__c": "vpcSubnet6",
              "CA10__subnetId__c": "subnetId6",
              "CA10__vpcSubnet__r": {
                  "Id": "vpcSubnet6",
                  "CA10__disappearanceTime__c": null,
                  "CA10__defaultForAz__c": true,
                  "CA10__mapPublicIpOnLaunch__c": true
              },
              "CA10__AWS_EC2_Elastic_IPs__r": []
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "399",
                  "conditionText": "isEmptyLookup('CA10__vpcSubnet__r')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-08-26T05:04:13Z"
              },
              "Id": "test7",
              "CA10__disappearanceTime__c": null,
              "CA10__publicIpAddress__c": "publicIpAddress7",
              "CA10__vpcSubnet__c": "vpcSubnet7",
              "CA10__subnetId__c": "subnetId7",
              "CA10__vpcSubnet__r": {
                  "Id": "vpcSubnet7",
                  "CA10__disappearanceTime__c": "2025-08-26T05:04:13Z",
                  "CA10__defaultForAz__c": true,
                  "CA10__mapPublicIpOnLaunch__c": true
              },
              "CA10__AWS_EC2_Elastic_IPs__r": []
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "600",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-08-26T05:04:13Z"
              },
              "Id": "test8",
              "CA10__disappearanceTime__c": null,
              "CA10__publicIpAddress__c": "publicIpAddress8",
              "CA10__vpcSubnet__c": "vpcSubnet8",
              "CA10__subnetId__c": "subnetId8",
              "CA10__vpcSubnet__r": {
                  "Id": "vpcSubnet8",
                  "CA10__disappearanceTime__c": null,
                  "CA10__defaultForAz__c": true,
                  "CA10__mapPublicIpOnLaunch__c": false
              },
              "CA10__AWS_EC2_Elastic_IPs__r": []
          }
      ]
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" : "199",
      "conditionText" : "extract('CA10__publicIpAddress__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_EC2_Elastic_IPs__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "CA10__vpcSubnet__r.CA10__defaultForAz__c == false",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "399",
      "conditionText" : "isEmptyLookup('CA10__vpcSubnet__r')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "600",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsInstance__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__publicIpAddress__c STRING,
      CA10__vpcSubnet__c STRING,
      CA10__subnetId__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2025-08-25T10:52:57Z"),
    "CA10__publicIpAddress__c" : "",
    "CA10__vpcSubnet__c" : "",
    "CA10__subnetId__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "test2",
    "CA10__publicIpAddress__c" : "",
    "CA10__vpcSubnet__c" : "vpcSubnet2",
    "CA10__subnetId__c" : "subnetId2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "test4",
    "CA10__publicIpAddress__c" : "publicIpAddress4",
    "CA10__vpcSubnet__c" : "vpcSubnet4",
    "CA10__subnetId__c" : "subnetId4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "test5",
    "CA10__publicIpAddress__c" : "publicIpAddress5",
    "CA10__vpcSubnet__c" : "vpcSubnet5",
    "CA10__subnetId__c" : "subnetId5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "test6",
    "CA10__publicIpAddress__c" : "publicIpAddress6",
    "CA10__vpcSubnet__c" : "vpcSubnet6",
    "CA10__subnetId__c" : "subnetId6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "test7",
    "CA10__publicIpAddress__c" : "publicIpAddress7",
    "CA10__vpcSubnet__c" : "vpcSubnet7",
    "CA10__subnetId__c" : "subnetId7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "test8",
    "CA10__publicIpAddress__c" : "publicIpAddress8",
    "CA10__vpcSubnet__c" : "vpcSubnet8",
    "CA10__subnetId__c" : "subnetId8"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsSubnet__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__defaultForAz__c BOOLEAN,
      CA10__mapPublicIpOnLaunch__c BOOLEAN,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : null,
    "CA10__defaultForAz__c" : null,
    "CA10__mapPublicIpOnLaunch__c" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "vpcSubnet2",
    "CA10__defaultForAz__c" : false,
    "CA10__mapPublicIpOnLaunch__c" : false
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "vpcSubnet4",
    "CA10__defaultForAz__c" : false,
    "CA10__mapPublicIpOnLaunch__c" : false
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "vpcSubnet5",
    "CA10__defaultForAz__c" : false,
    "CA10__mapPublicIpOnLaunch__c" : false
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "vpcSubnet6",
    "CA10__defaultForAz__c" : true,
    "CA10__mapPublicIpOnLaunch__c" : true
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "vpcSubnet7",
    "CA10__disappearanceTime__c" : new Date("2025-08-26T05:04:13Z"),
    "CA10__defaultForAz__c" : true,
    "CA10__mapPublicIpOnLaunch__c" : true
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "vpcSubnet8",
    "CA10__defaultForAz__c" : true,
    "CA10__mapPublicIpOnLaunch__c" : false
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsElasticIp__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__instance2__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-08-26T05:04:13Z")
    },
    "Id" : "test4_1",
    "CA10__instance2__c" : "test4"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsInstance__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__publicIpAddress__c STRING,
          CA10__vpcSubnet__c STRING,
          CA10__subnetId__c STRING,
          CA10__vpcSubnet__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__defaultForAz__c BOOLEAN,
              CA10__mapPublicIpOnLaunch__c BOOLEAN
          >,
          CA10__AWS_EC2_Elastic_IPs__r ARRAY<STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__instance2__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 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__publicIpAddress__c; } return this.out; };
      references1.push('Public IP Address [obj.CA10__publicIpAddress__c]: ' + obj.CA10__publicIpAddress__c);
      if (TextLib.isEmpty(extract3.call(extract3))) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__publicIpAddress__c').isEmpty()", currentStateMessage: "The instance does not have a public IP address.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_EC2_Elastic_IPs__r_COMPLIANT5 = 0;
      if (obj.CA10__AWS_EC2_Elastic_IPs__r != null) {
          for (var i6 = 0; i6 < obj.CA10__AWS_EC2_Elastic_IPs__r.length; i6++) {
              if (obj.CA10__AWS_EC2_Elastic_IPs__r[i6].result.status == 'COMPLIANT') {
                  count_CA10__AWS_EC2_Elastic_IPs__r_COMPLIANT5 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      references1.push('Related list [CA10__AWS_EC2_Elastic_IPs__r] ' + (count_CA10__AWS_EC2_Elastic_IPs__r_COMPLIANT5 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status');
      if (count_CA10__AWS_EC2_Elastic_IPs__r_COMPLIANT5 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_EC2_Elastic_IPs__r.has(COMPLIANT)", currentStateMessage: "The instance has an Elastic IP address.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      if (TextLib.isEmpty(obj.CA10__subnetId__c) || TextLib.isEmpty(obj.CA10__vpcSubnet__c) || obj.CA10__vpcSubnet__r.CA10__disappearanceTime__c != null) {
          return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "isEmptyLookup('CA10__vpcSubnet__r')", currentStateMessage: "Cannot determine if the instance is in a default subnet because subnet information is missing.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      references1.push('Default For AZ [obj.CA10__vpcSubnet__r.CA10__defaultForAz__c]: ' + obj.CA10__vpcSubnet__r.CA10__defaultForAz__c);
      if (obj.CA10__vpcSubnet__r.CA10__defaultForAz__c == false) {
          return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "CA10__vpcSubnet__r.CA10__defaultForAz__c == false", currentStateMessage: "Instance has a public IP address and is located in a custom subnet.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      references1.push('Map Public IP On Launch [obj.CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c]: ' + obj.CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c);
      if (obj.CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c == true) {
          return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c == true", currentStateMessage: "The instance has an auto-assigned public IP address and is located in a default subnet.", currentStateReferences: references1.join('\n'), remediation: "Consider moving the instance to a custom subnet intended for public resources or removing its public IP address if internet access is not required.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "The instance has an auto-assigned public IP address but the Auto-assign Public IPv4 Address subnet attribute is disabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_EC2_Elastic_IPs__r(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__instance2__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 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};
      }
      return {status: 'COMPLIANT', conditionIndex: 100, conditionText: "otherwise", currentStateMessage: "This is an Elastic IP address.", 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__publicIpAddress__c AS CA10__publicIpAddress__c,
          sObject.CA10__vpcSubnet__c AS CA10__vpcSubnet__c,
          sObject.CA10__subnetId__c AS CA10__subnetId__c,
          STRUCT (
              `CA10__vpcSubnet__r`.Id AS Id,
              `CA10__vpcSubnet__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
              `CA10__vpcSubnet__r`.CA10__defaultForAz__c AS CA10__defaultForAz__c,
              `CA10__vpcSubnet__r`.CA10__mapPublicIpOnLaunch__c AS CA10__mapPublicIpOnLaunch__c
          ) AS CA10__vpcSubnet__r,
          `CA10__AWS_EC2_Elastic_IPs__r`.arr AS CA10__AWS_EC2_Elastic_IPs__r,
          process_CA10__CaAwsInstance__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__publicIpAddress__c AS CA10__publicIpAddress__c,
                  sObject.CA10__vpcSubnet__c AS CA10__vpcSubnet__c,
                  sObject.CA10__subnetId__c AS CA10__subnetId__c,
                  STRUCT (
                      `CA10__vpcSubnet__r`.Id AS Id,
                      `CA10__vpcSubnet__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      `CA10__vpcSubnet__r`.CA10__defaultForAz__c AS CA10__defaultForAz__c,
                      `CA10__vpcSubnet__r`.CA10__mapPublicIpOnLaunch__c AS CA10__mapPublicIpOnLaunch__c
                  ) AS CA10__vpcSubnet__r,
                  `CA10__AWS_EC2_Elastic_IPs__r`.arr AS CA10__AWS_EC2_Elastic_IPs__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsInstance__c()) AS sObject
      LEFT JOIN UNNEST(mock_CA10__CaAwsSubnet__c()) AS `CA10__vpcSubnet__r`
          ON sObject.CA10__vpcSubnet__c = `CA10__vpcSubnet__r`.Id
      LEFT JOIN (
          SELECT
              sObject.CA10__instance2__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__instance2__c AS CA10__instance2__c,
                      process_CA10__AWS_EC2_Elastic_IPs__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__instance2__c AS CA10__instance2__c
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsElasticIp__c()) AS sObject
          GROUP BY sObject.CA10__instance2__c
      ) AS `CA10__AWS_EC2_Elastic_IPs__r`
          ON sObject.Id = `CA10__AWS_EC2_Elastic_IPs__r`.CA10__instance2__c
  ) sObject ON sObject.Id = expectedResult.Id;
