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 Datacenters.
This resource may be useful to create highly available infrastructure, distributed across several Datacenters.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const all = hcloud.getDatacenters({});
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",
datacenter: all.then(all => all.datacenters[range.value]).then(datacenters => datacenters.name),
}));
}
import pulumi
import pulumi_hcloud as hcloud
all = hcloud.get_datacenters()
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",
datacenter=all.datacenters[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.GetDatacenters.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",
Datacenter = all.Apply(getDatacentersResult => getDatacentersResult.Datacenters)[range.Value].Apply(datacenters => datacenters.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.getDatacenters(%!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")
.datacenter(all.datacenters()[range.value()].name())
.build());
}
}
}
Example coming soon!
Using getDatacenters
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 getDatacenters(opts?: InvokeOptions): Promise<GetDatacentersResult>
function getDatacentersOutput(opts?: InvokeOptions): Output<GetDatacentersResult>def get_datacenters(opts: Optional[InvokeOptions] = None) -> GetDatacentersResult
def get_datacenters_output(opts: Optional[InvokeOptions] = None) -> Output[GetDatacentersResult]func GetDatacenters(ctx *Context, opts ...InvokeOption) (*GetDatacentersResult, error)
func GetDatacentersOutput(ctx *Context, opts ...InvokeOption) GetDatacentersResultOutput> Note: This function is named GetDatacenters in the Go SDK.
public static class GetDatacenters
{
public static Task<GetDatacentersResult> InvokeAsync(InvokeOptions? opts = null)
public static Output<GetDatacentersResult> Invoke(InvokeOptions? opts = null)
}public static CompletableFuture<GetDatacentersResult> getDatacenters(InvokeOptions options)
public static Output<GetDatacentersResult> getDatacenters(InvokeOptions options)
fn::invoke:
function: hcloud:index/getDatacenters:getDatacenters
arguments:
# arguments dictionarygetDatacenters Result
The following output properties are available:
- Datacenter
Ids List<string> - Datacenters
List<Pulumi.
HCloud. Outputs. Get Datacenters Datacenter> - Descriptions List<string>
- Id string
- The ID of this resource.
- Names List<string>
- Datacenter
Ids []string - Datacenters
[]Get
Datacenters Datacenter - Descriptions []string
- Id string
- The ID of this resource.
- Names []string
- datacenter
Ids List<String> - datacenters
List<Get
Datacenters Datacenter> - descriptions List<String>
- id String
- The ID of this resource.
- names List<String>
- datacenter
Ids string[] - datacenters
Get
Datacenters Datacenter[] - descriptions string[]
- id string
- The ID of this resource.
- names string[]
- datacenter_
ids Sequence[str] - datacenters
Sequence[Get
Datacenters Datacenter] - descriptions Sequence[str]
- id str
- The ID of this resource.
- names Sequence[str]
- datacenter
Ids List<String> - datacenters List<Property Map>
- descriptions List<String>
- id String
- The ID of this resource.
- names List<String>
Supporting Types
GetDatacentersDatacenter
- Available
Server List<int>Type Ids - List of currently available Server Types in the Datacenter.
- Description string
- Description of the Datacenter.
- Id int
- ID of the Datacenter.
- Location Dictionary<string, string>
- Location of the Datacenter. See the Hetzner Docs for more details about locations.
- Name string
- Name of the Datacenter.
- Supported
Server List<int>Type Ids - List of supported Server Types in the Datacenter.
- Available
Server []intType Ids - List of currently available Server Types in the Datacenter.
- Description string
- Description of the Datacenter.
- Id int
- ID of the Datacenter.
- Location map[string]string
- Location of the Datacenter. See the Hetzner Docs for more details about locations.
- Name string
- Name of the Datacenter.
- Supported
Server []intType Ids - List of supported Server Types in the Datacenter.
- available
Server List<Integer>Type Ids - List of currently available Server Types in the Datacenter.
- description String
- Description of the Datacenter.
- id Integer
- ID of the Datacenter.
- location Map<String,String>
- Location of the Datacenter. See the Hetzner Docs for more details about locations.
- name String
- Name of the Datacenter.
- supported
Server List<Integer>Type Ids - List of supported Server Types in the Datacenter.
- available
Server number[]Type Ids - List of currently available Server Types in the Datacenter.
- description string
- Description of the Datacenter.
- id number
- ID of the Datacenter.
- location {[key: string]: string}
- Location of the Datacenter. See the Hetzner Docs for more details about locations.
- name string
- Name of the Datacenter.
- supported
Server number[]Type Ids - List of supported Server Types in the Datacenter.
- available_
server_ Sequence[int]type_ ids - List of currently available Server Types in the Datacenter.
- description str
- Description of the Datacenter.
- id int
- ID of the Datacenter.
- location Mapping[str, str]
- Location of the Datacenter. See the Hetzner Docs for more details about locations.
- name str
- Name of the Datacenter.
- supported_
server_ Sequence[int]type_ ids - List of supported Server Types in the Datacenter.
- available
Server List<Number>Type Ids - List of currently available Server Types in the Datacenter.
- description String
- Description of the Datacenter.
- id Number
- ID of the Datacenter.
- location Map<String>
- Location of the Datacenter. See the Hetzner Docs for more details about locations.
- name String
- Name of the Datacenter.
- supported
Server List<Number>Type Ids - List of supported Server Types in the Datacenter.
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
