@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
125 lines • 4.92 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.ComputeClusterHostGroup = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `vsphere.ComputeClusterHostGroup` resource can be used to manage groups
* of hosts in a cluster, either created by the
* `vsphere.ComputeCluster` resource or looked up
* by the `vsphere.ComputeCluster` data source.
*
* This resource mainly serves as an input to the
* `vsphere.ComputeClusterVmHostRule`
* resource - see the documentation for that resource for further details on how
* to use host groups.
*
* > **NOTE:** This resource requires vCenter and is not available on direct ESXi
* connections.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const config = new pulumi.Config();
* const datacenter = config.get("datacenter") || "dc-01";
* const hosts = config.getObject<any>("hosts") || [
* "esxi-01.example.com",
* "esxi-02.example.com",
* "esxi-03.example.com",
* ];
* const datacenterGetDatacenter = vsphere.getDatacenter({
* name: datacenter,
* });
* const hostsGetHost = (new Array(hosts.length)).map((_, i) => i).map(__index => (vsphere.getHost({
* name: hosts[__index],
* datacenterId: _arg0_.id,
* })));
* const computeCluster = new vsphere.ComputeCluster("compute_cluster", {
* name: "compute-cluster-test",
* datacenterId: dc.id,
* hostSystemIds: [hostsGetHost.map(__item => __item.id)],
* drsEnabled: true,
* drsAutomationLevel: "fullyAutomated",
* haEnabled: true,
* });
* const clusterHostGroup = new vsphere.ComputeClusterHostGroup("cluster_host_group", {
* name: "test-cluster-host-group",
* computeClusterId: computeCluster.id,
* hostSystemIds: [hostsGetHost.map(__item => __item.id)],
* });
* ```
*
* ## Import
*
* An existing group can be imported into this resource by
*
* supplying both the path to the cluster, and the name of the host group. If the
*
* name or cluster is not found, or if the group is of a different type, an error
*
* will be returned. An example is below:
*
* [docs-import]: https://developer.hashicorp.com/terraform/cli/import
*
* ```sh
* $ pulumi import vsphere:index/computeClusterHostGroup:ComputeClusterHostGroup cluster_host_group \
* ```
*
* '{"compute_cluster_path": "/dc1/host/cluster1", \
*
* "name": "pulumi-test-cluster-host-group"}'
*/
class ComputeClusterHostGroup extends pulumi.CustomResource {
/**
* Get an existing ComputeClusterHostGroup resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new ComputeClusterHostGroup(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of ComputeClusterHostGroup. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === ComputeClusterHostGroup.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["computeClusterId"] = state?.computeClusterId;
resourceInputs["hostSystemIds"] = state?.hostSystemIds;
resourceInputs["name"] = state?.name;
}
else {
const args = argsOrState;
if (args?.computeClusterId === undefined && !opts.urn) {
throw new Error("Missing required property 'computeClusterId'");
}
resourceInputs["computeClusterId"] = args?.computeClusterId;
resourceInputs["hostSystemIds"] = args?.hostSystemIds;
resourceInputs["name"] = args?.name;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ComputeClusterHostGroup.__pulumiType, name, resourceInputs, opts);
}
}
exports.ComputeClusterHostGroup = ComputeClusterHostGroup;
/** @internal */
ComputeClusterHostGroup.__pulumiType = 'vsphere:index/computeClusterHostGroup:ComputeClusterHostGroup';
//# sourceMappingURL=computeClusterHostGroup.js.map