---
inputType: "CA10__CaAwsElasticsearchDomain__c"
testData:
  - file: "test-data.json"
importExtracts:
  - file: "/types/CA10__CaAwsElasticsearchDomain__c/object.extracts.yaml"
conditions:
  - status: "UNDETERMINED"
    currentStateMessage: "The instance count or zone awareness status is not populated in the CMDB."
    check:
      OR:
        args:
          - IS_EMPTY:
              arg:
                EXTRACT: "CA10__clusterConfigInstanceCount__c"
          - IS_EMPTY:
              arg:
                EXTRACT: "CA10__clusterConfigZoneAwarenessEnabled__c"
  - status: "INCOMPLIANT"
    currentStateMessage: "Zone Awareness is disabled for this OpenSearch domain."
    remediationMessage: "Enable Zone Awareness to distribute nodes across multiple Availability Zones."
    check:
      IS_EQUAL:
        left:
          EXTRACT: "CA10__clusterConfigZoneAwarenessEnabled__c"
        right:
          TEXT: "false"
  - status: "INCOMPLIANT"
    currentStateMessage: "The OpenSearch Domain has fewer than 3 instances."
    remediationMessage: "Increase the instance count to at least 3 for high availability."
    check:
      LESS_THAN:
        left:
          EXTRACT: "CA10__clusterConfigInstanceCount__c"
        right:
          NUMBER: 3.0
  - status: "COMPLIANT"
    currentStateMessage: "The OpenSearch domain has at least 3 instances and Zone Awareness is enabled."
    check:
      AND:
        args:
          - IS_EQUAL:
              left:
                EXTRACT: "CA10__clusterConfigZoneAwarenessEnabled__c"
              right:
                TEXT: "true"
          - GREATER_THAN_EQUAL:
              left:
                EXTRACT: "CA10__clusterConfigInstanceCount__c"
              right:
                NUMBER: 3.0
otherwise:
  status: "UNDETERMINED"
  currentStateMessage: "Unexpected values in the fields."