gcp.compute.InstanceGroup
Explore with Pulumi AI
Creates a group of dissimilar Compute Engine virtual machine instances. For more information, see the official documentation and API
Example Usage
Empty Instance Group
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()
{
Description = "Test instance group",
Zone = "us-central1-a",
Network = google_compute_network.Default.Id,
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v6/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{
Description: pulumi.String("Test instance group"),
Zone: pulumi.String("us-central1-a"),
Network: pulumi.Any(google_compute_network.Default.Id),
})
if err != nil {
return err
}
return nil
})
}
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.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 test = new InstanceGroup("test", InstanceGroupArgs.builder()
.description("Test instance group")
.zone("us-central1-a")
.network(google_compute_network.default().id())
.build());
}
}
import pulumi
import pulumi_gcp as gcp
test = gcp.compute.InstanceGroup("test",
description="Test instance group",
zone="us-central1-a",
network=google_compute_network["default"]["id"])
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const test = new gcp.compute.InstanceGroup("test", {
description: "Test instance group",
zone: "us-central1-a",
network: google_compute_network["default"].id,
});
resources:
test:
type: gcp:compute:InstanceGroup
properties:
description: Test instance group
zone: us-central1-a
network: ${google_compute_network.default.id}
Example Usage - With instances and named ports
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()
{
Description = "Test instance group",
Instances = new[]
{
google_compute_instance.Test.Id,
google_compute_instance.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/v6/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{
Description: pulumi.String("Test instance group"),
Instances: pulumi.StringArray{
google_compute_instance.Test.Id,
google_compute_instance.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
})
}
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.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 webservers = new InstanceGroup("webservers", InstanceGroupArgs.builder()
.description("Test instance group")
.instances(
google_compute_instance.test().id(),
google_compute_instance.test2().id())
.namedPorts(
InstanceGroupNamedPortArgs.builder()
.name("http")
.port("8080")
.build(),
InstanceGroupNamedPortArgs.builder()
.name("https")
.port("8443")
.build())
.zone("us-central1-a")
.build());
}
}
import pulumi
import pulumi_gcp as gcp
webservers = gcp.compute.InstanceGroup("webservers",
description="Test instance group",
instances=[
google_compute_instance["test"]["id"],
google_compute_instance["test2"]["id"],
],
named_ports=[
gcp.compute.InstanceGroupNamedPortArgs(
name="http",
port=8080,
),
gcp.compute.InstanceGroupNamedPortArgs(
name="https",
port=8443,
),
],
zone="us-central1-a")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const webservers = new gcp.compute.InstanceGroup("webservers", {
description: "Test instance group",
instances: [
google_compute_instance.test.id,
google_compute_instance.test2.id,
],
namedPorts: [
{
name: "http",
port: 8080,
},
{
name: "https",
port: 8443,
},
],
zone: "us-central1-a",
});
resources:
webservers:
type: gcp:compute:InstanceGroup
properties:
description: Test instance group
instances:
- ${google_compute_instance.test.id}
- ${google_compute_instance.test2.id}
namedPorts:
- name: http
port: '8080'
- name: https
port: '8443'
zone: us-central1-a
Example Usage - Recreating an instance group in use
Coming soon!
Coming soon!
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetImageArgs;
import com.pulumi.gcp.compute.Instance;
import com.pulumi.gcp.compute.InstanceArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
import com.pulumi.gcp.compute.InstanceGroup;
import com.pulumi.gcp.compute.InstanceGroupArgs;
import com.pulumi.gcp.compute.inputs.InstanceGroupNamedPortArgs;
import com.pulumi.gcp.compute.HttpsHealthCheck;
import com.pulumi.gcp.compute.HttpsHealthCheckArgs;
import com.pulumi.gcp.compute.BackendService;
import com.pulumi.gcp.compute.BackendServiceArgs;
import com.pulumi.gcp.compute.inputs.BackendServiceBackendArgs;
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) {
final var debianImage = ComputeFunctions.getImage(GetImageArgs.builder()
.family("debian-11")
.project("debian-cloud")
.build());
var stagingVm = new Instance("stagingVm", InstanceArgs.builder()
.machineType("e2-medium")
.zone("us-central1-c")
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image(debianImage.applyValue(getImageResult -> getImageResult.selfLink()))
.build())
.build())
.networkInterfaces(InstanceNetworkInterfaceArgs.builder()
.network("default")
.build())
.build());
var stagingGroup = new InstanceGroup("stagingGroup", InstanceGroupArgs.builder()
.zone("us-central1-c")
.instances(stagingVm.id())
.namedPorts(
InstanceGroupNamedPortArgs.builder()
.name("http")
.port("8080")
.build(),
InstanceGroupNamedPortArgs.builder()
.name("https")
.port("8443")
.build())
.build());
var stagingHealth = new HttpsHealthCheck("stagingHealth", HttpsHealthCheckArgs.builder()
.requestPath("/health_check")
.build());
var stagingService = new BackendService("stagingService", BackendServiceArgs.builder()
.portName("https")
.protocol("HTTPS")
.backends(BackendServiceBackendArgs.builder()
.group(stagingGroup.id())
.build())
.healthChecks(stagingHealth.id())
.build());
}
}
Coming soon!
Coming soon!
resources:
stagingGroup:
type: gcp:compute:InstanceGroup
properties:
zone: us-central1-c
instances:
- ${stagingVm.id}
namedPorts:
- name: http
port: '8080'
- name: https
port: '8443'
stagingVm:
type: gcp:compute:Instance
properties:
machineType: e2-medium
zone: us-central1-c
bootDisk:
initializeParams:
image: ${debianImage.selfLink}
networkInterfaces:
- network: default
stagingService:
type: gcp:compute:BackendService
properties:
portName: https
protocol: HTTPS
backends:
- group: ${stagingGroup.id}
healthChecks:
- ${stagingHealth.id}
stagingHealth:
type: gcp:compute:HttpsHealthCheck
properties:
requestPath: /health_check
variables:
debianImage:
fn::invoke:
Function: gcp:compute:getImage
Arguments:
family: debian-11
project: debian-cloud
Create InstanceGroup Resource
new InstanceGroup(name: string, args?: InstanceGroupArgs, opts?: CustomResourceOptions);
@overload
def InstanceGroup(resource_name: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
instances: Optional[Sequence[str]] = None,
name: Optional[str] = None,
named_ports: Optional[Sequence[InstanceGroupNamedPortArgs]] = None,
network: Optional[str] = None,
project: Optional[str] = None,
zone: Optional[str] = None)
@overload
def InstanceGroup(resource_name: str,
args: Optional[InstanceGroupArgs] = None,
opts: Optional[ResourceOptions] = None)
func NewInstanceGroup(ctx *Context, name string, args *InstanceGroupArgs, opts ...ResourceOption) (*InstanceGroup, error)
public InstanceGroup(string name, InstanceGroupArgs? args = null, CustomResourceOptions? opts = null)
public InstanceGroup(String name, InstanceGroupArgs args)
public InstanceGroup(String name, InstanceGroupArgs args, CustomResourceOptions options)
type: gcp:compute:InstanceGroup
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args InstanceGroupArgs
- 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 InstanceGroupArgs
- 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 InstanceGroupArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args InstanceGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args InstanceGroupArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
InstanceGroup 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 InstanceGroup resource accepts the following input properties:
- Description string
An optional textual description of the instance group.
- Instances List<string>
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- Name 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.
- Named
Ports List<InstanceGroup Named Port> The named port configuration. See the section below for details on configuration. Structure is documented below.
- Network 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
network
norinstances
is specified, this field will be blank).- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Zone string
The zone that this instance group should be created in.
- Description string
An optional textual description of the instance group.
- Instances []string
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- Name 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.
- Named
Ports []InstanceGroup Named Port Type Args The named port configuration. See the section below for details on configuration. Structure is documented below.
- Network 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
network
norinstances
is specified, this field will be blank).- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Zone string
The zone that this instance group should be created in.
- description String
An optional textual description of the instance group.
- instances List<String>
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- name 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.
- named
Ports List<InstanceGroup Named Port> The named port configuration. See the section below for details on configuration. Structure is documented below.
- network 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
network
norinstances
is specified, this field will be blank).- project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone String
The zone that this instance group should be created in.
- description string
An optional textual description of the instance group.
- instances string[]
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- name 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.
- named
Ports InstanceGroup Named Port[] The named port configuration. See the section below for details on configuration. Structure is documented below.
- network 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
network
norinstances
is specified, this field will be blank).- project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone string
The zone that this instance group should be created in.
- description str
An optional textual description of the instance group.
- instances Sequence[str]
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- name str
The name of the instance group. Must be 1-63 characters long and comply with RFC1035. Supported characters include lowercase letters, numbers, and hyphens.
- named_
ports Sequence[InstanceGroup Named Port Args] The named port configuration. See the section below for details on configuration. Structure is documented below.
- network str
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
network
norinstances
is specified, this field will be blank).- project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone str
The zone that this instance group should be created in.
- description String
An optional textual description of the instance group.
- instances List<String>
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- name 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.
- named
Ports List<Property Map> The named port configuration. See the section below for details on configuration. Structure is documented below.
- network 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
network
norinstances
is specified, this field will be blank).- project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone String
The zone that this instance group should be created in.
Outputs
All input properties are implicitly available as output properties. Additionally, the InstanceGroup resource produces the following output properties:
Look up Existing InstanceGroup Resource
Get an existing InstanceGroup 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?: InstanceGroupState, opts?: CustomResourceOptions): InstanceGroup
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
instances: Optional[Sequence[str]] = None,
name: Optional[str] = None,
named_ports: Optional[Sequence[InstanceGroupNamedPortArgs]] = None,
network: Optional[str] = None,
project: Optional[str] = None,
self_link: Optional[str] = None,
size: Optional[int] = None,
zone: Optional[str] = None) -> InstanceGroup
func GetInstanceGroup(ctx *Context, name string, id IDInput, state *InstanceGroupState, opts ...ResourceOption) (*InstanceGroup, error)
public static InstanceGroup Get(string name, Input<string> id, InstanceGroupState? state, CustomResourceOptions? opts = null)
public static InstanceGroup get(String name, Output<String> id, InstanceGroupState 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.
- Description string
An optional textual description of the instance group.
- Instances List<string>
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- Name 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.
- Named
Ports List<InstanceGroup Named Port> The named port configuration. See the section below for details on configuration. Structure is documented below.
- Network 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
network
norinstances
is specified, this field will be blank).- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Self
Link string The URI of the created resource.
- Size int
The number of instances in the group.
- Zone string
The zone that this instance group should be created in.
- Description string
An optional textual description of the instance group.
- Instances []string
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- Name 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.
- Named
Ports []InstanceGroup Named Port Type Args The named port configuration. See the section below for details on configuration. Structure is documented below.
- Network 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
network
norinstances
is specified, this field will be blank).- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Self
Link string The URI of the created resource.
- Size int
The number of instances in the group.
- Zone string
The zone that this instance group should be created in.
- description String
An optional textual description of the instance group.
- instances List<String>
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- name 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.
- named
Ports List<InstanceGroup Named Port> The named port configuration. See the section below for details on configuration. Structure is documented below.
- network 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
network
norinstances
is specified, this field will be blank).- project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- self
Link String The URI of the created resource.
- size Integer
The number of instances in the group.
- zone String
The zone that this instance group should be created in.
- description string
An optional textual description of the instance group.
- instances string[]
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- name 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.
- named
Ports InstanceGroup Named Port[] The named port configuration. See the section below for details on configuration. Structure is documented below.
- network 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
network
norinstances
is specified, this field will be blank).- project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- self
Link string The URI of the created resource.
- size number
The number of instances in the group.
- zone string
The zone that this instance group should be created in.
- description str
An optional textual description of the instance group.
- instances Sequence[str]
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- name str
The name of the instance group. Must be 1-63 characters long and comply with RFC1035. Supported characters include lowercase letters, numbers, and hyphens.
- named_
ports Sequence[InstanceGroup Named Port Args] The named port configuration. See the section below for details on configuration. Structure is documented below.
- network str
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
network
norinstances
is specified, this field will be blank).- project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- self_
link str The URI of the created resource.
- size int
The number of instances in the group.
- zone str
The zone that this instance group should be created in.
- description String
An optional textual description of the instance group.
- instances List<String>
The list of instances in the group, in
self_link
format. When adding instances they must all be in the same network and zone as the instance group.- name 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.
- named
Ports List<Property Map> The named port configuration. See the section below for details on configuration. Structure is documented below.
- network 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
network
norinstances
is specified, this field will be blank).- project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- self
Link String The URI of the created resource.
- size Number
The number of instances in the group.
- zone String
The zone that this instance group should be created in.
Supporting Types
InstanceGroupNamedPort, InstanceGroupNamedPortArgs
Import
Instance group can be imported using the zone
and name
with an optional project
, e.g.
$ pulumi import gcp:compute/instanceGroup:InstanceGroup webservers us-central1-a/terraform-webservers
$ pulumi import gcp:compute/instanceGroup:InstanceGroup webservers big-project/us-central1-a/terraform-webservers
$ pulumi import gcp:compute/instanceGroup:InstanceGroup webservers projects/big-project/zones/us-central1-a/instanceGroups/terraform-webservers
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
google-beta
Terraform Provider.