feat(pricing): add hcloud_pricing data source#1449
Open
KamranBiglari wants to merge 3 commits into
Open
Conversation
Add a new hcloud_pricing data source exposing the prices for the resources offered by the Hetzner Cloud (images, floating IPs, primary IPs, server backups, server types, load balancer types and volumes). The Pricing API does not support server side filtering, so the full response is fetched and filtered locally via the optional location, server_type and load_balancer_type attributes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
hcloud_pricingdata source that exposes the prices for the resources offered by the Hetzner Cloud, mirroring the Pricing API.Prices are returned for the Hetzner Cloud project the configured API token belongs to.
Exposed prices
currency/vat_rateimage(price per GB/month)floating_ips(per type, per location)primary_ips(per type, per location – hourly & monthly)server_backup(surcharge percentage)server_types(per type, per location – hourly, monthly, included traffic, per-TB traffic)load_balancer_types(per type, per location – hourly, monthly, included traffic, per-TB traffic)volume(price per GB/month)Filters
The Pricing API has no server-side filtering, so the full response is fetched and filtered internally via optional inputs:
location– restrict the per-location price lists to a single locationserver_type– restrictserver_typesto a single type (by name)load_balancer_type– restrictload_balancer_typesto a single type (by name)Implementation notes
internal/pricing,FromAPI/ToTerraformmodels,hcloudutilclient wiring).hcloud/plugin_provider.go.Example
Test plan
go build ./...,go vet ./internal/pricing/...,gofmtcleango test ./internal/pricing/...passesTestAccPricingDataSourceadded (requiresTF_ACC+ a real token)