Skip to content

feat(pricing): add hcloud_pricing data source#1449

Open
KamranBiglari wants to merge 3 commits into
hetznercloud:mainfrom
KamranBiglari:feat/pricing-data-source
Open

feat(pricing): add hcloud_pricing data source#1449
KamranBiglari wants to merge 3 commits into
hetznercloud:mainfrom
KamranBiglari:feat/pricing-data-source

Conversation

@KamranBiglari

Copy link
Copy Markdown

Summary

Adds a new hcloud_pricing data 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_rate
  • image (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 location
  • server_type – restrict server_types to a single type (by name)
  • load_balancer_type – restrict load_balancer_types to a single type (by name)

Implementation notes

  • Built on the terraform-plugin-framework, following the existing data source style (internal/pricing, FromAPI/ToTerraform models, hcloudutil client wiring).
  • Registered in hcloud/plugin_provider.go.
  • Docs generated with tfplugindocs; example and acceptance test added.

Example

data "hcloud_pricing" "prices" {
  location    = "fsn1"
  server_type = "cx22"
}

output "cx22_monthly_gross" {
  value = data.hcloud_pricing.prices.server_types[0].prices[0].monthly.gross
}

Test plan

  • go build ./..., go vet ./internal/pricing/..., gofmt clean
  • go test ./internal/pricing/... passes
  • TestAccPricingDataSource added (requires TF_ACC + a real token)

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.
@KamranBiglari KamranBiglari requested a review from a team as a code owner June 4, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant