|
|
|
|
@ -91,6 +91,51 @@ func TestAccAWSAutoScalingGroup_autoGeneratedName(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccAWSAutoScalingGroup_terminationPolicies(t *testing.T) {
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy,
|
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccAWSAutoScalingGroupConfig_terminationPoliciesEmpty,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_autoscaling_group.bar", "termination_policies.#", "0"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccAWSAutoScalingGroupConfig_terminationPoliciesUpdate,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_autoscaling_group.bar", "termination_policies.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_autoscaling_group.bar", "termination_policies.0", "OldestInstance"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccAWSAutoScalingGroupConfig_terminationPoliciesExplicitDefault,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_autoscaling_group.bar", "termination_policies.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_autoscaling_group.bar", "termination_policies.0", "Default"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccAWSAutoScalingGroupConfig_terminationPoliciesEmpty,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_autoscaling_group.bar", "termination_policies.#", "0"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccAWSAutoScalingGroup_tags(t *testing.T) {
|
|
|
|
|
var group autoscaling.Group
|
|
|
|
|
|
|
|
|
|
@ -415,6 +460,56 @@ resource "aws_autoscaling_group" "bar" {
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testAccAWSAutoScalingGroupConfig_terminationPoliciesEmpty = `
|
|
|
|
|
resource "aws_launch_configuration" "foobar" {
|
|
|
|
|
image_id = "ami-21f78e11"
|
|
|
|
|
instance_type = "t1.micro"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_autoscaling_group" "bar" {
|
|
|
|
|
availability_zones = ["us-west-2a"]
|
|
|
|
|
max_size = 0
|
|
|
|
|
min_size = 0
|
|
|
|
|
desired_capacity = 0
|
|
|
|
|
|
|
|
|
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testAccAWSAutoScalingGroupConfig_terminationPoliciesExplicitDefault = `
|
|
|
|
|
resource "aws_launch_configuration" "foobar" {
|
|
|
|
|
image_id = "ami-21f78e11"
|
|
|
|
|
instance_type = "t1.micro"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_autoscaling_group" "bar" {
|
|
|
|
|
availability_zones = ["us-west-2a"]
|
|
|
|
|
max_size = 0
|
|
|
|
|
min_size = 0
|
|
|
|
|
desired_capacity = 0
|
|
|
|
|
termination_policies = ["Default"]
|
|
|
|
|
|
|
|
|
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testAccAWSAutoScalingGroupConfig_terminationPoliciesUpdate = `
|
|
|
|
|
resource "aws_launch_configuration" "foobar" {
|
|
|
|
|
image_id = "ami-21f78e11"
|
|
|
|
|
instance_type = "t1.micro"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_autoscaling_group" "bar" {
|
|
|
|
|
availability_zones = ["us-west-2a"]
|
|
|
|
|
max_size = 0
|
|
|
|
|
min_size = 0
|
|
|
|
|
desired_capacity = 0
|
|
|
|
|
termination_policies = ["OldestInstance"]
|
|
|
|
|
|
|
|
|
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testAccAWSAutoScalingGroupConfig = `
|
|
|
|
|
resource "aws_launch_configuration" "foobar" {
|
|
|
|
|
image_id = "ami-21f78e11"
|
|
|
|
|
|