Hetzner Cloud v1.29.0 published on Saturday, Nov 29, 2025 by Pulumi
Hetzner Cloud v1.29.0 published on Saturday, Nov 29, 2025 by Pulumi
Provides a list of available Hetzner Cloud Locations.
This resource may be useful to create highly available infrastructure, distributed across several locations.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const all = hcloud.getLocations({});
const workers: hcloud.Server[] = [];
for (const range = {value: 0}; range.value < 5; range.value++) {
workers.push(new hcloud.Server(`workers-${range.value}`, {
name: `node${range.value}`,
image: "debian-12",
serverType: "cx23",
location: all.then(all => all.locations[range.value]).then(locations => locations.name),
}));
}
import pulumi
import pulumi_hcloud as hcloud
all = hcloud.get_locations()
workers = []
for range in [{"value": i} for i in range(0, 5)]:
workers.append(hcloud.Server(f"workers-{range['value']}",
name=f"node{range['value']}",
image="debian-12",
server_type="cx23",
location=all.locations[range["value"]]["name"]))
Example coming soon!
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;
return await Deployment.RunAsync(() =>
{
var all = HCloud.GetLocations.Invoke();
var workers = new List<HCloud.Server>();
for (var rangeIndex = 0; rangeIndex < 5; rangeIndex++)
{
var range = new { Value = rangeIndex };
workers.Add(new HCloud.Server($"workers-{range.Value}", new()
{
Name = $"node{range.Value}",
Image = "debian-12",
ServerType = "cx23",
Location = all.Apply(getLocationsResult => getLocationsResult.Locations)[range.Value].Apply(locations => locations.Name),
}));
}
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.HcloudFunctions;
import com.pulumi.hcloud.Server;
import com.pulumi.hcloud.ServerArgs;
import com.pulumi.codegen.internal.KeyedValue;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var all = HcloudFunctions.getLocations(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference);
for (var i = 0; i < 5; i++) {
new Server("workers-" + i, ServerArgs.builder()
.name(String.format("node%s", range.value()))
.image("debian-12")
.serverType("cx23")
.location(all.locations()[range.value()].name())
.build());
}
}
}
Example coming soon!
Using getLocations
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getLocations(opts?: InvokeOptions): Promise<GetLocationsResult>
function getLocationsOutput(opts?: InvokeOptions): Output<GetLocationsResult>def get_locations(opts: Optional[InvokeOptions] = None) -> GetLocationsResult
def get_locations_output(opts: Optional[InvokeOptions] = None) -> Output[GetLocationsResult]func GetLocations(ctx *Context, opts ...InvokeOption) (*GetLocationsResult, error)
func GetLocationsOutput(ctx *Context, opts ...InvokeOption) GetLocationsResultOutput> Note: This function is named GetLocations in the Go SDK.
public static class GetLocations
{
public static Task<GetLocationsResult> InvokeAsync(InvokeOptions? opts = null)
public static Output<GetLocationsResult> Invoke(InvokeOptions? opts = null)
}public static CompletableFuture<GetLocationsResult> getLocations(InvokeOptions options)
public static Output<GetLocationsResult> getLocations(InvokeOptions options)
fn::invoke:
function: hcloud:index/getLocations:getLocations
arguments:
# arguments dictionarygetLocations Result
The following output properties are available:
- Descriptions List<string>
- Id string
- The ID of this resource.
- Location
Ids List<string> - Locations
List<Pulumi.
HCloud. Outputs. Get Locations Location> - Names List<string>
- Descriptions []string
- Id string
- The ID of this resource.
- Location
Ids []string - Locations
[]Get
Locations Location - Names []string
- descriptions List<String>
- id String
- The ID of this resource.
- location
Ids List<String> - locations
List<Get
Locations Location> - names List<String>
- descriptions string[]
- id string
- The ID of this resource.
- location
Ids string[] - locations
Get
Locations Location[] - names string[]
- descriptions Sequence[str]
- id str
- The ID of this resource.
- location_
ids Sequence[str] - locations
Sequence[Get
Locations Location] - names Sequence[str]
- descriptions List<String>
- id String
- The ID of this resource.
- location
Ids List<String> - locations List<Property Map>
- names List<String>
Supporting Types
GetLocationsLocation
- City string
- Name of the closest city to the Location. City name and optionally state in short form.
- Country string
- Country the Location resides in. ISO 3166-1 alpha-2 code of the country.
- Description string
- Description of the Location.
- Id int
- ID of the Location.
- Latitude double
- Latitude of the city closest to the Location.
- Longitude double
- Longitude of the city closest to the Location.
- Name string
- Name of the Location.
- Network
Zone string - Name of the Network Zone this Location resides in.
- City string
- Name of the closest city to the Location. City name and optionally state in short form.
- Country string
- Country the Location resides in. ISO 3166-1 alpha-2 code of the country.
- Description string
- Description of the Location.
- Id int
- ID of the Location.
- Latitude float64
- Latitude of the city closest to the Location.
- Longitude float64
- Longitude of the city closest to the Location.
- Name string
- Name of the Location.
- Network
Zone string - Name of the Network Zone this Location resides in.
- city String
- Name of the closest city to the Location. City name and optionally state in short form.
- country String
- Country the Location resides in. ISO 3166-1 alpha-2 code of the country.
- description String
- Description of the Location.
- id Integer
- ID of the Location.
- latitude Double
- Latitude of the city closest to the Location.
- longitude Double
- Longitude of the city closest to the Location.
- name String
- Name of the Location.
- network
Zone String - Name of the Network Zone this Location resides in.
- city string
- Name of the closest city to the Location. City name and optionally state in short form.
- country string
- Country the Location resides in. ISO 3166-1 alpha-2 code of the country.
- description string
- Description of the Location.
- id number
- ID of the Location.
- latitude number
- Latitude of the city closest to the Location.
- longitude number
- Longitude of the city closest to the Location.
- name string
- Name of the Location.
- network
Zone string - Name of the Network Zone this Location resides in.
- city str
- Name of the closest city to the Location. City name and optionally state in short form.
- country str
- Country the Location resides in. ISO 3166-1 alpha-2 code of the country.
- description str
- Description of the Location.
- id int
- ID of the Location.
- latitude float
- Latitude of the city closest to the Location.
- longitude float
- Longitude of the city closest to the Location.
- name str
- Name of the Location.
- network_
zone str - Name of the Network Zone this Location resides in.
- city String
- Name of the closest city to the Location. City name and optionally state in short form.
- country String
- Country the Location resides in. ISO 3166-1 alpha-2 code of the country.
- description String
- Description of the Location.
- id Number
- ID of the Location.
- latitude Number
- Latitude of the city closest to the Location.
- longitude Number
- Longitude of the city closest to the Location.
- name String
- Name of the Location.
- network
Zone String - Name of the Network Zone this Location resides in.
Package Details
- Repository
- Hetzner Cloud pulumi/pulumi-hcloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
hcloudTerraform Provider.
Hetzner Cloud v1.29.0 published on Saturday, Nov 29, 2025 by Pulumi
