InstanceGroup class
Creates a group of dissimilar Compute Engine virtual machine instances. For more information, see the official documentation and API
Example Usage
Empty Instance Group
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const test = new gcp.compute.InstanceGroup("test", {
name: "test",
description: "Test instance group",
zone: "us-central1-a",
network: _default.id,
});
import pulumi
import pulumi_gcp as gcp
test = gcp.compute.InstanceGroup("test",
name="test",
description="Test instance group",
zone="us-central1-a",
network=default["id"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var test = new Gcp.Compute.InstanceGroup("test", new()
{
Name = "test",
Description = "Test instance group",
Zone = "us-central1-a",
Network = @default.Id,
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := compute.NewInstanceGroup(ctx, "test", &compute.InstanceGroupArgs{
Name: pulumi.String("test"),
Description: pulumi.String("Test instance group"),
Zone: pulumi.String("us-central1-a"),
Network: pulumi.Any(_default.Id),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_compute_instancegroup" "test" {
name = "test"
description = "Test instance group"
zone = "us-central1-a"
network = default.id
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.InstanceGroup;
import com.pulumi.gcp.compute.InstanceGroupArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 test = new InstanceGroup("test", InstanceGroupArgs.builder()
.name("test")
.description("Test instance group")
.zone("us-central1-a")
.network(default_.get("id"))
.build());
}
}
resources:
test:
type: gcp:compute:InstanceGroup
properties:
name: test
description: Test instance group
zone: us-central1-a
network: ${default.id}
Example Usage - With instances and named ports
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const webservers = new gcp.compute.InstanceGroup("webservers", {
name: "webservers",
description: "Test instance group",
instances: [
test.id,
test2.id,
],
namedPorts: [
{
name: "http",
port: 8080,
},
{
name: "https",
port: 8443,
},
],
zone: "us-central1-a",
});
import pulumi
import pulumi_gcp as gcp
webservers = gcp.compute.InstanceGroup("webservers",
name="webservers",
description="Test instance group",
instances=[
test["id"],
test2["id"],
],
named_ports=[
{
"name": "http",
"port": 8080,
},
{
"name": "https",
"port": 8443,
},
],
zone="us-central1-a")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var webservers = new Gcp.Compute.InstanceGroup("webservers", new()
{
Name = "webservers",
Description = "Test instance group",
Instances = new[]
{
test.Id,
test2.Id,
},
NamedPorts = new[]
{
new Gcp.Compute.Inputs.InstanceGroupNamedPortArgs
{
Name = "http",
Port = 8080,
},
new Gcp.Compute.Inputs.InstanceGroupNamedPortArgs
{
Name = "https",
Port = 8443,
},
},
Zone = "us-central1-a",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := compute.NewInstanceGroup(ctx, "webservers", &compute.InstanceGroupArgs{
Name: pulumi.String("webservers"),
Description: pulumi.String("Test instance group"),
Instances: pulumi.StringArray{
test.Id,
test2.Id,
},
NamedPorts: compute.InstanceGroupNamedPortTypeArray{
&compute.InstanceGroupNamedPortTypeArgs{
Name: pulumi.String("http"),
Port: pulumi.Int(8080),
},
&compute.InstanceGroupNamedPortTypeArgs{
Name: pulumi.String("https"),
Port: pulumi.Int(8443),
},
},
Zone: pulumi.String("us-central1-a"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_compute_instancegroup" "webservers" {
name = "webservers"
description = "Test instance group"
instances = [test.id, test2.id]
named_ports {
name = "http"
port = "8080"
}
named_ports {
name = "https"
port = "8443"
}
zone = "us-central1-a"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.InstanceGroup;
import com.pulumi.gcp.compute.InstanceGroupArgs;
import com.pulumi.gcp.compute.inputs.InstanceGroupNamedPortArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 webservers = new InstanceGroup("webservers", InstanceGroupArgs.builder()
.name("webservers")
.description("Test instance group")
.instances(
test.get("id"),
test2.get("id"))
.namedPorts(
InstanceGroupNamedPortArgs.builder()
.name("http")
.port(8080)
.build(),
InstanceGroupNamedPortArgs.builder()
.name("https")
.port(8443)
.build())
.zone("us-central1-a")
.build());
}
}
resources:
webservers:
type: gcp:compute:InstanceGroup
properties:
name: webservers
description: Test instance group
instances:
- ${test.id}
- ${test2.id}
namedPorts:
- name: http
port: '8080'
- name: https
port: '8443'
zone: us-central1-a
Import
Instance groups can be imported using the zone and name with an optional project, e.g.
projects/{{project_id}}/zones/{{zone}}/instanceGroups/{{instance_group_id}}{{project_id}}/{{zone}}/{{instance_group_id}}{{zone}}/{{instance_group_id}}
When using the pulumi import command, instance groups can be imported using one of the formats above. For example:
$ pulumi import gcp:compute/instanceGroup:InstanceGroup default {{zone}}/{{instance_group_id}}
$ pulumi import gcp:compute/instanceGroup:InstanceGroup default {{project_id}}/{{zone}}/{{instance_group_id}}
$ pulumi import gcp:compute/instanceGroup:InstanceGroup default projects/{{project_id}}/zones/{{zone}}/instanceGroups/{{instance_group_id}}
Constructors
- InstanceGroup(String name, {InstanceGroupArgs? args, CustomResourceOptions? options})
-
Creates a new InstanceGroup.
nameThe Pulumi resource name.argsArguments used to configure this InstanceGroup. The set of arguments for InstanceGroup.optionsResource options controlling this resource's behavior. - InstanceGroup.reference(String urn)
- Creates a typed reference to an existing InstanceGroup resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE".
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
description
↔ Output<
String?> -
An optional textual description of the instance
group.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
-
instances
↔ Output<
List< String> > -
The list of instances in the group, in
selfLinkformat. When adding instances they must all be in the same network and zone as the instance group.latefinal - isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
The name of the instance group. Must be 1-63
characters long and comply with
RFC1035. Supported characters
include lowercase letters, numbers, and hyphens.
latefinal
-
namedPorts
↔ Output<
List< InstanceGroupNamedPort> ?> -
The named port configuration. See the section below
for details on configuration. Structure is documented below.
latefinal
-
network
↔ Output<
String> -
The URL of the network the instance group is in. If
this is different from the network where the instances are in, the creation
fails. Defaults to the network where the instances are in (if neither
networknorinstancesis specified, this field will be blank).latefinal -
project
↔ Output<
String> -
The ID of the project in which the resource belongs. If it
is not provided, the provider project is used.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selfLink
↔ Output<
String> -
The URI of the created resource.
latefinal
-
size
↔ Output<
int> -
The number of instances in the group.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
zone
↔ Output<
String> -
The zone that this instance group should be created in.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {InstanceGroupState? state, CustomResourceOptions? options}) → InstanceGroup -
Gets an existing InstanceGroup resource's state with the given
nameandid.