All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.compute.kotlin.InstanceGroupArgs.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.13.1.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.compute.kotlin

import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.compute.InstanceGroupArgs.builder
import com.pulumi.gcp.compute.kotlin.inputs.InstanceGroupNamedPortArgs
import com.pulumi.gcp.compute.kotlin.inputs.InstanceGroupNamedPortArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName

/**
 * Creates a group of dissimilar Compute Engine virtual machine instances.
 * For more information, see [the official documentation](https://cloud.google.com/compute/docs/instance-groups/#unmanaged_instance_groups)
 * and [API](https://cloud.google.com/compute/docs/reference/latest/instanceGroups)
 * ## Example Usage
 * ### Empty Instance Group
 * 
 * ```typescript
 * 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,
 * });
 * ```
 * ```python
 * 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"])
 * ```
 * ```csharp
 * 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,
 *     });
 * });
 * ```
 * ```go
 * 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
 * 	})
 * }
 * ```
 * ```java
 * 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());
 *     }
 * }
 * ```
 * ```yaml
 * 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
 * 
 * ```typescript
 * 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",
 * });
 * ```
 * ```python
 * 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")
 * ```
 * ```csharp
 * 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",
 *     });
 * });
 * ```
 * ```go
 * 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
 * 	})
 * }
 * ```
 * ```java
 * 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());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   webservers:
 *     type: gcp:compute:InstanceGroup
 *     properties:
 *       name: webservers
 *       description: Test instance group
 *       instances:
 *         - ${test.id}
 *         - ${test2.id}
 *       namedPorts:
 *         - name: http
 *           port: '8080'
 *         - name: https
 *           port: '8443'
 *       zone: us-central1-a
 * ```
 * 
 * ## Import
 * Instance groups can be imported using the `zone` and `name` with an optional `project`, e.g.
 * * `projects/{{project_id}}/zones/{{zone}}/instanceGroups/{{instance_group_id}}`
 * * `{{project_id}}/{{zone}}/{{instance_group_id}}`
 * * `{{zone}}/{{instance_group_id}}`
 * When using the `pulumi import` command, instance groups can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:compute/instanceGroup:InstanceGroup default {{zone}}/{{instance_group_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/instanceGroup:InstanceGroup default {{project_id}}/{{zone}}/{{instance_group_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/instanceGroup:InstanceGroup default projects/{{project_id}}/zones/{{zone}}/instanceGroups/{{instance_group_id}}
 * ```
 * @property description An optional textual description of the instance
 * group.
 * @property instances 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.
 * @property name The name of the instance group. Must be 1-63
 * characters long and comply with
 * [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). Supported characters
 * include lowercase letters, numbers, and hyphens.
 * @property namedPorts The named port configuration. See the section below
 * for details on configuration. Structure is documented below.
 * @property network 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).
 * @property project The ID of the project in which the resource belongs. If it
 * is not provided, the provider project is used.
 * @property zone The zone that this instance group should be created in.
 * - - -
 */
public data class InstanceGroupArgs(
    public val description: Output? = null,
    public val instances: Output>? = null,
    public val name: Output? = null,
    public val namedPorts: Output>? = null,
    public val network: Output? = null,
    public val project: Output? = null,
    public val zone: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.gcp.compute.InstanceGroupArgs =
        com.pulumi.gcp.compute.InstanceGroupArgs.builder()
            .description(description?.applyValue({ args0 -> args0 }))
            .instances(instances?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
            .name(name?.applyValue({ args0 -> args0 }))
            .namedPorts(
                namedPorts?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .network(network?.applyValue({ args0 -> args0 }))
            .project(project?.applyValue({ args0 -> args0 }))
            .zone(zone?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [InstanceGroupArgs].
 */
@PulumiTagMarker
public class InstanceGroupArgsBuilder internal constructor() {
    private var description: Output? = null

    private var instances: Output>? = null

    private var name: Output? = null

    private var namedPorts: Output>? = null

    private var network: Output? = null

    private var project: Output? = null

    private var zone: Output? = null

    /**
     * @param value An optional textual description of the instance
     * group.
     */
    @JvmName("clngoapnilnrfffy")
    public suspend fun description(`value`: Output) {
        this.description = value
    }

    /**
     * @param value 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.
     */
    @JvmName("umhalxbcrroittcn")
    public suspend fun instances(`value`: Output>) {
        this.instances = value
    }

    @JvmName("jktnwiltnrkcvegy")
    public suspend fun instances(vararg values: Output) {
        this.instances = Output.all(values.asList())
    }

    /**
     * @param values 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.
     */
    @JvmName("gccjpecybpaqaswy")
    public suspend fun instances(values: List>) {
        this.instances = Output.all(values)
    }

    /**
     * @param value The name of the instance group. Must be 1-63
     * characters long and comply with
     * [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). Supported characters
     * include lowercase letters, numbers, and hyphens.
     */
    @JvmName("blcegbgepycimypv")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value The named port configuration. See the section below
     * for details on configuration. Structure is documented below.
     */
    @JvmName("thoxbjstyhmsedbq")
    public suspend fun namedPorts(`value`: Output>) {
        this.namedPorts = value
    }

    @JvmName("ksdkdwwpexeqrvkq")
    public suspend fun namedPorts(vararg values: Output) {
        this.namedPorts = Output.all(values.asList())
    }

    /**
     * @param values The named port configuration. See the section below
     * for details on configuration. Structure is documented below.
     */
    @JvmName("spfmufnsvfehhrwu")
    public suspend fun namedPorts(values: List>) {
        this.namedPorts = Output.all(values)
    }

    /**
     * @param value 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).
     */
    @JvmName("bhhtbhrgpoajqplj")
    public suspend fun network(`value`: Output) {
        this.network = value
    }

    /**
     * @param value The ID of the project in which the resource belongs. If it
     * is not provided, the provider project is used.
     */
    @JvmName("grhogdhwoxrfxttt")
    public suspend fun project(`value`: Output) {
        this.project = value
    }

    /**
     * @param value The zone that this instance group should be created in.
     * - - -
     */
    @JvmName("encqpabhfpvqtgdd")
    public suspend fun zone(`value`: Output) {
        this.zone = value
    }

    /**
     * @param value An optional textual description of the instance
     * group.
     */
    @JvmName("ydtwajmdydhiykmn")
    public suspend fun description(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.description = mapped
    }

    /**
     * @param value 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.
     */
    @JvmName("afaynvdgkgfvtmbu")
    public suspend fun instances(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.instances = mapped
    }

    /**
     * @param values 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.
     */
    @JvmName("rmdaofhsuhkcykwu")
    public suspend fun instances(vararg values: String) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.instances = mapped
    }

    /**
     * @param value The name of the instance group. Must be 1-63
     * characters long and comply with
     * [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). Supported characters
     * include lowercase letters, numbers, and hyphens.
     */
    @JvmName("eoevdawvhheosxgv")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value The named port configuration. See the section below
     * for details on configuration. Structure is documented below.
     */
    @JvmName("fvoqmyyakufxshem")
    public suspend fun namedPorts(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.namedPorts = mapped
    }

    /**
     * @param argument The named port configuration. See the section below
     * for details on configuration. Structure is documented below.
     */
    @JvmName("etgbqpkdkcliurjd")
    public suspend fun namedPorts(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            InstanceGroupNamedPortArgsBuilder().applySuspend {
                it()
            }.build()
        }
        val mapped = of(toBeMapped)
        this.namedPorts = mapped
    }

    /**
     * @param argument The named port configuration. See the section below
     * for details on configuration. Structure is documented below.
     */
    @JvmName("felmrkslqhcrwioh")
    public suspend fun namedPorts(vararg argument: suspend InstanceGroupNamedPortArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            InstanceGroupNamedPortArgsBuilder().applySuspend {
                it()
            }.build()
        }
        val mapped = of(toBeMapped)
        this.namedPorts = mapped
    }

    /**
     * @param argument The named port configuration. See the section below
     * for details on configuration. Structure is documented below.
     */
    @JvmName("uexdmodrpxlsmeos")
    public suspend fun namedPorts(argument: suspend InstanceGroupNamedPortArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(InstanceGroupNamedPortArgsBuilder().applySuspend { argument() }.build())
        val mapped = of(toBeMapped)
        this.namedPorts = mapped
    }

    /**
     * @param values The named port configuration. See the section below
     * for details on configuration. Structure is documented below.
     */
    @JvmName("qvfpuluomhcievyj")
    public suspend fun namedPorts(vararg values: InstanceGroupNamedPortArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.namedPorts = mapped
    }

    /**
     * @param value 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).
     */
    @JvmName("beulynrvynhxtjyk")
    public suspend fun network(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.network = mapped
    }

    /**
     * @param value The ID of the project in which the resource belongs. If it
     * is not provided, the provider project is used.
     */
    @JvmName("rkiiybbqhmodcpvs")
    public suspend fun project(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.project = mapped
    }

    /**
     * @param value The zone that this instance group should be created in.
     * - - -
     */
    @JvmName("lfylwnbkhfxcrppu")
    public suspend fun zone(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.zone = mapped
    }

    internal fun build(): InstanceGroupArgs = InstanceGroupArgs(
        description = description,
        instances = instances,
        name = name,
        namedPorts = namedPorts,
        network = network,
        project = project,
        zone = zone,
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy