@@ -21,9 +21,20 @@ func TestAccAWSAutoscalingPolicy_basic(t *testing.T) {
2121 resource.TestStep {
2222 Config : testAccAWSAutoscalingPolicyConfig ,
2323 Check : resource .ComposeTestCheckFunc (
24- testAccCheckScalingPolicyExists ("aws_autoscaling_policy.foobar" , & policy ),
25- resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar" , "adjustment_type" , "ChangeInCapacity" ),
26- resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar" , "cooldown" , "300" ),
24+ testAccCheckScalingPolicyExists ("aws_autoscaling_policy.foobar_simple" , & policy ),
25+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_simple" , "adjustment_type" , "ChangeInCapacity" ),
26+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_simple" , "policy_type" , "SimpleScaling" ),
27+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_simple" , "cooldown" , "300" ),
28+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_simple" , "name" , "foobar_simple" ),
29+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_simple" , "scaling_adjustment" , "2" ),
30+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_simple" , "autoscaling_group_name" , "terraform-test-foobar5" ),
31+ testAccCheckScalingPolicyExists ("aws_autoscaling_policy.foobar_step" , & policy ),
32+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_step" , "adjustment_type" , "ChangeInCapacity" ),
33+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_step" , "policy_type" , "StepScaling" ),
34+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_step" , "name" , "foobar_step" ),
35+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_step" , "metric_aggregation_type" , "Minimum" ),
36+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_step" , "estimated_instance_warmup" , "200" ),
37+ resource .TestCheckResourceAttr ("aws_autoscaling_policy.foobar_step" , "autoscaling_group_name" , "terraform-test-foobar5" ),
2738 ),
2839 },
2940 },
@@ -82,33 +93,47 @@ func testAccCheckAWSAutoscalingPolicyDestroy(s *terraform.State) error {
8293
8394var testAccAWSAutoscalingPolicyConfig = fmt .Sprintf (`
8495resource "aws_launch_configuration" "foobar" {
85- name = "terraform-test-foobar5"
86- image_id = "ami-21f78e11"
87- instance_type = "t1.micro"
96+ name = "terraform-test-foobar5"
97+ image_id = "ami-21f78e11"
98+ instance_type = "t1.micro"
8899}
89100
90101resource "aws_autoscaling_group" "foobar" {
91- availability_zones = ["us-west-2a"]
92- name = "terraform-test-foobar5"
93- max_size = 5
94- min_size = 2
95- health_check_grace_period = 300
96- health_check_type = "ELB"
97- force_delete = true
98- termination_policies = ["OldestInstance"]
99- launch_configuration = "${aws_launch_configuration.foobar.name}"
100- tag {
101- key = "Foo"
102- value = "foo-bar"
103- propagate_at_launch = true
104- }
102+ availability_zones = ["us-west-2a"]
103+ name = "terraform-test-foobar5"
104+ max_size = 5
105+ min_size = 2
106+ health_check_grace_period = 300
107+ health_check_type = "ELB"
108+ force_delete = true
109+ termination_policies = ["OldestInstance"]
110+ launch_configuration = "${aws_launch_configuration.foobar.name}"
111+ tag {
112+ key = "Foo"
113+ value = "foo-bar"
114+ propagate_at_launch = true
115+ }
116+ }
117+
118+ resource "aws_autoscaling_policy" "foobar_simple" {
119+ name = "foobar_simple"
120+ adjustment_type = "ChangeInCapacity"
121+ cooldown = 300
122+ policy_type = "SimpleScaling"
123+ scaling_adjustment = 2
124+ autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
105125}
106126
107- resource "aws_autoscaling_policy" "foobar" {
108- name = "foobar"
109- scaling_adjustment = 4
110- adjustment_type = "ChangeInCapacity"
111- cooldown = 300
112- autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
127+ resource "aws_autoscaling_policy" "foobar_step" {
128+ name = "foobar_step"
129+ adjustment_type = "ChangeInCapacity"
130+ policy_type = "StepScaling"
131+ estimated_instance_warmup = 200
132+ metric_aggregation_type = "Minimum"
133+ step_adjustment {
134+ scaling_adjustment = 1
135+ metric_interval_lower_bound = 2.0
136+ }
137+ autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
113138}
114139` )
0 commit comments