1. Packages
  2. Hetzner Cloud
  3. API Docs
  4. PlacementGroup
Hetzner Cloud v1.18.1 published on Tuesday, Apr 9, 2024 by Pulumi

hcloud.PlacementGroup

Explore with Pulumi AI

hcloud logo
Hetzner Cloud v1.18.1 published on Tuesday, Apr 9, 2024 by Pulumi

    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", {
        type: "spread",
        labels: {
            key: "value",
        },
    });
    const node1 = new hcloud.Server("node1", {
        image: "debian-11",
        serverType: "cx11",
        placementGroupId: my_placement_group.id,
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    my_placement_group = hcloud.PlacementGroup("my-placement-group",
        type="spread",
        labels={
            "key": "value",
        })
    node1 = hcloud.Server("node1",
        image="debian-11",
        server_type="cx11",
        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{
    			Type: pulumi.String("spread"),
    			Labels: pulumi.Map{
    				"key": pulumi.Any("value"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
    			Image:            pulumi.String("debian-11"),
    			ServerType:       pulumi.String("cx11"),
    			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()
        {
            Type = "spread",
            Labels = 
            {
                { "key", "value" },
            },
        });
    
        var node1 = new HCloud.Server("node1", new()
        {
            Image = "debian-11",
            ServerType = "cx11",
            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()        
                .type("spread")
                .labels(Map.of("key", "value"))
                .build());
    
            var node1 = new Server("node1", ServerArgs.builder()        
                .image("debian-11")
                .serverType("cx11")
                .placementGroupId(my_placement_group.id())
                .build());
    
        }
    }
    
    resources:
      my-placement-group:
        type: hcloud:PlacementGroup
        properties:
          type: spread
          labels:
            key: value
      node1:
        type: hcloud:Server
        properties:
          image: debian-11
          serverType: cx11
          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, Any]] = 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.

    Example

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

    var placementGroupResource = new HCloud.PlacementGroup("placementGroupResource", new()
    {
        Type = "string",
        Labels = 
        {
            { "string", "any" },
        },
        Name = "string",
    });
    
    example, err := hcloud.NewPlacementGroup(ctx, "placementGroupResource", &hcloud.PlacementGroupArgs{
    	Type: pulumi.String("string"),
    	Labels: pulumi.Map{
    		"string": pulumi.Any("any"),
    	},
    	Name: pulumi.String("string"),
    })
    
    var placementGroupResource = new PlacementGroup("placementGroupResource", PlacementGroupArgs.builder()        
        .type("string")
        .labels(Map.of("string", "any"))
        .name("string")
        .build());
    
    placement_group_resource = hcloud.PlacementGroup("placementGroupResource",
        type="string",
        labels={
            "string": "any",
        },
        name="string")
    
    const placementGroupResource = new hcloud.PlacementGroup("placementGroupResource", {
        type: "string",
        labels: {
            string: "any",
        },
        name: "string",
    });
    
    type: hcloud:PlacementGroup
    properties:
        labels:
            string: any
        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:

    Type string
    Type of the Placement Group.
    Labels Dictionary<string, object>
    User-defined labels (key-value pairs) should be created with.
    Name string
    Name of the Placement Group.
    Type string
    Type of the Placement Group.
    Labels map[string]interface{}
    User-defined labels (key-value pairs) should be created with.
    Name string
    Name of the Placement Group.
    type String
    Type of the Placement Group.
    labels Map<String,Object>
    User-defined labels (key-value pairs) should be created with.
    name String
    Name of the Placement Group.
    type string
    Type of the Placement Group.
    labels {[key: string]: any}
    User-defined labels (key-value pairs) should be created with.
    name string
    Name of the Placement Group.
    type str
    Type of the Placement Group.
    labels Mapping[str, Any]
    User-defined labels (key-value pairs) should be created with.
    name str
    Name of the Placement Group.
    type String
    Type of the Placement Group.
    labels Map<Any>
    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, Any]] = 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.
    The following state arguments are supported:
    Labels Dictionary<string, object>
    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]interface{}
    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,Object>
    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]: any}
    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, Any]
    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<Any>
    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 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.
    hcloud logo
    Hetzner Cloud v1.18.1 published on Tuesday, Apr 9, 2024 by Pulumi