-
Notifications
You must be signed in to change notification settings - Fork 72
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
[Feature]: Enhance Data Source: hcloud_server_type to return locations for the server type #520
Comments
Current workaround for 1: def ensure_server_type_exists(token, server_type_name, server_location):
server_type_name = server_type_name.lower()
response = httpx.get(f'https://api.hetzner.cloud/v1/server_types?name={server_type_name}', headers={"Authorization": f"Bearer {token}"})
if response.status_code == HTTPStatus.OK.value:
response = response.json()
if response:
_server_types = response.get('server_types', None)
if _server_types:
if len(_server_types) != 1:
raise ValueError(f"Expected to find unique server type {server_type_name}, instead found '{_server_types}'")
else:
_prices = _server_types[0].get('prices', None)
if _prices:
locations = {_price.get('location', None) for _price in _prices}
if server_location not in locations:
raise RuntimeError(f"Server type '{server_type_name}' unsupported at location '{server_location}'. Available at locations {locations}")
else:
raise ValueError(f"Did not find server type {server_type_name}")
# TODO: ServerTypeUnknown exception
else:
raise RuntimeError(f"Failed to lookup server types") |
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
Sounds like a good addition. Right now the available server types are exposed in the |
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
What whould you like to see?
https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/data-sources/server_type at the moment returns some specs for the server type but leaves out rich data as available from the API: https://docs.hetzner.cloud/#server-types-get-a-server-type
One benefit of the rich data is to ensure:
server_type
exists at thelocation
server_type
prices at thelocation
is within budget (price_hourly
,price_monthly
) and estimate the cost of running a stackThe text was updated successfully, but these errors were encountered: