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
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"])
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/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
})
}
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 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()
.name("test")
.description("Test instance group")
.zone("us-central1-a")
.network(default_.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")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/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
})
}
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 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()
.name("webservers")
.description("Test instance group")
.instances(
test.id(),
test2.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
Create InstanceGroup Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new InstanceGroup(name: string, args?: InstanceGroupArgs, opts?: CustomResourceOptions);
@overload
def InstanceGroup(resource_name: str,
args: Optional[InstanceGroupArgs] = None,
opts: Optional[ResourceOptions] = None)
@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)
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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var instanceGroupResource = new Gcp.Compute.InstanceGroup("instanceGroupResource", new()
{
Description = "string",
Instances = new[]
{
"string",
},
Name = "string",
NamedPorts = new[]
{
new Gcp.Compute.Inputs.InstanceGroupNamedPortArgs
{
Name = "string",
Port = 0,
},
},
Network = "string",
Project = "string",
Zone = "string",
});
example, err := compute.NewInstanceGroup(ctx, "instanceGroupResource", &compute.InstanceGroupArgs{
Description: pulumi.String("string"),
Instances: pulumi.StringArray{
pulumi.String("string"),
},
Name: pulumi.String("string"),
NamedPorts: compute.InstanceGroupNamedPortTypeArray{
&compute.InstanceGroupNamedPortTypeArgs{
Name: pulumi.String("string"),
Port: pulumi.Int(0),
},
},
Network: pulumi.String("string"),
Project: pulumi.String("string"),
Zone: pulumi.String("string"),
})
var instanceGroupResource = new InstanceGroup("instanceGroupResource", InstanceGroupArgs.builder()
.description("string")
.instances("string")
.name("string")
.namedPorts(InstanceGroupNamedPortArgs.builder()
.name("string")
.port(0)
.build())
.network("string")
.project("string")
.zone("string")
.build());
instance_group_resource = gcp.compute.InstanceGroup("instanceGroupResource",
description="string",
instances=["string"],
name="string",
named_ports=[{
"name": "string",
"port": 0,
}],
network="string",
project="string",
zone="string")
const instanceGroupResource = new gcp.compute.InstanceGroup("instanceGroupResource", {
description: "string",
instances: ["string"],
name: "string",
namedPorts: [{
name: "string",
port: 0,
}],
network: "string",
project: "string",
zone: "string",
});
type: gcp:compute:InstanceGroup
properties:
description: string
instances:
- string
name: string
namedPorts:
- name: string
port: 0
network: string
project: string
zone: string
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 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}}
To learn more about importing existing cloud resources, see Importing resources.
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.