Skip to content

Commit

Permalink
Merge pull request #19829 from maerlyn/f-aws_autoscaling_schedule-tim…
Browse files Browse the repository at this point in the history
…e_zone

Add time_zone parameter to aws_autoscaling_schedule
  • Loading branch information
bill-rich authored Jul 30, 2021
2 parents 9499333 + 608857d commit c4113a2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/19829.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-notes:enhancement
resource/aws_autoscaling_schedule: Add time_zone argument
```
13 changes: 13 additions & 0 deletions aws/resource_aws_autoscaling_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func resourceAwsAutoscalingSchedule() *schema.Resource {
Computed: true,
ValidateFunc: validateASGScheduleTimestamp,
},
"time_zone": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"recurrence": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -119,6 +124,10 @@ func resourceAwsAutoscalingScheduleCreate(d *schema.ResourceData, meta interface
params.EndTime = aws.Time(t)
}

if attr, ok := d.GetOk("time_zone"); ok {
params.TimeZone = aws.String(attr.(string))
}

if attr, ok := d.GetOk("recurrence"); ok {
params.Recurrence = aws.String(attr.(string))
}
Expand Down Expand Up @@ -194,6 +203,10 @@ func resourceAwsAutoscalingScheduleRead(d *schema.ResourceData, meta interface{}
d.Set("end_time", sa.EndTime.Format(awsAutoscalingScheduleTimeLayout))
}

if sa.TimeZone != nil {
d.Set("time_zone", sa.TimeZone)
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_autoscaling_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ resource "aws_autoscaling_schedule" "foobar" {
max_size = 1
desired_capacity = 0
recurrence = "0 8 * * *"
time_zone = "Pacific/Tahiti"
autoscaling_group_name = aws_autoscaling_group.foobar.name
}
`, r, r)
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/autoscaling_schedule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ 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 message.
* `recurrence` - (Optional) The time when recurring future actions will start. Start time is specified by the user following the Unix cron syntax format.
* `time_zone` - (Optional) The timezone for the cron expression. Valid values are the canonical names of the IANA time zones (such as Etc/GMT+9 or Pacific/Tahiti).
* `min_size` - (Optional) The minimum size for the Auto Scaling group. Default 0.
Set to -1 if you don't want to change the minimum size at the scheduled time.
* `max_size` - (Optional) The maximum size for the Auto Scaling group. Default 0.
Expand Down

0 comments on commit c4113a2

Please sign in to comment.