Merge pull request #4693 from stack72/f-aws-asg-schedule-0values
provider/aws: aws autoscale schedule 0 values
This commit is contained in:
commit
05d19b0fc3
|
@ -97,17 +97,9 @@ func resourceAwsAutoscalingScheduleCreate(d *schema.ResourceData, meta interface
|
|||
params.Recurrence = aws.String(attr.(string))
|
||||
}
|
||||
|
||||
if attr, ok := d.GetOk("min_size"); ok {
|
||||
params.MinSize = aws.Int64(int64(attr.(int)))
|
||||
}
|
||||
|
||||
if attr, ok := d.GetOk("max_size"); ok {
|
||||
params.MaxSize = aws.Int64(int64(attr.(int)))
|
||||
}
|
||||
|
||||
if attr, ok := d.GetOk("desired_capacity"); ok {
|
||||
params.DesiredCapacity = aws.Int64(int64(attr.(int)))
|
||||
}
|
||||
params.MinSize = aws.Int64(int64(d.Get("min_size").(int)))
|
||||
params.MaxSize = aws.Int64(int64(d.Get("max_size").(int)))
|
||||
params.DesiredCapacity = aws.Int64(int64(d.Get("desired_capacity").(int)))
|
||||
|
||||
log.Printf("[INFO] Creating Autoscaling Scheduled Action: %s", d.Get("scheduled_action_name").(string))
|
||||
_, err := autoscalingconn.PutScheduledUpdateGroupAction(params)
|
||||
|
|
|
@ -47,6 +47,24 @@ func TestAccAWSAutoscalingSchedule_recurrence(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSAutoscalingSchedule_zeroValues(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_zeroValues,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckScalingScheduleExists("aws_autoscaling_schedule.foobar", &schedule),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckScalingScheduleExists(n string, policy *autoscaling.ScheduledUpdateGroupAction) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
@ -168,3 +186,38 @@ resource "aws_autoscaling_schedule" "foobar" {
|
|||
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
|
||||
}
|
||||
`)
|
||||
|
||||
var testAccAWSAutoscalingScheduleConfig_zeroValues = 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"
|
||||
max_size = 0
|
||||
min_size = 0
|
||||
desired_capacity = 0
|
||||
start_time = "2018-01-16T07:00:00Z"
|
||||
end_time = "2018-01-16T13:00:00Z"
|
||||
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
|
||||
}
|
||||
`)
|
||||
|
|
|
@ -45,11 +45,13 @@ The following arguments are supported:
|
|||
* `end_time` - (Optional) The time for this action to end, in "YYYY-MM-DDThh:mm:ssZ" format in UTC/GMT only (for example, 2014-06-01T00:00:00Z ).
|
||||
If you try to schedule your action in the past, Auto Scaling returns an error messag
|
||||
* `recurrence` - (Optional) The time when recurring future actions will start. Start time is specified by the user following the Unix cron syntax format.
|
||||
* `min_size` - (Optional) The minimum size for the Auto Scaling group.
|
||||
* `max_size` - (Optional) The maximum size for the Auto Scaling group.
|
||||
* `desired_capacity` - (Optional) The number of EC2 instances that should be running in the group.
|
||||
* `min_size` - (Optional) The minimum size for the Auto Scaling group. Default
|
||||
0.
|
||||
* `max_size` - (Optional) The maximum size for the Auto Scaling group. Default
|
||||
0.
|
||||
* `desired_capacity` - (Optional) The number of EC2 instances that should be running in the group. Default 0.
|
||||
|
||||
~> **NOTE:** When `start_time` and `end_time` are specified with `recurrence` , they form the boundaries of when the recurring action will start and stop.
|
||||
|
||||
## Attribute Reference
|
||||
* `arn` - The ARN assigned by AWS to the autoscaling schedule.
|
||||
* `arn` - The ARN assigned by AWS to the autoscaling schedule.
|
||||
|
|
Loading…
Reference in New Issue