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

com.pulumi.gcp.firebase.kotlin.DatabaseInstance.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.firebase.kotlin

import com.pulumi.core.Output
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

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

    public var args: DatabaseInstanceArgs = DatabaseInstanceArgs()

    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 DatabaseInstanceArgsBuilder.() -> Unit) {
        val builder = DatabaseInstanceArgsBuilder()
        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(): DatabaseInstance {
        val builtJavaResource = com.pulumi.gcp.firebase.DatabaseInstance(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return DatabaseInstance(builtJavaResource)
    }
}

/**
 * ## Example Usage
 * ### Firebase Database Instance Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const basic = new gcp.firebase.DatabaseInstance("basic", {
 *     project: "my-project-name",
 *     region: "us-central1",
 *     instanceId: "active-db",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * basic = gcp.firebase.DatabaseInstance("basic",
 *     project="my-project-name",
 *     region="us-central1",
 *     instance_id="active-db")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var basic = new Gcp.Firebase.DatabaseInstance("basic", new()
 *     {
 *         Project = "my-project-name",
 *         Region = "us-central1",
 *         InstanceId = "active-db",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firebase"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := firebase.NewDatabaseInstance(ctx, "basic", &firebase.DatabaseInstanceArgs{
 * 			Project:    pulumi.String("my-project-name"),
 * 			Region:     pulumi.String("us-central1"),
 * 			InstanceId: pulumi.String("active-db"),
 * 		})
 * 		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.firebase.DatabaseInstance;
 * import com.pulumi.gcp.firebase.DatabaseInstanceArgs;
 * 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 basic = new DatabaseInstance("basic", DatabaseInstanceArgs.builder()
 *             .project("my-project-name")
 *             .region("us-central1")
 *             .instanceId("active-db")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   basic:
 *     type: gcp:firebase:DatabaseInstance
 *     properties:
 *       project: my-project-name
 *       region: us-central1
 *       instanceId: active-db
 * ```
 * 
 * ### Firebase Database Instance Full
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const full = new gcp.firebase.DatabaseInstance("full", {
 *     project: "my-project-name",
 *     region: "europe-west1",
 *     instanceId: "disabled-db",
 *     type: "USER_DATABASE",
 *     desiredState: "DISABLED",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * full = gcp.firebase.DatabaseInstance("full",
 *     project="my-project-name",
 *     region="europe-west1",
 *     instance_id="disabled-db",
 *     type="USER_DATABASE",
 *     desired_state="DISABLED")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var full = new Gcp.Firebase.DatabaseInstance("full", new()
 *     {
 *         Project = "my-project-name",
 *         Region = "europe-west1",
 *         InstanceId = "disabled-db",
 *         Type = "USER_DATABASE",
 *         DesiredState = "DISABLED",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firebase"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := firebase.NewDatabaseInstance(ctx, "full", &firebase.DatabaseInstanceArgs{
 * 			Project:      pulumi.String("my-project-name"),
 * 			Region:       pulumi.String("europe-west1"),
 * 			InstanceId:   pulumi.String("disabled-db"),
 * 			Type:         pulumi.String("USER_DATABASE"),
 * 			DesiredState: pulumi.String("DISABLED"),
 * 		})
 * 		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.firebase.DatabaseInstance;
 * import com.pulumi.gcp.firebase.DatabaseInstanceArgs;
 * 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 full = new DatabaseInstance("full", DatabaseInstanceArgs.builder()
 *             .project("my-project-name")
 *             .region("europe-west1")
 *             .instanceId("disabled-db")
 *             .type("USER_DATABASE")
 *             .desiredState("DISABLED")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   full:
 *     type: gcp:firebase:DatabaseInstance
 *     properties:
 *       project: my-project-name
 *       region: europe-west1
 *       instanceId: disabled-db
 *       type: USER_DATABASE
 *       desiredState: DISABLED
 * ```
 * 
 * ### Firebase Database Instance Default Database
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const _default = new gcp.organizations.Project("default", {
 *     projectId: "rtdb-project",
 *     name: "rtdb-project",
 *     orgId: "123456789",
 *     labels: {
 *         firebase: "enabled",
 *     },
 * });
 * const defaultProject = new gcp.firebase.Project("default", {project: _default.projectId});
 * const firebaseDatabase = new gcp.projects.Service("firebase_database", {
 *     project: defaultProject.project,
 *     service: "firebasedatabase.googleapis.com",
 * });
 * const defaultDatabaseInstance = new gcp.firebase.DatabaseInstance("default", {
 *     project: defaultProject.project,
 *     region: "us-central1",
 *     instanceId: "rtdb-project-default-rtdb",
 *     type: "DEFAULT_DATABASE",
 * }, {
 *     dependsOn: [firebaseDatabase],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.organizations.Project("default",
 *     project_id="rtdb-project",
 *     name="rtdb-project",
 *     org_id="123456789",
 *     labels={
 *         "firebase": "enabled",
 *     })
 * default_project = gcp.firebase.Project("default", project=default.project_id)
 * firebase_database = gcp.projects.Service("firebase_database",
 *     project=default_project.project,
 *     service="firebasedatabase.googleapis.com")
 * default_database_instance = gcp.firebase.DatabaseInstance("default",
 *     project=default_project.project,
 *     region="us-central1",
 *     instance_id="rtdb-project-default-rtdb",
 *     type="DEFAULT_DATABASE",
 *     opts = pulumi.ResourceOptions(depends_on=[firebase_database]))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Gcp.Organizations.Project("default", new()
 *     {
 *         ProjectId = "rtdb-project",
 *         Name = "rtdb-project",
 *         OrgId = "123456789",
 *         Labels =
 *         {
 *             { "firebase", "enabled" },
 *         },
 *     });
 *     var defaultProject = new Gcp.Firebase.Project("default", new()
 *     {
 *         ProjectID = @default.ProjectId,
 *     });
 *     var firebaseDatabase = new Gcp.Projects.Service("firebase_database", new()
 *     {
 *         Project = defaultProject.ProjectID,
 *         ServiceName = "firebasedatabase.googleapis.com",
 *     });
 *     var defaultDatabaseInstance = new Gcp.Firebase.DatabaseInstance("default", new()
 *     {
 *         Project = defaultProject.ProjectID,
 *         Region = "us-central1",
 *         InstanceId = "rtdb-project-default-rtdb",
 *         Type = "DEFAULT_DATABASE",
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             firebaseDatabase,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firebase"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := organizations.NewProject(ctx, "default", &organizations.ProjectArgs{
 * 			ProjectId: pulumi.String("rtdb-project"),
 * 			Name:      pulumi.String("rtdb-project"),
 * 			OrgId:     pulumi.String("123456789"),
 * 			Labels: pulumi.StringMap{
 * 				"firebase": pulumi.String("enabled"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultProject, err := firebase.NewProject(ctx, "default", &firebase.ProjectArgs{
 * 			Project: _default.ProjectId,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		firebaseDatabase, err := projects.NewService(ctx, "firebase_database", &projects.ServiceArgs{
 * 			Project: defaultProject.Project,
 * 			Service: pulumi.String("firebasedatabase.googleapis.com"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = firebase.NewDatabaseInstance(ctx, "default", &firebase.DatabaseInstanceArgs{
 * 			Project:    defaultProject.Project,
 * 			Region:     pulumi.String("us-central1"),
 * 			InstanceId: pulumi.String("rtdb-project-default-rtdb"),
 * 			Type:       pulumi.String("DEFAULT_DATABASE"),
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			firebaseDatabase,
 * 		}))
 * 		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.organizations.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * import com.pulumi.gcp.firebase.Project;
 * import com.pulumi.gcp.firebase.ProjectArgs;
 * import com.pulumi.gcp.projects.Service;
 * import com.pulumi.gcp.projects.ServiceArgs;
 * import com.pulumi.gcp.firebase.DatabaseInstance;
 * import com.pulumi.gcp.firebase.DatabaseInstanceArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * 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 default_ = new Project("default", ProjectArgs.builder()
 *             .projectId("rtdb-project")
 *             .name("rtdb-project")
 *             .orgId("123456789")
 *             .labels(Map.of("firebase", "enabled"))
 *             .build());
 *         var defaultProject = new Project("defaultProject", ProjectArgs.builder()
 *             .project(default_.projectId())
 *             .build());
 *         var firebaseDatabase = new Service("firebaseDatabase", ServiceArgs.builder()
 *             .project(defaultProject.project())
 *             .service("firebasedatabase.googleapis.com")
 *             .build());
 *         var defaultDatabaseInstance = new DatabaseInstance("defaultDatabaseInstance", DatabaseInstanceArgs.builder()
 *             .project(defaultProject.project())
 *             .region("us-central1")
 *             .instanceId("rtdb-project-default-rtdb")
 *             .type("DEFAULT_DATABASE")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(firebaseDatabase)
 *                 .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: gcp:organizations:Project
 *     properties:
 *       projectId: rtdb-project
 *       name: rtdb-project
 *       orgId: '123456789'
 *       labels:
 *         firebase: enabled
 *   defaultProject:
 *     type: gcp:firebase:Project
 *     name: default
 *     properties:
 *       project: ${default.projectId}
 *   firebaseDatabase:
 *     type: gcp:projects:Service
 *     name: firebase_database
 *     properties:
 *       project: ${defaultProject.project}
 *       service: firebasedatabase.googleapis.com
 *   defaultDatabaseInstance:
 *     type: gcp:firebase:DatabaseInstance
 *     name: default
 *     properties:
 *       project: ${defaultProject.project}
 *       region: us-central1
 *       instanceId: rtdb-project-default-rtdb
 *       type: DEFAULT_DATABASE
 *     options:
 *       dependson:
 *         - ${firebaseDatabase}
 * ```
 * 
 * ## Import
 * Instance can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{region}}/instances/{{instance_id}}`
 * * `{{project}}/{{region}}/{{instance_id}}`
 * * `{{region}}/{{instance_id}}`
 * * `{{instance_id}}`
 * When using the `pulumi import` command, Instance can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:firebase/databaseInstance:DatabaseInstance default projects/{{project}}/locations/{{region}}/instances/{{instance_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:firebase/databaseInstance:DatabaseInstance default {{project}}/{{region}}/{{instance_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:firebase/databaseInstance:DatabaseInstance default {{region}}/{{instance_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:firebase/databaseInstance:DatabaseInstance default {{instance_id}}
 * ```
 */
public class DatabaseInstance internal constructor(
    override val javaResource: com.pulumi.gcp.firebase.DatabaseInstance,
) : KotlinCustomResource(javaResource, DatabaseInstanceMapper) {
    /**
     * The database URL in the form of https://{instance-id}.firebaseio.com for us-central1 instances
     * or https://{instance-id}.{region}.firebasedatabase.app in other regions.
     */
    public val databaseUrl: Output
        get() = javaResource.databaseUrl().applyValue({ args0 -> args0 })

    /**
     * The intended database state.
     */
    public val desiredState: Output?
        get() = javaResource.desiredState().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The globally unique identifier of the Firebase Realtime Database instance.
     * Instance IDs cannot be reused after deletion.
     * - - -
     */
    public val instanceId: Output
        get() = javaResource.instanceId().applyValue({ args0 -> args0 })

    /**
     * The fully-qualified resource name of the Firebase Realtime Database, in
     * the format: projects/PROJECT_NUMBER/locations/REGION_IDENTIFIER/instances/INSTANCE_ID
     * PROJECT_NUMBER: The Firebase project's [`ProjectNumber`](https://firebase.google.com/docs/reference/firebase-management/rest/v1beta1/projects#FirebaseProject.FIELDS.project_number)
     * Learn more about using project identifiers in Google's [AIP 2510 standard](https://google.aip.dev/cloud/2510).
     */
    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 })

    /**
     * A reference to the region where the Firebase Realtime database resides.
     * Check all [available regions](https://firebase.google.com/docs/projects/locations#rtdb-locations)
     */
    public val region: Output
        get() = javaResource.region().applyValue({ args0 -> args0 })

    /**
     * The current database state. Set desired_state to :DISABLED to disable the database and :ACTIVE to reenable the database
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })

    /**
     * The database type.
     * Each project can create one default Firebase Realtime Database, which cannot be deleted once created.
     * Creating user Databases is only available for projects on the Blaze plan.
     * Projects can be upgraded using the Cloud Billing API https://cloud.google.com/billing/reference/rest/v1/projects/updateBillingInfo.
     * Default value is `USER_DATABASE`.
     * Possible values are: `DEFAULT_DATABASE`, `USER_DATABASE`.
     */
    public val type: Output?
        get() = javaResource.type().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}

public object DatabaseInstanceMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.firebase.DatabaseInstance::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy