1. Packages
  2. Hcloud Provider
  3. API Docs
  4. PlacementGroup
Hetzner Cloud v1.22.0 published on Wednesday, Feb 26, 2025 by Pulumi

hcloud.PlacementGroup

Explore with Pulumi AI

Provides a Hetzner Cloud Placement Group to represent a Placement Group in the Hetzner Cloud.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const my_placement_group = new hcloud.PlacementGroup("my-placement-group", {
    name: "my-placement-group",
    type: "spread",
    labels: {
        key: "value",
    },
});
const node1 = new hcloud.Server("node1", {
    name: "node1",
    image: "debian-11",
    serverType: "cx22",
    placementGroupId: my_placement_group.id,
});
Copy
import pulumi
import pulumi_hcloud as hcloud

my_placement_group = hcloud.PlacementGroup("my-placement-group",
    name="my-placement-group",
    type="spread",
    labels={
        "key": "value",
    })
node1 = hcloud.Server("node1",
    name="node1",
    image="debian-11",
    server_type="cx22",
    placement_group_id=my_placement_group.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		my_placement_group, err := hcloud.NewPlacementGroup(ctx, "my-placement-group", &hcloud.PlacementGroupArgs{
			Name: pulumi.String("my-placement-group"),
			Type: pulumi.String("spread"),
			Labels: pulumi.StringMap{
				"key": pulumi.String("value"),
			},
		})
		if err != nil {
			return err
		}
		_, err = hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
			Name:             pulumi.String("node1"),
			Image:            pulumi.String("debian-11"),
			ServerType:       pulumi.String("cx22"),
			PlacementGroupId: my_placement_group.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;

return await Deployment.RunAsync(() => 
{
    var my_placement_group = new HCloud.PlacementGroup("my-placement-group", new()
    {
        Name = "my-placement-group",
        Type = "spread",
        Labels = 
        {
            { "key", "value" },
        },
    });

    var node1 = new HCloud.Server("node1", new()
    {
        Name = "node1",
        Image = "debian-11",
        ServerType = "cx22",
        PlacementGroupId = my_placement_group.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.PlacementGroup;
import com.pulumi.hcloud.PlacementGroupArgs;
import com.pulumi.hcloud.Server;
import com.pulumi.hcloud.ServerArgs;
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) {
        var my_placement_group = new PlacementGroup("my-placement-group", PlacementGroupArgs.builder()
            .name("my-placement-group")
            .type("spread")
            .labels(Map.of("key", "value"))
            .build());

        var node1 = new Server("node1", ServerArgs.builder()
            .name("node1")
            .image("debian-11")
            .serverType("cx22")
            .placementGroupId(my_placement_group.id())
            .build());

    }
}
Copy
resources:
  my-placement-group:
    type: hcloud:PlacementGroup
    properties:
      name: my-placement-group
      type: spread
      labels:
        key: value
  node1:
    type: hcloud:Server
    properties:
      name: node1
      image: debian-11
      serverType: cx22
      placementGroupId: ${["my-placement-group"].id}
Copy

Create PlacementGroup Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new PlacementGroup(name: string, args: PlacementGroupArgs, opts?: CustomResourceOptions);
@overload
def PlacementGroup(resource_name: str,
                   args: PlacementGroupArgs,
                   opts: Optional[ResourceOptions] = None)

@overload
def PlacementGroup(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   type: Optional[str] = None,
                   labels: Optional[Mapping[str, str]] = None,
                   name: Optional[str] = None)
func NewPlacementGroup(ctx *Context, name string, args PlacementGroupArgs, opts ...ResourceOption) (*PlacementGroup, error)
public PlacementGroup(string name, PlacementGroupArgs args, CustomResourceOptions? opts = null)
public PlacementGroup(String name, PlacementGroupArgs args)
public PlacementGroup(String name, PlacementGroupArgs args, CustomResourceOptions options)
type: hcloud:PlacementGroup
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. PlacementGroupArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. PlacementGroupArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. PlacementGroupArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. PlacementGroupArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. PlacementGroupArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var placementGroupResource = new HCloud.PlacementGroup("placementGroupResource", new()
{
    Type = "string",
    Labels = 
    {
        { "string", "string" },
    },
    Name = "string",
});
Copy
example, err := hcloud.NewPlacementGroup(ctx, "placementGroupResource", &hcloud.PlacementGroupArgs{
	Type: pulumi.String("string"),
	Labels: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	Name: pulumi.String("string"),
})
Copy
var placementGroupResource = new PlacementGroup("placementGroupResource", PlacementGroupArgs.builder()
    .type("string")
    .labels(Map.of("string", "string"))
    .name("string")
    .build());
Copy
placement_group_resource = hcloud.PlacementGroup("placementGroupResource",
    type="string",
    labels={
        "string": "string",
    },
    name="string")
Copy
const placementGroupResource = new hcloud.PlacementGroup("placementGroupResource", {
    type: "string",
    labels: {
        string: "string",
    },
    name: "string",
});
Copy
type: hcloud:PlacementGroup
properties:
    labels:
        string: string
    name: string
    type: string
Copy

PlacementGroup Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The PlacementGroup resource accepts the following input properties:

Type This property is required. string
Type of the Placement Group.
Labels Dictionary<string, string>
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Placement Group.
Type This property is required. string
Type of the Placement Group.
Labels map[string]string
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Placement Group.
type This property is required. String
Type of the Placement Group.
labels Map<String,String>
User-defined labels (key-value pairs) should be created with.
name String
Name of the Placement Group.
type This property is required. string
Type of the Placement Group.
labels {[key: string]: string}
User-defined labels (key-value pairs) should be created with.
name string
Name of the Placement Group.
type This property is required. str
Type of the Placement Group.
labels Mapping[str, str]
User-defined labels (key-value pairs) should be created with.
name str
Name of the Placement Group.
type This property is required. String
Type of the Placement Group.
labels Map<String>
User-defined labels (key-value pairs) should be created with.
name String
Name of the Placement Group.

Outputs

All input properties are implicitly available as output properties. Additionally, the PlacementGroup resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Servers List<int>
Id string
The provider-assigned unique ID for this managed resource.
Servers []int
id String
The provider-assigned unique ID for this managed resource.
servers List<Integer>
id string
The provider-assigned unique ID for this managed resource.
servers number[]
id str
The provider-assigned unique ID for this managed resource.
servers Sequence[int]
id String
The provider-assigned unique ID for this managed resource.
servers List<Number>

Look up Existing PlacementGroup Resource

Get an existing PlacementGroup resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: PlacementGroupState, opts?: CustomResourceOptions): PlacementGroup
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        labels: Optional[Mapping[str, str]] = None,
        name: Optional[str] = None,
        servers: Optional[Sequence[int]] = None,
        type: Optional[str] = None) -> PlacementGroup
func GetPlacementGroup(ctx *Context, name string, id IDInput, state *PlacementGroupState, opts ...ResourceOption) (*PlacementGroup, error)
public static PlacementGroup Get(string name, Input<string> id, PlacementGroupState? state, CustomResourceOptions? opts = null)
public static PlacementGroup get(String name, Output<String> id, PlacementGroupState state, CustomResourceOptions options)
resources:  _:    type: hcloud:PlacementGroup    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Labels Dictionary<string, string>
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Placement Group.
Servers List<int>
Type string
Type of the Placement Group.
Labels map[string]string
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Placement Group.
Servers []int
Type string
Type of the Placement Group.
labels Map<String,String>
User-defined labels (key-value pairs) should be created with.
name String
Name of the Placement Group.
servers List<Integer>
type String
Type of the Placement Group.
labels {[key: string]: string}
User-defined labels (key-value pairs) should be created with.
name string
Name of the Placement Group.
servers number[]
type string
Type of the Placement Group.
labels Mapping[str, str]
User-defined labels (key-value pairs) should be created with.
name str
Name of the Placement Group.
servers Sequence[int]
type str
Type of the Placement Group.
labels Map<String>
User-defined labels (key-value pairs) should be created with.
name String
Name of the Placement Group.
servers List<Number>
type String
Type of the Placement Group.

Import

Placement Groups can be imported using its id:

$ pulumi import hcloud:index/placementGroup:PlacementGroup example "$PLACEMENT_GROUP_ID"
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Hetzner Cloud pulumi/pulumi-hcloud
License
Apache-2.0
Notes
This Pulumi package is based on the hcloud Terraform Provider.