autoscaling - how to set up scaling policies

1,125 views
Skip to first unread message

Sathiya Shunmugasundaram

unread,
Mar 8, 2015, 9:03:46 AM3/8/15
to terrafo...@googlegroups.com
Hello,

Does terraform provide a hook yet to create scaling policies for auto scaling groups

Thx

Jesse Merlin

unread,
Mar 9, 2015, 6:58:40 PM3/9/15
to terrafo...@googlegroups.com
From what I can tell by looking at the AWS provider Terraform currently does not provide this support.


It looks like the support is in the AWS API client Terraform is using, just not currently implemented.

I wonder if this is in the roadmap, as it's a pretty key feature for auto-scaling groups.

Sanju Burkule

unread,
Jun 27, 2015, 7:53:26 AM6/27/15
to terrafo...@googlegroups.com
Hi

Any idea on a workaround till the create scaling policies are implemented? 

Thx

Sathiya S

unread,
Jun 27, 2015, 8:19:36 AM6/27/15
to terrafo...@googlegroups.com
I am using a Local Provisioner to call CLI to add scaling policy, let me know if you need as sample code

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Terraform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/terraform-tool/EBWHxTtbbtk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/d18d1780-f4c9-4a2f-ad9e-e7dc168e3812%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Matheny

unread,
Jul 1, 2015, 12:50:47 AM7/1/15
to terrafo...@googlegroups.com
Sathiya, Can you provide that example?

Christophe Chaudier

unread,
Jul 1, 2015, 5:35:16 AM7/1/15
to terrafo...@googlegroups.com
Hello.

I wan't do the same things.
Sathiya, I also need some sample code.

Thank's
Christophe Chaudier

Sathiya Shunmugasundaram

unread,
Jul 1, 2015, 1:37:15 PM7/1/15
to terrafo...@googlegroups.com
Check out this.

  • Ensure that you have AWS CLI installed in your workstation wherever you run Terraform and is in path. Just type aws and you should be able to see something
  • The command creates Scaleout and Scalein policies along with CloudWatch alarms. You need an SNS Topic for alarm.
  • The command creates few transient files to process in next stage after each command. You can clean up those files as needed, doesn't hurt to leave them there.
  • I only used CPU metrics, feel free to extend it to other metrics 
Let me know if this helps.

Thx
Sathiya

provisioner "local-exec" {
        command = "aws autoscaling put-scaling-policy --auto-scaling-group-name ${aws_autoscaling_group.oupf-app-as.name} --policy-name ScaleIn --scaling-adjustment ${var.scalein_adjustment} --adjustment-type ChangeInCapacity > ScaleIn.json;aws autoscaling put-scaling-policy --auto-scaling-group-name ${aws_autoscaling_group.oupf-app-as.name} --policy-name ScaleOut --scaling-adjustment ${var.scaleout_adjustment} --adjustment-type ChangeInCapacity > ScaleOut.json;export SCALEOUT_POLICY=$(cat ScaleOut.json | grep PolicyARN | awk -F'\"PolicyARN\": \"' '{print $2}' | awk -F'\"' '{print $1}');export SCALEIN_POLICY=$(cat ScaleIn.json | grep PolicyARN | awk -F'\"PolicyARN\": \"' '{print $2}' | awk -F'\"' '{print $1}');echo  $SCALEOUT_POLICY > scaleout_policy ;echo $SCALEIN_POLICY > scalein_policy;aws cloudwatch put-metric-alarm --alarm-name ${aws_autoscaling_group.oupf-app-as.name}-scaleout --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period ${var.scaleout_alarm_cpu_interval_secs} --threshold ${var.scaleout_cpu_percent} --comparison-operator GreaterThanOrEqualToThreshold --dimensions \"Name=AutoScalingGroupName,Value=${aws_autoscaling_group.oupf-app-as.name}\" --evaluation-periods ${var.scaleout_evaluation_periods} --alarm-actions $SCALEOUT_POLICY ${var.sns_topic};aws cloudwatch put-metric-alarm --alarm-name ${aws_autoscaling_group.oupf-app-as.name}-scalein --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period ${var.scalein_alarm_cpu_interval_secs} --threshold ${var.scalein_cpu_percent} --comparison-operator LessThanOrEqualToThreshold --dimensions \"Name=AutoScalingGroupName,Value=${aws_autoscaling_group.oupf-app-as.name}\" --evaluation-periods ${var.scalein_evaluation_periods} --alarm-actions $SCALEIN_POLICY ${var.sns_topic}}"
  }

  variable "sns_topic" {
    description = "SNS Topic ID"
    default = "arn:aws:sns:us-east-1:XXXXXXXXXXX"
}

variable "scaleout_cpu_percent" {
    description = "scaleout_cpu_percent"
    default = "80"
}

variable "scalein_cpu_percent" {
    description = "scaleout_cpu_percent"
    default = "5"
}

variable "scaleout_alarm_cpu_interval_secs" {
    description = "scaleout_cpu_percent"
    default = "3600"
}

variable "scalein_alarm_cpu_interval_secs" {
    description = "scaleout_cpu_percent"
    default = "3600"
}

variable "scaleout_evaluation_periods" {
    description = "scaleout_cpu_percent"
    default = "23"
}

variable "scalein_evaluation_periods" {
    description = "scaleout_cpu_percent"
    default = "23"
}

variable "scalein_adjustment" {
    description = "scalein_adjustment"
    default = "-1"
}

variable "scaleout_adjustment" {
    description = "scalein_adjustment"
    default = "1"

Sathiya Shunmugasundaram

unread,
Jul 1, 2015, 2:40:12 PM7/1/15
to terrafo...@googlegroups.com
Looks like 0.6 is released and you may not need this :)

Christophe Chaudier

unread,
Jul 1, 2015, 2:50:46 PM7/1/15
to terrafo...@googlegroups.com
So good ^^
Juste a the good time for me ^^.


Cordialement,
Christophe Chaudier

You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/0f49999a-97bc-46f7-8486-f05daad21b02%40googlegroups.com.

SATHIYA SHUNMUGASUNDARAM

unread,
Jul 1, 2015, 7:26:28 PM7/1/15
to terrafo...@googlegroups.com
Yes, good luck

You can always use this CLI approach to glue any missing features

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages