-
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
d/aws_ec2_instance_spot_price - add new data source #12504
Conversation
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 @p0pr0ck5 👋 Thanks so much for submitting this! Overall its on the right track. I left some initial review items below. Please reach out if you have any questions or do not have time to implement them.
Thanks for the review @bflad! I will have a follow-up series of commits ready for this soon (hopefully Monday or Tuesday PDT). Thanks! |
Adds a data source to fetch the most recently published Spot Price value for a given EC2 instance type and availability zone. The value can be manipulated and fed into spot price parameters in other resources, allowing for dynamic adjusted of spot requests.
since we are only interested in fetching the latest SpotPrice, we don't need to iterate over a series of requests, as we only ever need to fetch call's worth of data
9aa0b41
to
ce454d9
Compare
add a test for sourcing an aws_ec2_spot_price data source using filter{} blocks exclusively. this commit also involves a rework of the DescribeSpotPriceHistory AWS API call, namely using the native SDK paging function; without this function, making a singular direct call to the DescribeSpotPriceHistory SDK function returned a response with an empty slice, but the underlying API call returned a response with a non-nil NextToken value. to support this, we simply use the DescribeSpotPriceHistoryPages unconditionally during reads, and add all found SpotPriceHistory objects to a slice.
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 with one little documentation change, thanks @p0pr0ck5 🚀 Please note this will be merged after the 3.0 release in a week or two.
Output from acceptance testing in AWS Commercial:
--- PASS: TestAccAwsEc2SpotPriceDataSource (8.97s)
--- PASS: TestAccAwsEc2SpotPriceDataSourceFilter (10.45s)
Output from acceptance testing in AWS GovCloud (US):
--- PASS: TestAccAwsEc2SpotPriceDataSource (2.95s)
--- PASS: TestAccAwsEc2SpotPriceDataSourceFilter (3.33s)
This has been released in version 3.1.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
@@ -221,6 +221,7 @@ func Provider() terraform.ResourceProvider { | |||
"aws_ec2_local_gateway_virtual_interface": dataSourceAwsEc2LocalGatewayVirtualInterface(), | |||
"aws_ec2_local_gateway_virtual_interface_group": dataSourceAwsEc2LocalGatewayVirtualInterfaceGroup(), | |||
"aws_ec2_local_gateway_virtual_interface_groups": dataSourceAwsEc2LocalGatewayVirtualInterfaceGroups(), | |||
"aws_ec2_spot_price": dataSourceAwsEc2SpotPrice(), |
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.
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.
Please see: #14680
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! |
Adds a data source to fetch the most recently published Spot Price
value for a given EC2 instance type and availability zone. The value
can be manipulated and fed into spot price parameters in other resources,
allowing for dynamic adjusted of spot requests.
Community Note
Release note for CHANGELOG: