Bug fixes for aws_autoscaling_schedule resource
- Fix typo s/recurrance/recurrence - Fix missing nil check on EndTime that was crashing
This commit is contained in:
parent
b6907f9bd4
commit
5c68858c5b
|
@ -93,7 +93,7 @@ func resourceAwsAutoscalingScheduleCreate(d *schema.ResourceData, meta interface
|
|||
params.EndTime = aws.Time(t)
|
||||
}
|
||||
|
||||
if attr, ok := d.GetOk("recurrance"); ok {
|
||||
if attr, ok := d.GetOk("recurrence"); ok {
|
||||
params.Recurrence = aws.String(attr.(string))
|
||||
}
|
||||
|
||||
|
@ -131,9 +131,15 @@ func resourceAwsAutoscalingScheduleRead(d *schema.ResourceData, meta interface{}
|
|||
d.Set("desired_capacity", sa.DesiredCapacity)
|
||||
d.Set("min_size", sa.MinSize)
|
||||
d.Set("max_size", sa.MaxSize)
|
||||
d.Set("recurrance", sa.Recurrence)
|
||||
d.Set("start_time", sa.StartTime.Format(awsAutoscalingScheduleTimeLayout))
|
||||
d.Set("end_time", sa.EndTime.Format(awsAutoscalingScheduleTimeLayout))
|
||||
d.Set("recurrence", sa.Recurrence)
|
||||
|
||||
if sa.StartTime != nil {
|
||||
d.Set("start_time", sa.StartTime.Format(awsAutoscalingScheduleTimeLayout))
|
||||
}
|
||||
|
||||
if sa.EndTime != nil {
|
||||
d.Set("end_time", sa.EndTime.Format(awsAutoscalingScheduleTimeLayout))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -28,6 +28,25 @@ func TestAccAWSAutoscalingSchedule_basic(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSAutoscalingSchedule_recurrence(t *testing.T) {
|
||||
var schedule autoscaling.ScheduledUpdateGroupAction
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSAutoscalingScheduleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSAutoscalingScheduleConfig_recurrence,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckScalingScheduleExists("aws_autoscaling_schedule.foobar", &schedule),
|
||||
resource.TestCheckResourceAttr("aws_autoscaling_schedule.foobar", "recurrence", "0 8 * * *"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckScalingScheduleExists(n string, policy *autoscaling.ScheduledUpdateGroupAction) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
@ -115,3 +134,37 @@ resource "aws_autoscaling_schedule" "foobar" {
|
|||
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
|
||||
}
|
||||
`)
|
||||
|
||||
var testAccAWSAutoscalingScheduleConfig_recurrence = fmt.Sprintf(`
|
||||
resource "aws_launch_configuration" "foobar" {
|
||||
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 = 1
|
||||
min_size = 1
|
||||
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_schedule" "foobar" {
|
||||
scheduled_action_name = "foobar"
|
||||
min_size = 0
|
||||
max_size = 1
|
||||
desired_capacity = 0
|
||||
recurrence = "0 8 * * *"
|
||||
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
|
||||
}
|
||||
`)
|
||||
|
|
Loading…
Reference in New Issue