published on Tuesday, Mar 24, 2026 by g-core
published on Tuesday, Mar 24, 2026 by g-core
Placement groups enforce affinity or anti-affinity policies that control whether virtual machines are hosted on the same or different physical servers.
Example Usage
Basic placement group
Creates an affinity placement group.
import * as pulumi from "@pulumi/pulumi";
import * as gcore from "@pulumi/gcore";
const servergroup = new gcore.CloudPlacementGroup("servergroup", {
projectId: 1,
regionId: 1,
name: "my-servergroup",
policy: "affinity",
});
import pulumi
import pulumi_gcore as gcore
servergroup = gcore.CloudPlacementGroup("servergroup",
project_id=1,
region_id=1,
name="my-servergroup",
policy="affinity")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/gcore/v2/gcore"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := gcore.NewCloudPlacementGroup(ctx, "servergroup", &gcore.CloudPlacementGroupArgs{
ProjectId: pulumi.Float64(1),
RegionId: pulumi.Float64(1),
Name: pulumi.String("my-servergroup"),
Policy: pulumi.String("affinity"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcore = Pulumi.Gcore;
return await Deployment.RunAsync(() =>
{
var servergroup = new Gcore.CloudPlacementGroup("servergroup", new()
{
ProjectId = 1,
RegionId = 1,
Name = "my-servergroup",
Policy = "affinity",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcore.CloudPlacementGroup;
import com.pulumi.gcore.CloudPlacementGroupArgs;
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 servergroup = new CloudPlacementGroup("servergroup", CloudPlacementGroupArgs.builder()
.projectId(1.0)
.regionId(1.0)
.name("my-servergroup")
.policy("affinity")
.build());
}
}
resources:
servergroup:
type: gcore:CloudPlacementGroup
properties:
projectId: 1
regionId: 1
name: my-servergroup
policy: affinity
Placement group with two instances
Creates a placement group and assigns two compute instances to it.
Example coming soon!
Example coming soon!
Example coming soon!
Example coming soon!
Example coming soon!
resources:
bootVolume:
type: gcore:CloudVolume
name: boot_volume
properties:
projectId: 1
regionId: 1
name: my-boot-volume
typeName: ssd_hiiops
size: 5
imageId: your-ubuntu-image-id
bootVolume2:
type: gcore:CloudVolume
name: boot_volume2
properties:
projectId: 1
regionId: 1
name: my-boot-volume2
typeName: ssd_hiiops
size: 5
imageId: your-ubuntu-image-id
instance:
type: gcore:CloudInstance
properties:
projectId: 1
regionId: 1
flavor: g1-standard-2-4
name: my-instance
volumes:
- volumeId: ${bootVolume.id}
bootIndex: 0
interfaces:
- type: external
name: my-external-interface
instance2:
type: gcore:CloudInstance
properties:
projectId: 1
regionId: 1
flavor: g1-standard-2-4
name: my-instance2
volumes:
- volumeId: ${bootVolume2.id}
bootIndex: 0
interfaces:
- type: external
name: my-external-interface
servergroup:
type: gcore:CloudPlacementGroup
properties:
projectId: 1
regionId: 1
name: default
policy: affinity
instances:
- instanceId: ${instance.id}
- instanceId: ${instance2.id}
Create CloudPlacementGroup Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new CloudPlacementGroup(name: string, args: CloudPlacementGroupArgs, opts?: CustomResourceOptions);@overload
def CloudPlacementGroup(resource_name: str,
args: CloudPlacementGroupArgs,
opts: Optional[ResourceOptions] = None)
@overload
def CloudPlacementGroup(resource_name: str,
opts: Optional[ResourceOptions] = None,
policy: Optional[str] = None,
instances: Optional[Sequence[CloudPlacementGroupInstanceArgs]] = None,
name: Optional[str] = None,
project_id: Optional[float] = None,
region_id: Optional[float] = None)func NewCloudPlacementGroup(ctx *Context, name string, args CloudPlacementGroupArgs, opts ...ResourceOption) (*CloudPlacementGroup, error)public CloudPlacementGroup(string name, CloudPlacementGroupArgs args, CustomResourceOptions? opts = null)
public CloudPlacementGroup(String name, CloudPlacementGroupArgs args)
public CloudPlacementGroup(String name, CloudPlacementGroupArgs args, CustomResourceOptions options)
type: gcore:CloudPlacementGroup
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 CloudPlacementGroupArgs
- 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 CloudPlacementGroupArgs
- 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 CloudPlacementGroupArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CloudPlacementGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CloudPlacementGroupArgs
- 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 cloudPlacementGroupResource = new Gcore.CloudPlacementGroup("cloudPlacementGroupResource", new()
{
Policy = "string",
Instances = new[]
{
new Gcore.Inputs.CloudPlacementGroupInstanceArgs
{
InstanceId = "string",
InstanceName = "string",
},
},
Name = "string",
ProjectId = 0,
RegionId = 0,
});
example, err := gcore.NewCloudPlacementGroup(ctx, "cloudPlacementGroupResource", &gcore.CloudPlacementGroupArgs{
Policy: pulumi.String("string"),
Instances: gcore.CloudPlacementGroupInstanceArray{
&gcore.CloudPlacementGroupInstanceArgs{
InstanceId: pulumi.String("string"),
InstanceName: pulumi.String("string"),
},
},
Name: pulumi.String("string"),
ProjectId: pulumi.Float64(0),
RegionId: pulumi.Float64(0),
})
var cloudPlacementGroupResource = new CloudPlacementGroup("cloudPlacementGroupResource", CloudPlacementGroupArgs.builder()
.policy("string")
.instances(CloudPlacementGroupInstanceArgs.builder()
.instanceId("string")
.instanceName("string")
.build())
.name("string")
.projectId(0.0)
.regionId(0.0)
.build());
cloud_placement_group_resource = gcore.CloudPlacementGroup("cloudPlacementGroupResource",
policy="string",
instances=[{
"instance_id": "string",
"instance_name": "string",
}],
name="string",
project_id=0,
region_id=0)
const cloudPlacementGroupResource = new gcore.CloudPlacementGroup("cloudPlacementGroupResource", {
policy: "string",
instances: [{
instanceId: "string",
instanceName: "string",
}],
name: "string",
projectId: 0,
regionId: 0,
});
type: gcore:CloudPlacementGroup
properties:
instances:
- instanceId: string
instanceName: string
name: string
policy: string
projectId: 0
regionId: 0
CloudPlacementGroup 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 CloudPlacementGroup resource accepts the following input properties:
- policy str
- The server group policy. Available values: "affinity", "anti-affinity", "soft-anti-affinity".
- instances
Sequence[Cloud
Placement Group Instance Args] - The list of instances in this server group.
- name str
- The name of the server group.
- project_
id float - region_
id float
Outputs
All input properties are implicitly available as output properties. Additionally, the CloudPlacementGroup resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Region string
- Region name
- Servergroup
Id string - The ID of the server group.
- Id string
- The provider-assigned unique ID for this managed resource.
- Region string
- Region name
- Servergroup
Id string - The ID of the server group.
- id String
- The provider-assigned unique ID for this managed resource.
- region String
- Region name
- servergroup
Id String - The ID of the server group.
- id string
- The provider-assigned unique ID for this managed resource.
- region string
- Region name
- servergroup
Id string - The ID of the server group.
- id str
- The provider-assigned unique ID for this managed resource.
- region str
- Region name
- servergroup_
id str - The ID of the server group.
- id String
- The provider-assigned unique ID for this managed resource.
- region String
- Region name
- servergroup
Id String - The ID of the server group.
Look up Existing CloudPlacementGroup Resource
Get an existing CloudPlacementGroup 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?: CloudPlacementGroupState, opts?: CustomResourceOptions): CloudPlacementGroup@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
instances: Optional[Sequence[CloudPlacementGroupInstanceArgs]] = None,
name: Optional[str] = None,
policy: Optional[str] = None,
project_id: Optional[float] = None,
region: Optional[str] = None,
region_id: Optional[float] = None,
servergroup_id: Optional[str] = None) -> CloudPlacementGroupfunc GetCloudPlacementGroup(ctx *Context, name string, id IDInput, state *CloudPlacementGroupState, opts ...ResourceOption) (*CloudPlacementGroup, error)public static CloudPlacementGroup Get(string name, Input<string> id, CloudPlacementGroupState? state, CustomResourceOptions? opts = null)public static CloudPlacementGroup get(String name, Output<String> id, CloudPlacementGroupState state, CustomResourceOptions options)resources: _: type: gcore:CloudPlacementGroup get: id: ${id}- 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.
- Instances
List<Cloud
Placement Group Instance> - The list of instances in this server group.
- Name string
- The name of the server group.
- Policy string
- The server group policy. Available values: "affinity", "anti-affinity", "soft-anti-affinity".
- Project
Id double - Region string
- Region name
- Region
Id double - Servergroup
Id string - The ID of the server group.
- Instances
[]Cloud
Placement Group Instance Args - The list of instances in this server group.
- Name string
- The name of the server group.
- Policy string
- The server group policy. Available values: "affinity", "anti-affinity", "soft-anti-affinity".
- Project
Id float64 - Region string
- Region name
- Region
Id float64 - Servergroup
Id string - The ID of the server group.
- instances
List<Cloud
Placement Group Instance> - The list of instances in this server group.
- name String
- The name of the server group.
- policy String
- The server group policy. Available values: "affinity", "anti-affinity", "soft-anti-affinity".
- project
Id Double - region String
- Region name
- region
Id Double - servergroup
Id String - The ID of the server group.
- instances
Cloud
Placement Group Instance[] - The list of instances in this server group.
- name string
- The name of the server group.
- policy string
- The server group policy. Available values: "affinity", "anti-affinity", "soft-anti-affinity".
- project
Id number - region string
- Region name
- region
Id number - servergroup
Id string - The ID of the server group.
- instances
Sequence[Cloud
Placement Group Instance Args] - The list of instances in this server group.
- name str
- The name of the server group.
- policy str
- The server group policy. Available values: "affinity", "anti-affinity", "soft-anti-affinity".
- project_
id float - region str
- Region name
- region_
id float - servergroup_
id str - The ID of the server group.
- instances List<Property Map>
- The list of instances in this server group.
- name String
- The name of the server group.
- policy String
- The server group policy. Available values: "affinity", "anti-affinity", "soft-anti-affinity".
- project
Id Number - region String
- Region name
- region
Id Number - servergroup
Id String - The ID of the server group.
Supporting Types
CloudPlacementGroupInstance, CloudPlacementGroupInstanceArgs
- Instance
Id string - The ID of the instance, corresponding to the attribute 'id'.
- Instance
Name string - The name of the instance, corresponding to the attribute 'name'.
- Instance
Id string - The ID of the instance, corresponding to the attribute 'id'.
- Instance
Name string - The name of the instance, corresponding to the attribute 'name'.
- instance
Id String - The ID of the instance, corresponding to the attribute 'id'.
- instance
Name String - The name of the instance, corresponding to the attribute 'name'.
- instance
Id string - The ID of the instance, corresponding to the attribute 'id'.
- instance
Name string - The name of the instance, corresponding to the attribute 'name'.
- instance_
id str - The ID of the instance, corresponding to the attribute 'id'.
- instance_
name str - The name of the instance, corresponding to the attribute 'name'.
- instance
Id String - The ID of the instance, corresponding to the attribute 'id'.
- instance
Name String - The name of the instance, corresponding to the attribute 'name'.
Import
$ pulumi import gcore:index/cloudPlacementGroup:CloudPlacementGroup example '<project_id>/<region_id>/<group_id>'
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- gcore g-core/terraform-provider-gcore
- License
- Notes
- This Pulumi package is based on the
gcoreTerraform Provider.
published on Tuesday, Mar 24, 2026 by g-core
