ThoughtWorksStudios / eb_deployer

AWS Elastic Beanstalk blue-green deployment automation from ThoughtWorks Mingle Team
MIT License
400 stars 94 forks source link

Modify EBS default autoscaling group #90

Open Rshomali opened 8 years ago

Rshomali commented 8 years ago

Hi,

I would like to add a scale up and scale down policy to the existing autoscaling group created by EBS. I tried to add a config file under .ebextensions with:

Resources:
  AWSEBAutoScalingGroup:
    Type: "AWS::AutoScaling::AutoScalingGroup"
    Properties:
      HealthCheckType: ELB
      HealthCheckGracePeriod: 300
  ScaleUpPolicy:
    Type: AWS::AutoScaling::ScalingPolicy
    Properties:
      AdjustmentType: "ChangeInCapacity"
      AutoScalingGroupName: { "Ref" : "AWSEBAutoScalingGroup" }
      Cooldown: 60
      ScalingAdjustment: 1
  ScaleDownPolicy:
    Type: AWS::AutoScaling::ScalingPolicy
    Properties:
      AdjustmentType: "ChangeInCapacity"
      AutoScalingGroupName: { "Ref" : "AWSEBAutoScalingGroup" }
      Cooldown: 60
      ScalingAdjustment: -1
  HighCPUUsageAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: "Alarm if CPU Usage > 80%"
      Namespace: "SWF/EC2"
      MetricName: CPUUtilization
      Dimensions:
        - Name: AutoScalingGroupName
          Value: { "Ref" : "AWSEBAutoScalingGroup" }
      Statistic: Average
      Period: 60
      EvaluationPeriods: 1
      Threshold: 80
      ComparisonOperator: GreaterThanThreshold
      AlarmActions:
          - Ref: ScaleUpPolicy

But nothing is changed. I also using CloudFormation template to create AWS resources and it is defined in my eb_deployer.yml:

  resources: &resources
    template: config/resources.json
    inputs:
      <<: *resource_inputs
    outputs:
     . . .

I tried to define the new policy and alarms in resources.json, but the only way I could get it working is by creating and new load balancer to reference. I couldn't find a way to reference the default autoscaling group name in resources.json.

Any help to modify the existing scaling group policy and and more scale up and down policies would be great.

Thanks Rami