Here are the sequence of steps to Create Autoscaling Group using Insisive Cloud API.  A sample in python is attached for reference.


On successful execution , the APIs return 200 status code and additional details depending on the API response.  Check the API documentation for each response.



1. Login 

"login": {

        "email_id":"youremail@sample.com",   #signin user name
        "password":"yourstrongpassword",      #password
        "remember": true                                 # not used for API access
    },


 2. Create a launch template with the required parameters

    '''

        "LaunchTemplateProperties": {

        "LaunchTemplateName": "Example-21",

        "LaunchTemplateType": "ASG",   # use this for AutoScaling Group

        "InstanceType": ["t2.micro"],

        "ImageId": "ami-8024aaff",  

        "SecurityGroups": [

            "sg-03c5be9a2bbe13d38"  # provide security group ID

        ],

        "VPCZoneIdentifier": "subnet-be1a2ae3,subnet-08c3d26c,subnet-b493a09b",  # subnet Identifiers

        "KeyName": "cmp-key-pair", # key pair to log into the system  

        # if Notifications are sent then TopicARN is mandatory. Else, you can ignore both the fields

        "NotificationTypes": ["autoscaling:TEST_NOTIFICATION", "autoscaling:EC2_INSTANCE_LAUNCH",

                              "autoscaling:EC2_INSTANCE_LAUNCH_ERROR", "autoscaling:EC2_INSTANCE_TERMINATE",

                              "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"],

        "TopicARN": "arn:aws:sns:us-east-1:388603454435:cmp-notification-args",


        # Availability zones and subnets should match! Else ASG creation will fail.

        "AvailabilityZones": [

            "us-east-1a", "us-east-1b", "us-east-1c"

        ],

        "Tags": [


            {"Key": "LT_Tag",

             "Value": "LT_Value"}

        ]


    '''

3 Create a auto scaling group using the parameters below.  The application context is as below 


Optimal

Optimized for both Cost and Availability. Attempt to minimize spot instance terminations. Replace instances with other spot instances or OnDemand Instances in some limited situations.

Maximum Availability

Optimized for both Cost and Availability. Attempt to minimize spot instance terminations. Replace instances with other spot instances or OnDemand Instances in some limited situations.

Minimum Price

Optimized for both Cost and Availability. Attempt to minimize spot instance terminations. Replace instances with other spot instances or OnDemand Instances in some limited situations.


You can add additional tags, change the scaling policy etc.


{
        "AutoScalingProperties":{
        "region": "us-east-1",
        "LCName": "new_asg_template"  # Autoscaling group Template. Use the newly created one or an existing template    ,
        "name": "ASG_new_test,   # The name of the ASG to create
        "ApplicationContext":"Minimum_Price",   # the Application context to use  'Minimum_Price' or 'Optimal'  'Maximum_Availability'
        "MinInstanceCount": 1,
        "MaxInstanceCount": 1,
        "DesiredInstanceCount": 1,
        "HealthCheckInterval":300,
        "CollectMetrics":false,
        "LoadBalancerNames":[
           "classicelb"
         ],
        "TargetGroupARNs":[
           "arn:aws:elasticloadbalancing:us-east-1:388603454435:targetgroup/insisivecloud-tg/4d708437192bd007"
         ],
        "ScalingProperties" :[ {
            "PolicyType" : "StepScaling",
             "AdjustmentType" : "ChangeInCapacity",
             "PolicyName" : "ScaleUpASG",
             "EstimatedInstanceWarmup" : 300,
             "StepAdjustments" : [{
               "MetricIntervalLowerBound": 0.0,
               "ScalingAdjustment": 1
             }],
             "MetricName":"CPUUtilization",
             "Threshold": 60,
             "Period": 60,
             "MetricAggregationType": "Average",
             "ComparisonOperator":"GreaterThanOrEqualToThreshold",
             "Dimensions" : [{"Name" : "AutoScalingGroupName", "Value":""}]
         },{
            "PolicyType" : "StepScaling",
             "AdjustmentType" : "ChangeInCapacity",
             "PolicyName" : "ScaleInASG",
             "EstimatedInstanceWarmup" : 300,
             "StepAdjustments" : [{
               "MetricIntervalUpperBound": 0.0,
               "ScalingAdjustment": -1
             }],
             "MetricName":"CPUUtilization",
             "Threshold": 30,
             "Period": 60,
             "MetricAggregationType": "Average",
             "ComparisonOperator":"LessThanOrEqualToThreshold",
             "Dimensions" : [{"Name" : "AutoScalingGroupName", "Value":""}]
         }],
        "tags":[
              { "Key": "OS",
              "Value" : "Linux" }
              ]
       }}