-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Issue #3530 Add valid_from and valid_until for aws_spot_instance_request #4018
Conversation
…s_spot_instance_request
34988be
to
10db145
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @saravanan30erd! 👋 Thanks for this contribution. Can you please see the below and also implement an acceptance test?
@@ -12,6 +12,8 @@ import ( | |||
"github.com/hashicorp/terraform/helper/schema" | |||
) | |||
|
|||
const awsSpotInstanceRequestTimeLayout = "2006-01-02T15:04:05Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating our own time layout, can we please use time.RFC3339
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the format to time.RFC3339 instead of custom layout.
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching to RFC3339 gives us an easy plan-time validation function for both of these:
ValidateFunc: validation.ValidateRFC3339TimeString,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the validation function from the same package(validators.go).
if err != nil { | ||
return err | ||
} | ||
spotOpts.ValidFrom = &valid_from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: we prefer to use the AWS SDK provided functions for these, e.g. aws.Time(valid_from)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used the aws.Time function for pointer reference.
@@ -61,6 +61,11 @@ Spot Instance Requests support all the same arguments as | |||
The duration period starts as soon as your Spot instance receives its instance ID. At the end of the duration period, Amazon EC2 marks the Spot instance for termination and provides a Spot instance termination notice, which gives the instance a two-minute warning before it terminates. | |||
Note that you can't specify an Availability Zone group or a launch group if you specify a duration. | |||
* `instance_interruption_behavior` - (Optional) Indicates whether a Spot instance stops or terminates when it is interrupted. Default is `terminate` as this is the current AWS behaviour. | |||
* `valid_until` - The end date and time of the request, in UTC ISO8601 format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we switch to RFC3339, we should link to its documentation, e.g. in [RFC3339 format](https://tools.ietf.org/html/rfc3339#section-5.8)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the document with RFC3339 change.
Hi @bflad added the acceptance test for valid_until. All of the custom tests are passed. But the general test is failing. make testacc TEST=./aws TESTARGS='-run=TestAccAWSSpotInstanceRequest_validUntil'
Since terraform always expect empty(i.e no changes) during terraform plan after terraform apply. Not only this test, all the acceptance tests for aws_spot_instance_request are failing since the aws introduced these parameters(valid_from & valid_until). make testacc TEST=./aws TESTARGS='-run=TestAccAWSSpotInstanceRequest_basic' --- FAIL: TestAccAWSSpotInstanceRequest_basic (212.76s)
We can fix this by setting valid_from during acceptance test, but it seems test always expecting the spot request result as "fulfilled" and if we set valid_from, actual result of the request is "not-scheduled-yet", so the test is failing. |
@saravanan30erd for now add |
@bflad thanks. Changed valid_from and valid_until as computed attributes, so tests are also passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- thanks!! 🚀
Test failure unrelated
Tests failed: 1 (1 new), passed: 9
=== RUN TestAccAWSSpotInstanceRequestInterruptHibernate
--- PASS: TestAccAWSSpotInstanceRequestInterruptHibernate (53.78s)
=== RUN TestAccAWSSpotInstanceRequestInterruptStop
--- PASS: TestAccAWSSpotInstanceRequestInterruptStop (75.38s)
=== RUN TestAccAWSSpotInstanceRequest_vpc
--- PASS: TestAccAWSSpotInstanceRequest_vpc (92.12s)
=== RUN TestAccAWSSpotInstanceRequest_NetworkInterfaceAttributes
--- PASS: TestAccAWSSpotInstanceRequest_NetworkInterfaceAttributes (110.35s)
=== RUN TestAccAWSSpotInstanceRequest_withBlockDuration
--- PASS: TestAccAWSSpotInstanceRequest_withBlockDuration (112.70s)
=== RUN TestAccAWSSpotInstanceRequest_validUntil
--- PASS: TestAccAWSSpotInstanceRequest_validUntil (138.11s)
=== RUN TestAccAWSSpotInstanceRequest_withLaunchGroup
--- PASS: TestAccAWSSpotInstanceRequest_withLaunchGroup (178.15s)
=== RUN TestAccAWSSpotInstanceRequest_SubnetAndSGAndPublicIpAddress
--- FAIL: TestAccAWSSpotInstanceRequest_SubnetAndSGAndPublicIpAddress (209.23s)
=== RUN TestAccAWSSpotInstanceRequest_basic
--- PASS: TestAccAWSSpotInstanceRequest_basic (249.55s)
=== RUN TestAccAWSSpotInstanceRequest_getPasswordData
--- PASS: TestAccAWSSpotInstanceRequest_getPasswordData (318.24s)
This has been released in version 1.16.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
No description provided.