Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change custom time layout to RFC3339 in spot_fleet_request #4463

Merged
merged 1 commit into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions aws/resource_aws_spot_fleet_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,16 @@ func resourceAwsSpotFleetRequest() *schema.Resource {
ForceNew: true,
},
"valid_from": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validateRFC3339TimeString,
},
"valid_until": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validateRFC3339TimeString,
},
"spot_request_state": {
Type: schema.TypeString,
Expand Down Expand Up @@ -601,22 +603,22 @@ func resourceAwsSpotFleetRequestCreate(d *schema.ResourceData, meta interface{})
}

if v, ok := d.GetOk("valid_from"); ok {
valid_from, err := time.Parse(awsAutoscalingScheduleTimeLayout, v.(string))
valid_from, err := time.Parse(time.RFC3339, v.(string))
if err != nil {
return err
}
spotFleetConfig.ValidFrom = &valid_from
spotFleetConfig.ValidFrom = aws.Time(valid_from)
}

if v, ok := d.GetOk("valid_until"); ok {
valid_until, err := time.Parse(awsAutoscalingScheduleTimeLayout, v.(string))
valid_until, err := time.Parse(time.RFC3339, v.(string))
if err != nil {
return err
}
spotFleetConfig.ValidUntil = &valid_until
spotFleetConfig.ValidUntil = aws.Time(valid_until)
} else {
valid_until := time.Now().Add(24 * time.Hour)
spotFleetConfig.ValidUntil = &valid_until
spotFleetConfig.ValidUntil = aws.Time(valid_until)
}

if v, ok := d.GetOk("load_balancers"); ok && v.(*schema.Set).Len() > 0 {
Expand Down Expand Up @@ -880,12 +882,12 @@ func resourceAwsSpotFleetRequestRead(d *schema.ResourceData, meta interface{}) e

if config.ValidFrom != nil {
d.Set("valid_from",
aws.TimeValue(config.ValidFrom).Format(awsAutoscalingScheduleTimeLayout))
aws.TimeValue(config.ValidFrom).Format(time.RFC3339))
}

if config.ValidUntil != nil {
d.Set("valid_until",
aws.TimeValue(config.ValidUntil).Format(awsAutoscalingScheduleTimeLayout))
aws.TimeValue(config.ValidUntil).Format(time.RFC3339))
}

d.Set("replace_unhealthy_instances", config.ReplaceUnhealthyInstances)
Expand Down
5 changes: 2 additions & 3 deletions website/docs/r/spot_fleet_request.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ lowestPrice.
* `instance_interruption_behavior` - (Optional) Indicates whether a Spot
instance stops or terminates when it is interrupted. Default is
`terminate`.
* `valid_until` - The end date and time of the request, in UTC ISO8601 format
(for example, YYYY-MM-DDTHH:MM:SSZ). At this point, no new Spot instance
requests are placed or enabled to fulfill the request. Defaults to 24 hours.
* `valid_until` - (Optional) The end date and time of the request, in UTC [RFC3339](https://tools.ietf.org/html/rfc3339#section-5.8) format(for example, YYYY-MM-DDTHH:MM:SSZ). At this point, no new Spot instance requests are placed or enabled to fulfill the request. Defaults to 24 hours.
* `valid_from` - (Optional) The start date and time of the request, in UTC [RFC3339](https://tools.ietf.org/html/rfc3339#section-5.8) format(for example, YYYY-MM-DDTHH:MM:SSZ). The default is to start fulfilling the request immediately.
* `load_balancers` (Optional) A list of elastic load balancer names to add to the Spot fleet.
* `target_group_arns` (Optional) A list of `aws_alb_target_group` ARNs, for use with
Application Load Balancing.
Expand Down