|
|
|
|
@ -21,9 +21,20 @@ func TestAccAWSAutoscalingPolicy_basic(t *testing.T) {
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccAWSAutoscalingPolicyConfig,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckScalingPolicyExists("aws_autoscaling_policy.foobar", &policy),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar", "adjustment_type", "ChangeInCapacity"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar", "cooldown", "300"),
|
|
|
|
|
testAccCheckScalingPolicyExists("aws_autoscaling_policy.foobar_simple", &policy),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "adjustment_type", "ChangeInCapacity"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "policy_type", "SimpleScaling"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "cooldown", "300"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "name", "foobar_simple"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "scaling_adjustment", "2"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "autoscaling_group_name", "terraform-test-foobar5"),
|
|
|
|
|
testAccCheckScalingPolicyExists("aws_autoscaling_policy.foobar_step", &policy),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "adjustment_type", "ChangeInCapacity"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "policy_type", "StepScaling"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "name", "foobar_step"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "metric_aggregation_type", "Minimum"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "estimated_instance_warmup", "200"),
|
|
|
|
|
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "autoscaling_group_name", "terraform-test-foobar5"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
@ -82,33 +93,47 @@ func testAccCheckAWSAutoscalingPolicyDestroy(s *terraform.State) error {
|
|
|
|
|
|
|
|
|
|
var testAccAWSAutoscalingPolicyConfig = fmt.Sprintf(`
|
|
|
|
|
resource "aws_launch_configuration" "foobar" {
|
|
|
|
|
name = "terraform-test-foobar5"
|
|
|
|
|
image_id = "ami-21f78e11"
|
|
|
|
|
instance_type = "t1.micro"
|
|
|
|
|
name = "terraform-test-foobar5"
|
|
|
|
|
image_id = "ami-21f78e11"
|
|
|
|
|
instance_type = "t1.micro"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_autoscaling_group" "foobar" {
|
|
|
|
|
availability_zones = ["us-west-2a"]
|
|
|
|
|
name = "terraform-test-foobar5"
|
|
|
|
|
max_size = 5
|
|
|
|
|
min_size = 2
|
|
|
|
|
health_check_grace_period = 300
|
|
|
|
|
health_check_type = "ELB"
|
|
|
|
|
force_delete = true
|
|
|
|
|
termination_policies = ["OldestInstance"]
|
|
|
|
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
|
|
|
|
tag {
|
|
|
|
|
key = "Foo"
|
|
|
|
|
value = "foo-bar"
|
|
|
|
|
propagate_at_launch = true
|
|
|
|
|
}
|
|
|
|
|
availability_zones = ["us-west-2a"]
|
|
|
|
|
name = "terraform-test-foobar5"
|
|
|
|
|
max_size = 5
|
|
|
|
|
min_size = 2
|
|
|
|
|
health_check_grace_period = 300
|
|
|
|
|
health_check_type = "ELB"
|
|
|
|
|
force_delete = true
|
|
|
|
|
termination_policies = ["OldestInstance"]
|
|
|
|
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
|
|
|
|
tag {
|
|
|
|
|
key = "Foo"
|
|
|
|
|
value = "foo-bar"
|
|
|
|
|
propagate_at_launch = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_autoscaling_policy" "foobar_simple" {
|
|
|
|
|
name = "foobar_simple"
|
|
|
|
|
adjustment_type = "ChangeInCapacity"
|
|
|
|
|
cooldown = 300
|
|
|
|
|
policy_type = "SimpleScaling"
|
|
|
|
|
scaling_adjustment = 2
|
|
|
|
|
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_autoscaling_policy" "foobar" {
|
|
|
|
|
name = "foobar"
|
|
|
|
|
scaling_adjustment = 4
|
|
|
|
|
adjustment_type = "ChangeInCapacity"
|
|
|
|
|
cooldown = 300
|
|
|
|
|
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
|
|
|
|
|
resource "aws_autoscaling_policy" "foobar_step" {
|
|
|
|
|
name = "foobar_step"
|
|
|
|
|
adjustment_type = "ChangeInCapacity"
|
|
|
|
|
policy_type = "StepScaling"
|
|
|
|
|
estimated_instance_warmup = 200
|
|
|
|
|
metric_aggregation_type = "Minimum"
|
|
|
|
|
step_adjustment {
|
|
|
|
|
scaling_adjustment = 1
|
|
|
|
|
metric_interval_lower_bound = 2.0
|
|
|
|
|
}
|
|
|
|
|
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
|
|
|
|
|
}
|
|
|
|
|
`)
|
|
|
|
|
|