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

d/aws_ec2_instance_spot_price - add new data source #12504

Merged
merged 17 commits into from
Jul 31, 2020

Conversation

p0pr0ck5
Copy link
Contributor

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

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

**New Data Source**: `aws_ec2_instance_spot_price`

@p0pr0ck5 p0pr0ck5 requested a review from a team March 23, 2020 18:38
@ghost ghost added size/L Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/ec2 Issues and PRs that pertain to the ec2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Mar 23, 2020
@bflad bflad added new-data-source Introduces a new data source. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 9, 2020
Copy link
Contributor

@bflad bflad left a 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.

aws/provider.go Outdated Show resolved Hide resolved
main.tf Outdated Show resolved Hide resolved
aws/data_source_aws_ec2_instance_spot_price.go Outdated Show resolved Hide resolved
aws/data_source_aws_ec2_instance_spot_price.go Outdated Show resolved Hide resolved
aws/data_source_aws_ec2_instance_spot_price.go Outdated Show resolved Hide resolved
aws/data_source_aws_ec2_instance_spot_price.go Outdated Show resolved Hide resolved
aws/data_source_aws_ec2_instance_spot_price_test.go Outdated Show resolved Hide resolved
aws/data_source_aws_ec2_instance_spot_price_test.go Outdated Show resolved Hide resolved
aws/data_source_aws_ec2_instance_spot_price_test.go Outdated Show resolved Hide resolved
website/docs/d/ec2_instance_spot_price.html.markdown Outdated Show resolved Hide resolved
@bflad bflad self-assigned this Jul 9, 2020
@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jul 9, 2020
@p0pr0ck5
Copy link
Contributor Author

Thanks for the review @bflad! I will have a follow-up series of commits ready for this soon (hopefully Monday or Tuesday PDT). Thanks!

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jul 13, 2020
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
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.
@bflad bflad added this to the v3.1.0 milestone Jul 14, 2020
Copy link
Contributor

@bflad bflad left a 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)

website/docs/d/ec2_spot_price.html.markdown Outdated Show resolved Hide resolved
@bflad bflad merged commit 37c0224 into hashicorp:master Jul 31, 2020
bflad added a commit that referenced this pull request Jul 31, 2020
@ghost
Copy link

ghost commented Aug 7, 2020

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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@p0pr0ck5 @bflad This data source is documented as aws_ec2_instance_spot_price (note instance) but as this line demonstrates, the name is actually aws_ec2_spot_price. So either the docs or the data source name here has to be changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see: #14680

@ghost
Copy link

ghost commented Aug 30, 2020

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!

@ghost ghost locked and limited conversation to collaborators Aug 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-data-source Introduces a new data source. provider Pertains to the provider itself, rather than any interaction with AWS. service/ec2 Issues and PRs that pertain to the ec2 service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants