Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.spanner.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.spanner.kotlin.outputs.DatabaseEncryptionConfig
import com.pulumi.gcp.spanner.kotlin.outputs.DatabaseEncryptionConfig.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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
/**
* Builder for [Database].
*/
@PulumiTagMarker
public class DatabaseResourceBuilder internal constructor() {
public var name: String? = null
public var args: DatabaseArgs = DatabaseArgs()
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 DatabaseArgsBuilder.() -> Unit) {
val builder = DatabaseArgsBuilder()
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(): Database {
val builtJavaResource = com.pulumi.gcp.spanner.Database(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Database(builtJavaResource)
}
}
/**
* A Cloud Spanner Database which is hosted on a Spanner instance.
* To get more information about Database, see:
* * [API documentation](https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/spanner/)
* > **Warning:** On newer versions of the provider, you must explicitly set `deletion_protection=false`
* (and run `pulumi up` to write the field to state) in order to destroy an instance.
* It is recommended to not set this field (or set it to true) until you're ready to destroy.
* On older versions, it is strongly recommended to set `lifecycle { prevent_destroy = true }`
* on databases in order to prevent accidental data loss.
* ## Example Usage
* ### Spanner Database Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const main = new gcp.spanner.Instance("main", {
* config: "regional-europe-west1",
* displayName: "main-instance",
* numNodes: 1,
* });
* const database = new gcp.spanner.Database("database", {
* instance: main.name,
* name: "my-database",
* versionRetentionPeriod: "3d",
* ddls: [
* "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
* "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
* ],
* deletionProtection: false,
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* main = gcp.spanner.Instance("main",
* config="regional-europe-west1",
* display_name="main-instance",
* num_nodes=1)
* database = gcp.spanner.Database("database",
* instance=main.name,
* name="my-database",
* version_retention_period="3d",
* ddls=[
* "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
* "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
* ],
* deletion_protection=False)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var main = new Gcp.Spanner.Instance("main", new()
* {
* Config = "regional-europe-west1",
* DisplayName = "main-instance",
* NumNodes = 1,
* });
* var database = new Gcp.Spanner.Database("database", new()
* {
* Instance = main.Name,
* Name = "my-database",
* VersionRetentionPeriod = "3d",
* Ddls = new[]
* {
* "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
* "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
* },
* DeletionProtection = false,
* });
* });
* ```
* ```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 {
* main, err := spanner.NewInstance(ctx, "main", &spanner.InstanceArgs{
* Config: pulumi.String("regional-europe-west1"),
* DisplayName: pulumi.String("main-instance"),
* NumNodes: pulumi.Int(1),
* })
* if err != nil {
* return err
* }
* _, err = spanner.NewDatabase(ctx, "database", &spanner.DatabaseArgs{
* Instance: main.Name,
* Name: pulumi.String("my-database"),
* VersionRetentionPeriod: pulumi.String("3d"),
* Ddls: pulumi.StringArray{
* pulumi.String("CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)"),
* pulumi.String("CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)"),
* },
* DeletionProtection: pulumi.Bool(false),
* })
* 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.Database;
* import com.pulumi.gcp.spanner.DatabaseArgs;
* 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 main = new Instance("main", InstanceArgs.builder()
* .config("regional-europe-west1")
* .displayName("main-instance")
* .numNodes(1)
* .build());
* var database = new Database("database", DatabaseArgs.builder()
* .instance(main.name())
* .name("my-database")
* .versionRetentionPeriod("3d")
* .ddls(
* "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
* "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)")
* .deletionProtection(false)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* main:
* type: gcp:spanner:Instance
* properties:
* config: regional-europe-west1
* displayName: main-instance
* numNodes: 1
* database:
* type: gcp:spanner:Database
* properties:
* instance: ${main.name}
* name: my-database
* versionRetentionPeriod: 3d
* ddls:
* - CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)
* - CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)
* deletionProtection: false
* ```
*
* ## Import
* Database can be imported using any of these accepted formats:
* * `projects/{{project}}/instances/{{instance}}/databases/{{name}}`
* * `instances/{{instance}}/databases/{{name}}`
* * `{{project}}/{{instance}}/{{name}}`
* * `{{instance}}/{{name}}`
* When using the `pulumi import` command, Database can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:spanner/database:Database default projects/{{project}}/instances/{{instance}}/databases/{{name}}
* ```
* ```sh
* $ pulumi import gcp:spanner/database:Database default instances/{{instance}}/databases/{{name}}
* ```
* ```sh
* $ pulumi import gcp:spanner/database:Database default {{project}}/{{instance}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:spanner/database:Database default {{instance}}/{{name}}
* ```
*/
public class Database internal constructor(
override val javaResource: com.pulumi.gcp.spanner.Database,
) : KotlinCustomResource(javaResource, DatabaseMapper) {
/**
* The dialect of the Cloud Spanner Database.
* If it is not provided, "GOOGLE_STANDARD_SQL" will be used.
* Possible values are: `GOOGLE_STANDARD_SQL`, `POSTGRESQL`.
*/
public val databaseDialect: Output
get() = javaResource.databaseDialect().applyValue({ args0 -> args0 })
/**
* An optional list of DDL statements to run inside the newly created
* database. Statements can create tables, indexes, etc. These statements
* execute atomically with the creation of the database: if there is an
* error in any statement, the database is not created.
*/
public val ddls: Output>?
get() = javaResource.ddls().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0
})
}).orElse(null)
})
/**
* Whether or not to allow the provider to destroy the instance. Unless this field is set to false
* in state, a `destroy` or `update` that would delete the instance will fail.
*/
public val deletionProtection: Output?
get() = javaResource.deletionProtection().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
public val enableDropProtection: Output?
get() = javaResource.enableDropProtection().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Encryption configuration for the database
* Structure is documented below.
*/
public val encryptionConfig: Output?
get() = javaResource.encryptionConfig().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> toKotlin(args0) })
}).orElse(null)
})
/**
* The instance to create the database on.
* - - -
*/
public val instance: Output
get() = javaResource.instance().applyValue({ args0 -> args0 })
/**
* A unique identifier for the database, which cannot be changed after
* the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
*/
public val name: Output
get() = javaResource.name().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 })
/**
* An explanation of the status of the database.
*/
public val state: Output
get() = javaResource.state().applyValue({ args0 -> args0 })
/**
* The retention period for the database. The retention period must be between 1 hour
* and 7 days, and can be specified in days, hours, minutes, or seconds. For example,
* the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h.
* If this property is used, you must avoid adding new DDL statements to `ddl` that
* update the database's version_retention_period.
*/
public val versionRetentionPeriod: Output
get() = javaResource.versionRetentionPeriod().applyValue({ args0 -> args0 })
}
public object DatabaseMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.spanner.Database::class == javaResource::class
override fun map(javaResource: Resource): Database = Database(
javaResource as
com.pulumi.gcp.spanner.Database,
)
}
/**
* @see [Database].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Database].
*/
public suspend fun database(name: String, block: suspend DatabaseResourceBuilder.() -> Unit): Database {
val builder = DatabaseResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Database].
* @param name The _unique_ name of the resulting resource.
*/
public fun database(name: String): Database {
val builder = DatabaseResourceBuilder()
builder.name(name)
return builder.build()
}