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

com.pulumi.gcp.spanner.kotlin.Instance.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.spanner.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.spanner.kotlin.outputs.InstanceAutoscalingConfig
import com.pulumi.gcp.spanner.kotlin.outputs.InstanceAutoscalingConfig.Companion.toKotlin
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map

/**
 * Builder for [Instance].
 */
@PulumiTagMarker
public class InstanceResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: InstanceArgs = InstanceArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend InstanceArgsBuilder.() -> Unit) {
        val builder = InstanceArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): Instance {
        val builtJavaResource = com.pulumi.gcp.spanner.Instance(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Instance(builtJavaResource)
    }
}

/**
 * An isolated set of Cloud Spanner resources on which databases can be
 * hosted.
 * To get more information about Instance, see:
 * * [API documentation](https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/spanner/)
 * ## Example Usage
 * ### Spanner Instance Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const example = new gcp.spanner.Instance("example", {
 *     config: "regional-us-central1",
 *     displayName: "Test Spanner Instance",
 *     numNodes: 2,
 *     labels: {
 *         foo: "bar",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * example = gcp.spanner.Instance("example",
 *     config="regional-us-central1",
 *     display_name="Test Spanner Instance",
 *     num_nodes=2,
 *     labels={
 *         "foo": "bar",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Gcp.Spanner.Instance("example", new()
 *     {
 *         Config = "regional-us-central1",
 *         DisplayName = "Test Spanner Instance",
 *         NumNodes = 2,
 *         Labels =
 *         {
 *             { "foo", "bar" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/spanner"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := spanner.NewInstance(ctx, "example", &spanner.InstanceArgs{
 * 			Config:      pulumi.String("regional-us-central1"),
 * 			DisplayName: pulumi.String("Test Spanner Instance"),
 * 			NumNodes:    pulumi.Int(2),
 * 			Labels: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 		})
 * 		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.spanner.Instance;
 * import com.pulumi.gcp.spanner.InstanceArgs;
 * 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 example = new Instance("example", InstanceArgs.builder()
 *             .config("regional-us-central1")
 *             .displayName("Test Spanner Instance")
 *             .numNodes(2)
 *             .labels(Map.of("foo", "bar"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:spanner:Instance
 *     properties:
 *       config: regional-us-central1
 *       displayName: Test Spanner Instance
 *       numNodes: 2
 *       labels:
 *         foo: bar
 * ```
 * 
 * ### Spanner Instance Processing Units
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const example = new gcp.spanner.Instance("example", {
 *     config: "regional-us-central1",
 *     displayName: "Test Spanner Instance",
 *     processingUnits: 200,
 *     labels: {
 *         foo: "bar",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * example = gcp.spanner.Instance("example",
 *     config="regional-us-central1",
 *     display_name="Test Spanner Instance",
 *     processing_units=200,
 *     labels={
 *         "foo": "bar",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Gcp.Spanner.Instance("example", new()
 *     {
 *         Config = "regional-us-central1",
 *         DisplayName = "Test Spanner Instance",
 *         ProcessingUnits = 200,
 *         Labels =
 *         {
 *             { "foo", "bar" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/spanner"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := spanner.NewInstance(ctx, "example", &spanner.InstanceArgs{
 * 			Config:          pulumi.String("regional-us-central1"),
 * 			DisplayName:     pulumi.String("Test Spanner Instance"),
 * 			ProcessingUnits: pulumi.Int(200),
 * 			Labels: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 		})
 * 		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.spanner.Instance;
 * import com.pulumi.gcp.spanner.InstanceArgs;
 * 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 example = new Instance("example", InstanceArgs.builder()
 *             .config("regional-us-central1")
 *             .displayName("Test Spanner Instance")
 *             .processingUnits(200)
 *             .labels(Map.of("foo", "bar"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:spanner:Instance
 *     properties:
 *       config: regional-us-central1
 *       displayName: Test Spanner Instance
 *       processingUnits: 200
 *       labels:
 *         foo: bar
 * ```
 * 
 * ### Spanner Instance With Autoscaling
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const example = new gcp.spanner.Instance("example", {
 *     config: "regional-us-central1",
 *     displayName: "Test Spanner Instance",
 *     autoscalingConfig: {
 *         autoscalingLimits: {
 *             maxProcessingUnits: 3000,
 *             minProcessingUnits: 2000,
 *         },
 *         autoscalingTargets: {
 *             highPriorityCpuUtilizationPercent: 75,
 *             storageUtilizationPercent: 90,
 *         },
 *     },
 *     labels: {
 *         foo: "bar",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * example = gcp.spanner.Instance("example",
 *     config="regional-us-central1",
 *     display_name="Test Spanner Instance",
 *     autoscaling_config={
 *         "autoscaling_limits": {
 *             "max_processing_units": 3000,
 *             "min_processing_units": 2000,
 *         },
 *         "autoscaling_targets": {
 *             "high_priority_cpu_utilization_percent": 75,
 *             "storage_utilization_percent": 90,
 *         },
 *     },
 *     labels={
 *         "foo": "bar",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Gcp.Spanner.Instance("example", new()
 *     {
 *         Config = "regional-us-central1",
 *         DisplayName = "Test Spanner Instance",
 *         AutoscalingConfig = new Gcp.Spanner.Inputs.InstanceAutoscalingConfigArgs
 *         {
 *             AutoscalingLimits = new Gcp.Spanner.Inputs.InstanceAutoscalingConfigAutoscalingLimitsArgs
 *             {
 *                 MaxProcessingUnits = 3000,
 *                 MinProcessingUnits = 2000,
 *             },
 *             AutoscalingTargets = new Gcp.Spanner.Inputs.InstanceAutoscalingConfigAutoscalingTargetsArgs
 *             {
 *                 HighPriorityCpuUtilizationPercent = 75,
 *                 StorageUtilizationPercent = 90,
 *             },
 *         },
 *         Labels =
 *         {
 *             { "foo", "bar" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/spanner"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := spanner.NewInstance(ctx, "example", &spanner.InstanceArgs{
 * 			Config:      pulumi.String("regional-us-central1"),
 * 			DisplayName: pulumi.String("Test Spanner Instance"),
 * 			AutoscalingConfig: &spanner.InstanceAutoscalingConfigArgs{
 * 				AutoscalingLimits: &spanner.InstanceAutoscalingConfigAutoscalingLimitsArgs{
 * 					MaxProcessingUnits: pulumi.Int(3000),
 * 					MinProcessingUnits: pulumi.Int(2000),
 * 				},
 * 				AutoscalingTargets: &spanner.InstanceAutoscalingConfigAutoscalingTargetsArgs{
 * 					HighPriorityCpuUtilizationPercent: pulumi.Int(75),
 * 					StorageUtilizationPercent:         pulumi.Int(90),
 * 				},
 * 			},
 * 			Labels: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 		})
 * 		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.spanner.Instance;
 * import com.pulumi.gcp.spanner.InstanceArgs;
 * import com.pulumi.gcp.spanner.inputs.InstanceAutoscalingConfigArgs;
 * import com.pulumi.gcp.spanner.inputs.InstanceAutoscalingConfigAutoscalingLimitsArgs;
 * import com.pulumi.gcp.spanner.inputs.InstanceAutoscalingConfigAutoscalingTargetsArgs;
 * 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 example = new Instance("example", InstanceArgs.builder()
 *             .config("regional-us-central1")
 *             .displayName("Test Spanner Instance")
 *             .autoscalingConfig(InstanceAutoscalingConfigArgs.builder()
 *                 .autoscalingLimits(InstanceAutoscalingConfigAutoscalingLimitsArgs.builder()
 *                     .maxProcessingUnits(3000)
 *                     .minProcessingUnits(2000)
 *                     .build())
 *                 .autoscalingTargets(InstanceAutoscalingConfigAutoscalingTargetsArgs.builder()
 *                     .highPriorityCpuUtilizationPercent(75)
 *                     .storageUtilizationPercent(90)
 *                     .build())
 *                 .build())
 *             .labels(Map.of("foo", "bar"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:spanner:Instance
 *     properties:
 *       config: regional-us-central1
 *       displayName: Test Spanner Instance
 *       autoscalingConfig:
 *         autoscalingLimits:
 *           maxProcessingUnits: 3000
 *           minProcessingUnits: 2000
 *         autoscalingTargets:
 *           highPriorityCpuUtilizationPercent: 75
 *           storageUtilizationPercent: 90
 *       labels:
 *         foo: bar
 * ```
 * 
 * ### Spanner Instance Multi Regional
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const example = new gcp.spanner.Instance("example", {
 *     config: "nam-eur-asia1",
 *     displayName: "Multi Regional Instance",
 *     numNodes: 2,
 *     labels: {
 *         foo: "bar",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * example = gcp.spanner.Instance("example",
 *     config="nam-eur-asia1",
 *     display_name="Multi Regional Instance",
 *     num_nodes=2,
 *     labels={
 *         "foo": "bar",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Gcp.Spanner.Instance("example", new()
 *     {
 *         Config = "nam-eur-asia1",
 *         DisplayName = "Multi Regional Instance",
 *         NumNodes = 2,
 *         Labels =
 *         {
 *             { "foo", "bar" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/spanner"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := spanner.NewInstance(ctx, "example", &spanner.InstanceArgs{
 * 			Config:      pulumi.String("nam-eur-asia1"),
 * 			DisplayName: pulumi.String("Multi Regional Instance"),
 * 			NumNodes:    pulumi.Int(2),
 * 			Labels: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 		})
 * 		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.spanner.Instance;
 * import com.pulumi.gcp.spanner.InstanceArgs;
 * 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 example = new Instance("example", InstanceArgs.builder()
 *             .config("nam-eur-asia1")
 *             .displayName("Multi Regional Instance")
 *             .numNodes(2)
 *             .labels(Map.of("foo", "bar"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:spanner:Instance
 *     properties:
 *       config: nam-eur-asia1
 *       displayName: Multi Regional Instance
 *       numNodes: 2
 *       labels:
 *         foo: bar
 * ```
 * 
 * ## Import
 * Instance can be imported using any of these accepted formats:
 * * `projects/{{project}}/instances/{{name}}`
 * * `{{project}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Instance can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:spanner/instance:Instance default projects/{{project}}/instances/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:spanner/instance:Instance default {{project}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:spanner/instance:Instance default {{name}}
 * ```
 */
public class Instance internal constructor(
    override val javaResource: com.pulumi.gcp.spanner.Instance,
) : KotlinCustomResource(javaResource, InstanceMapper) {
    /**
     * The autoscaling configuration. Autoscaling is enabled if this field is set.
     * When autoscaling is enabled, num_nodes and processing_units are treated as,
     * OUTPUT_ONLY fields and reflect the current compute capacity allocated to
     * the instance.
     * Structure is documented below.
     */
    public val autoscalingConfig: Output?
        get() = javaResource.autoscalingConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> toKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The name of the instance's configuration (similar but not
     * quite the same as a region) which defines the geographic placement and
     * replication of your databases in this instance. It determines where your data
     * is stored. Values are typically of the form `regional-europe-west1` , `us-central` etc.
     * In order to obtain a valid list please consult the
     * [Configuration section of the docs](https://cloud.google.com/spanner/docs/instances).
     */
    public val config: Output
        get() = javaResource.config().applyValue({ args0 -> args0 })

    /**
     * The descriptive name for this instance as it appears in UIs. Must be
     * unique per project and between 4 and 30 characters in length.
     * - - -
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
     */
    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * When deleting a spanner instance, this boolean option will delete all backups of this instance.
     * This must be set to true if you created a backup manually in the console.
     */
    public val forceDestroy: Output?
        get() = javaResource.forceDestroy().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * An object containing a list of "key": value pairs.
     * Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
     * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
     * Please refer to the field `effective_labels` for all of the labels present on the resource.
     */
    public val labels: Output>?
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * A unique identifier for the instance, which cannot be changed after
     * the instance is created. The name must be between 6 and 30 characters
     * in length.
     * If not provided, a random string starting with `tf-` will be selected.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    public val numNodes: Output
        get() = javaResource.numNodes().applyValue({ args0 -> args0 })

    public val processingUnits: Output
        get() = javaResource.processingUnits().applyValue({ args0 -> args0 })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The combination of labels configured directly on the resource
     * and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Instance status: `CREATING` or `READY`.
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })
}

public object InstanceMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.spanner.Instance::class == javaResource::class

    override fun map(javaResource: Resource): Instance = Instance(
        javaResource as
            com.pulumi.gcp.spanner.Instance,
    )
}

/**
 * @see [Instance].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Instance].
 */
public suspend fun instance(name: String, block: suspend InstanceResourceBuilder.() -> Unit): Instance {
    val builder = InstanceResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Instance].
 * @param name The _unique_ name of the resulting resource.
 */
public fun instance(name: String): Instance {
    val builder = InstanceResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy