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

New data source: aws_spot_price_history #12795

Conversation

janschumann
Copy link
Contributor

@janschumann janschumann commented Apr 13, 2020

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

Motivation

Currently we configure spot prices as terraform variables. In some cases these prices vary frequently, so that somebody has to lookup the prices in AWS and update the code accordingly.

Please consider the following example, which uses the new resource in conjunction with a launch configuration. If an instance, cannot start due to a higher spot price, just apply the corresponding terraform workspace.

# Request spot prices
resource "aws_spot_price_history" "prices" {
  start_time = "2020-04-13T01:10:30Z"
  filter {
    name = "instance_type"
    values = ["m4.large"]
  } 
}

# use the latest price for the launch configuration
resource "aws_launch_configuration" "default" {
  name          = "default"
  image_id      = "${data.aws_ami.ubuntu.id}"
  instance_type = "m4.large"
  spot_price    = data.aws_spot_price_history.prices.latest.spot_price * 1.2
}

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSSpotPriceHistoryDataSource_instance_type_filter'

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSSpotPriceHistoryDataSource_instance_type -timeout 120m
=== RUN   TestAccAWSSpotPriceHistoryDataSource_instance_type_filter
=== PAUSE TestAccAWSSpotPriceHistoryDataSource_instance_type_filter
=== CONT  TestAccAWSSpotPriceHistoryDataSource_instance_type_filter
--- PASS: TestAccAWSSpotPriceHistoryDataSource_instance_type_filter (40.09s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	41.407s

@janschumann janschumann requested a review from a team April 13, 2020 05:44
@ghost ghost added size/XL 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 Apr 13, 2020
@janschumann janschumann force-pushed the spot-price-history-data-source branch from dcfdb1a to f3c39b2 Compare April 13, 2020 06:06
@ewbankkit
Copy link
Contributor

@bflad
Copy link
Contributor

bflad commented Jul 9, 2020

Hi @janschumann 👋 Thank you for submitting this! As @ewbankkit mentions above, it appears there is an earlier contribution for this functionality with #12504. In these situations the maintainers will review contributions in their submission order and you're welcome to provide your feedback there as well.

@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
@bflad
Copy link
Contributor

bflad commented Jul 16, 2020

Just to followup, #12504 has been reviewed and will be merged shortly after we release 3.0. Thanks again for contributing this, @janschumann. 👍

@bflad bflad closed this Jul 16, 2020
@ghost
Copy link

ghost commented Aug 15, 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 15, 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/XL 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