---
inputType: "CA10__CaAwsAutoScalingGroup__c"
importExtracts:
  - file: "/types/CA10__CaAwsAutoScalingGroupTrafficSourceLink__c/object.extracts.yaml"
  - file: "/types/CA10__CaAwsAutoScalingGroup__c/object.extracts.yaml"
  - file: "/types/CA10__CaAwsLaunchConfiguration__c/object.extracts.yaml"
testData:
  - file: "test-data.json"  
conditions:
  - status: "INAPPLICABLE"
    currentStateMessage: "The AGS is not associated with a Load Balancer."
    check:
      RELATED_LIST_HAS_NO:
        relationshipName: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r"
        status: "COMPLIANT"
  - status: "INAPPLICABLE"
    currentStateMessage: "The AGS does not use a launch configuration."
    check:
      IS_EMPTY:
        arg:
          EXTRACT: "CA10__launchConfigurationName__c"
  - status: "UNDETERMINED"
    currentStateMessage: "The launch configuration does not exist in the CMDB."
    check:
      IS_EMPTY_LOOKUP: "CA10__launchConfiguration__r"
  - status: "INCOMPLIANT"
    currentStateMessage: "The Launch Configuration specifies to assign a public\
      \ IPv4 address to the group's instances."
    remediationMessage: "Consider disabling the option of assigning a public IP \
      \ to instances behind a load balancer."
    check:
      IS_EQUAL:
        left:
          EXTRACT: "CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c"
        right:
          BOOLEAN: true
  - status: "COMPLIANT"
    currentStateMessage: "Auto Scaling doesn't assign a public IP address\
      \ to the group's instances behind a load balancer."
    check:
      IS_EQUAL:
        left:
          EXTRACT: "CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c"
        right:
          BOOLEAN: false
otherwise:
  status: "UNDETERMINED"
  currentStateMessage: "Unexpected values in the fields."
relatedLists:
  - relationshipName: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r"
    conditions:
      - status: "COMPLIANT"
        currentStateMessage: "The ASG traffic source is a Classic Load Balancer."
        check:
          IS_EQUAL:
            left:
              EXTRACT: "CA10__trafficSourceType__c"
            right:
              TEXT: "elb"
      - status: "COMPLIANT"
        currentStateMessage: "The ASG traffic source is an ELB target group."
        check:
          IS_EQUAL:
            left:
              EXTRACT: "CA10__trafficSourceType__c"
            right:
              TEXT: "elbv2"
    otherwise:
      status: "INAPPLICABLE"
      currentStateMessage: "Unrelated ASG traffic source."