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,
});
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)
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 {
_, 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
})
}
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,
});
});
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());
}
}
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}
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 string
- The unique name of the resource.
- args PlacementGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args 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 string
- The unique name of the resource.
- args PlacementGroupArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PlacementGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args 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",
});
example, err := hcloud.NewPlacementGroup(ctx, "placementGroupResource", &hcloud.PlacementGroupArgs{
Type: pulumi.String("string"),
Labels: pulumi.StringMap{
"string": pulumi.String("string"),
},
Name: pulumi.String("string"),
})
var placementGroupResource = new PlacementGroup("placementGroupResource", PlacementGroupArgs.builder()
.type("string")
.labels(Map.of("string", "string"))
.name("string")
.build());
placement_group_resource = hcloud.PlacementGroup("placementGroupResource",
type="string",
labels={
"string": "string",
},
name="string")
const placementGroupResource = new hcloud.PlacementGroup("placementGroupResource", {
type: "string",
labels: {
string: "string",
},
name: "string",
});
type: hcloud:PlacementGroup
properties:
labels:
string: string
name: string
type: string
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
The PlacementGroup resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the PlacementGroup resource produces the following output properties:
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)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
Import
Placement Groups can be imported using its id
:
$ pulumi import hcloud:index/placementGroup:PlacementGroup my-placement-group id
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.