---
inputType: "CA10__CaAwsInstance__c"
importExtracts:
  - file: "/types/CA10__CaAwsInstance__c/object.extracts.yaml"
testData:
  - file: 'test-data.json'
conditions:
  - status: "INAPPLICABLE"
    currentStateMessage: "The instance is not running."
    check:
      NOT_EQUAL:
        left:
          EXTRACT: "CA10__stateName__c"
        right:
          TEXT: "running"
  - status: "INAPPLICABLE"
    currentStateMessage: "The instance has been running for less than 14 days."
    check:
      LESS_THAN:
        left:
          EXTRACT: "CA10__currentRunningTime__c"
        right:
          NUMBER: 14.0
  - status: UNDETERMINED
    currentStateMessage: "There is not enough data in the CMDB to identify if the instance is underutilized."
    check:
      OR:
        args:
          - IS_EMPTY:
              arg:
                EXTRACT: "CA10__averageCpuTwoWeeks__c"
          - IS_EMPTY:
              arg:
                EXTRACT: "CA10__maxCpuTwoWeeks__c"
  - status: INAPPLICABLE
    currentStateMessage: "The instance is idle and considered by the 'AWS EC2 Instance is idle' policy."
    check:
      AND:
        args:
          - LESS_THAN:
              left:
                EXTRACT: CA10__averageCpuTwoWeeks__c
              right:
                NUMBER: 5.0
          - LESS_THAN:
              left:
                EXTRACT: CA10__maxCpuTwoWeeks__c
              right:
                NUMBER: 15.0
          - LESS_THAN:
              left:
                EXTRACT: CA10__sumTwoWeekNetworkInMb__c
              right:
                NUMBER: 100.0
          - LESS_THAN:
              left:
                EXTRACT: CA10__sumTwoWeekNetworkOutMb__c
              right:
                NUMBER: 100.0
  - status: "INCOMPLIANT"
    currentStateMessage: "The instance is underutilized with Average CPU Utilization < 40%\
      \ and Max CPU Utilization < 50%."
    remediationMessage: "Consider rightsizing, consolidating or terminating the instance."
    check:
      AND:
        args:
          - LESS_THAN:
              left:
                EXTRACT: CA10__averageCpuTwoWeeks__c
              right:
                NUMBER: 40.0
          - LESS_THAN:
              left:
                EXTRACT: CA10__maxCpuTwoWeeks__c
              right:
                NUMBER: 50.0
otherwise:
  status: "COMPLIANT"
  currentStateMessage: 'The instance is not underutilized.'