1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. InstanceGroup
Google Cloud Classic v7.20.0 published on Wednesday, Apr 24, 2024 by Pulumi

gcp.compute.InstanceGroup

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.20.0 published on Wednesday, Apr 24, 2024 by Pulumi

    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/v7/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=[
            gcp.compute.InstanceGroupNamedPortArgs(
                name="http",
                port=8080,
            ),
            gcp.compute.InstanceGroupNamedPortArgs(
                name="https",
                port=8443,
            ),
        ],
        zone="us-central1-a")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/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
    

    Example Usage - Recreating an instance group in use

    Recreating an instance group that’s in use by another resource will give a resourceInUseByAnotherResource error. Use lifecycle.create_before_destroy as shown in this example to avoid this type of error.

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const debianImage = gcp.compute.getImage({
        family: "debian-11",
        project: "debian-cloud",
    });
    const stagingVm = new gcp.compute.Instance("staging_vm", {
        name: "staging-vm",
        machineType: "e2-medium",
        zone: "us-central1-c",
        bootDisk: {
            initializeParams: {
                image: debianImage.then(debianImage => debianImage.selfLink),
            },
        },
        networkInterfaces: [{
            network: "default",
        }],
    });
    const stagingGroup = new gcp.compute.InstanceGroup("staging_group", {
        name: "staging-instance-group",
        zone: "us-central1-c",
        instances: [stagingVm.id],
        namedPorts: [
            {
                name: "http",
                port: 8080,
            },
            {
                name: "https",
                port: 8443,
            },
        ],
    });
    const stagingHealth = new gcp.compute.HttpsHealthCheck("staging_health", {
        name: "staging-health",
        requestPath: "/health_check",
    });
    const stagingService = new gcp.compute.BackendService("staging_service", {
        name: "staging-service",
        portName: "https",
        protocol: "HTTPS",
        backends: [{
            group: stagingGroup.id,
        }],
        healthChecks: stagingHealth.id,
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    debian_image = gcp.compute.get_image(family="debian-11",
        project="debian-cloud")
    staging_vm = gcp.compute.Instance("staging_vm",
        name="staging-vm",
        machine_type="e2-medium",
        zone="us-central1-c",
        boot_disk=gcp.compute.InstanceBootDiskArgs(
            initialize_params=gcp.compute.InstanceBootDiskInitializeParamsArgs(
                image=debian_image.self_link,
            ),
        ),
        network_interfaces=[gcp.compute.InstanceNetworkInterfaceArgs(
            network="default",
        )])
    staging_group = gcp.compute.InstanceGroup("staging_group",
        name="staging-instance-group",
        zone="us-central1-c",
        instances=[staging_vm.id],
        named_ports=[
            gcp.compute.InstanceGroupNamedPortArgs(
                name="http",
                port=8080,
            ),
            gcp.compute.InstanceGroupNamedPortArgs(
                name="https",
                port=8443,
            ),
        ])
    staging_health = gcp.compute.HttpsHealthCheck("staging_health",
        name="staging-health",
        request_path="/health_check")
    staging_service = gcp.compute.BackendService("staging_service",
        name="staging-service",
        port_name="https",
        protocol="HTTPS",
        backends=[gcp.compute.BackendServiceBackendArgs(
            group=staging_group.id,
        )],
        health_checks=staging_health.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		debianImage, err := compute.LookupImage(ctx, &compute.LookupImageArgs{
    			Family:  pulumi.StringRef("debian-11"),
    			Project: pulumi.StringRef("debian-cloud"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		stagingVm, err := compute.NewInstance(ctx, "staging_vm", &compute.InstanceArgs{
    			Name:        pulumi.String("staging-vm"),
    			MachineType: pulumi.String("e2-medium"),
    			Zone:        pulumi.String("us-central1-c"),
    			BootDisk: &compute.InstanceBootDiskArgs{
    				InitializeParams: &compute.InstanceBootDiskInitializeParamsArgs{
    					Image: pulumi.String(debianImage.SelfLink),
    				},
    			},
    			NetworkInterfaces: compute.InstanceNetworkInterfaceArray{
    				&compute.InstanceNetworkInterfaceArgs{
    					Network: pulumi.String("default"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		stagingGroup, err := compute.NewInstanceGroup(ctx, "staging_group", &compute.InstanceGroupArgs{
    			Name: pulumi.String("staging-instance-group"),
    			Zone: pulumi.String("us-central1-c"),
    			Instances: pulumi.StringArray{
    				stagingVm.ID(),
    			},
    			NamedPorts: compute.InstanceGroupNamedPortTypeArray{
    				&compute.InstanceGroupNamedPortTypeArgs{
    					Name: pulumi.String("http"),
    					Port: pulumi.Int(8080),
    				},
    				&compute.InstanceGroupNamedPortTypeArgs{
    					Name: pulumi.String("https"),
    					Port: pulumi.Int(8443),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		stagingHealth, err := compute.NewHttpsHealthCheck(ctx, "staging_health", &compute.HttpsHealthCheckArgs{
    			Name:        pulumi.String("staging-health"),
    			RequestPath: pulumi.String("/health_check"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewBackendService(ctx, "staging_service", &compute.BackendServiceArgs{
    			Name:     pulumi.String("staging-service"),
    			PortName: pulumi.String("https"),
    			Protocol: pulumi.String("HTTPS"),
    			Backends: compute.BackendServiceBackendArray{
    				&compute.BackendServiceBackendArgs{
    					Group: stagingGroup.ID(),
    				},
    			},
    			HealthChecks: stagingHealth.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 debianImage = Gcp.Compute.GetImage.Invoke(new()
        {
            Family = "debian-11",
            Project = "debian-cloud",
        });
    
        var stagingVm = new Gcp.Compute.Instance("staging_vm", new()
        {
            Name = "staging-vm",
            MachineType = "e2-medium",
            Zone = "us-central1-c",
            BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
            {
                InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
                {
                    Image = debianImage.Apply(getImageResult => getImageResult.SelfLink),
                },
            },
            NetworkInterfaces = new[]
            {
                new Gcp.Compute.Inputs.InstanceNetworkInterfaceArgs
                {
                    Network = "default",
                },
            },
        });
    
        var stagingGroup = new Gcp.Compute.InstanceGroup("staging_group", new()
        {
            Name = "staging-instance-group",
            Zone = "us-central1-c",
            Instances = new[]
            {
                stagingVm.Id,
            },
            NamedPorts = new[]
            {
                new Gcp.Compute.Inputs.InstanceGroupNamedPortArgs
                {
                    Name = "http",
                    Port = 8080,
                },
                new Gcp.Compute.Inputs.InstanceGroupNamedPortArgs
                {
                    Name = "https",
                    Port = 8443,
                },
            },
        });
    
        var stagingHealth = new Gcp.Compute.HttpsHealthCheck("staging_health", new()
        {
            Name = "staging-health",
            RequestPath = "/health_check",
        });
    
        var stagingService = new Gcp.Compute.BackendService("staging_service", new()
        {
            Name = "staging-service",
            PortName = "https",
            Protocol = "HTTPS",
            Backends = new[]
            {
                new Gcp.Compute.Inputs.BackendServiceBackendArgs
                {
                    Group = stagingGroup.Id,
                },
            },
            HealthChecks = stagingHealth.Id,
        });
    
    });
    
    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()        
                .name("staging-vm")
                .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()        
                .name("staging-instance-group")
                .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()        
                .name("staging-health")
                .requestPath("/health_check")
                .build());
    
            var stagingService = new BackendService("stagingService", BackendServiceArgs.builder()        
                .name("staging-service")
                .portName("https")
                .protocol("HTTPS")
                .backends(BackendServiceBackendArgs.builder()
                    .group(stagingGroup.id())
                    .build())
                .healthChecks(stagingHealth.id())
                .build());
    
        }
    }
    
    resources:
      stagingGroup:
        type: gcp:compute:InstanceGroup
        name: staging_group
        properties:
          name: staging-instance-group
          zone: us-central1-c
          instances:
            - ${stagingVm.id}
          namedPorts:
            - name: http
              port: '8080'
            - name: https
              port: '8443'
      stagingVm:
        type: gcp:compute:Instance
        name: staging_vm
        properties:
          name: staging-vm
          machineType: e2-medium
          zone: us-central1-c
          bootDisk:
            initializeParams:
              image: ${debianImage.selfLink}
          networkInterfaces:
            - network: default
      stagingService:
        type: gcp:compute:BackendService
        name: staging_service
        properties:
          name: staging-service
          portName: https
          protocol: HTTPS
          backends:
            - group: ${stagingGroup.id}
          healthChecks: ${stagingHealth.id}
      stagingHealth:
        type: gcp:compute:HttpsHealthCheck
        name: staging_health
        properties:
          name: staging-health
          requestPath: /health_check
    variables:
      debianImage:
        fn::invoke:
          Function: gcp:compute:getImage
          Arguments:
            family: debian-11
            project: debian-cloud
    

    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.

    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=[gcp.compute.InstanceGroupNamedPortArgs(
            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.
    NamedPorts List<InstanceGroupNamedPort>
    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 nor instances 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.
    NamedPorts []InstanceGroupNamedPortTypeArgs
    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 nor instances 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.
    namedPorts List<InstanceGroupNamedPort>
    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 nor instances 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.
    namedPorts InstanceGroupNamedPort[]
    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 nor instances 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[InstanceGroupNamedPortArgs]
    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 nor instances 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.
    namedPorts 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 nor instances 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:

    Id string
    The provider-assigned unique ID for this managed resource.
    SelfLink string
    The URI of the created resource.
    Size int
    The number of instances in the group.
    Id string
    The provider-assigned unique ID for this managed resource.
    SelfLink string
    The URI of the created resource.
    Size int
    The number of instances in the group.
    id String
    The provider-assigned unique ID for this managed resource.
    selfLink String
    The URI of the created resource.
    size Integer
    The number of instances in the group.
    id string
    The provider-assigned unique ID for this managed resource.
    selfLink string
    The URI of the created resource.
    size number
    The number of instances in the group.
    id str
    The provider-assigned unique ID for this managed resource.
    self_link str
    The URI of the created resource.
    size int
    The number of instances in the group.
    id String
    The provider-assigned unique ID for this managed resource.
    selfLink String
    The URI of the created resource.
    size Number
    The number of instances in the group.

    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.
    The following state arguments are supported:
    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.
    NamedPorts List<InstanceGroupNamedPort>
    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 nor instances 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.
    SelfLink 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.
    NamedPorts []InstanceGroupNamedPortTypeArgs
    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 nor instances 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.
    SelfLink 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.
    namedPorts List<InstanceGroupNamedPort>
    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 nor instances 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.
    selfLink 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.
    namedPorts InstanceGroupNamedPort[]
    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 nor instances 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.
    selfLink 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[InstanceGroupNamedPortArgs]
    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 nor instances 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.
    namedPorts 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 nor instances 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.
    selfLink 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

    Name string
    The name which the port will be mapped to.
    Port int
    The port number to map the name to.
    Name string
    The name which the port will be mapped to.
    Port int
    The port number to map the name to.
    name String
    The name which the port will be mapped to.
    port Integer
    The port number to map the name to.
    name string
    The name which the port will be mapped to.
    port number
    The port number to map the name to.
    name str
    The name which the port will be mapped to.
    port int
    The port number to map the name to.
    name String
    The name which the port will be mapped to.
    port Number
    The port number to map the name to.

    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.
    gcp logo
    Google Cloud Classic v7.20.0 published on Wednesday, Apr 24, 2024 by Pulumi