gcp logo
Google Cloud Classic v6.49.0, Feb 1 23

gcp.sql.getDatabase

Use this data source to get information about a database in a Cloud SQL instance.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var qa = Gcp.Sql.GetDatabase.Invoke(new()
    {
        Name = "test-sql-database",
        Instance = google_sql_database_instance.Main.Name,
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/sql"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := sql.LookupDatabase(ctx, &sql.LookupDatabaseArgs{
			Name:     "test-sql-database",
			Instance: google_sql_database_instance.Main.Name,
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.sql.SqlFunctions;
import com.pulumi.gcp.sql.inputs.GetDatabaseArgs;
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 qa = SqlFunctions.getDatabase(GetDatabaseArgs.builder()
            .name("test-sql-database")
            .instance(google_sql_database_instance.main().name())
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

qa = gcp.sql.get_database(name="test-sql-database",
    instance=google_sql_database_instance["main"]["name"])
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const qa = gcp.sql.getDatabase({
    name: "test-sql-database",
    instance: google_sql_database_instance.main.name,
});
variables:
  qa:
    fn::invoke:
      Function: gcp:sql:getDatabase
      Arguments:
        name: test-sql-database
        instance: ${google_sql_database_instance.main.name}

Using getDatabase

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getDatabase(args: GetDatabaseArgs, opts?: InvokeOptions): Promise<GetDatabaseResult>
function getDatabaseOutput(args: GetDatabaseOutputArgs, opts?: InvokeOptions): Output<GetDatabaseResult>
def get_database(instance: Optional[str] = None,
                 name: Optional[str] = None,
                 project: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetDatabaseResult
def get_database_output(instance: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 project: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetDatabaseResult]
func LookupDatabase(ctx *Context, args *LookupDatabaseArgs, opts ...InvokeOption) (*LookupDatabaseResult, error)
func LookupDatabaseOutput(ctx *Context, args *LookupDatabaseOutputArgs, opts ...InvokeOption) LookupDatabaseResultOutput

> Note: This function is named LookupDatabase in the Go SDK.

public static class GetDatabase 
{
    public static Task<GetDatabaseResult> InvokeAsync(GetDatabaseArgs args, InvokeOptions? opts = null)
    public static Output<GetDatabaseResult> Invoke(GetDatabaseInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetDatabaseResult> getDatabase(GetDatabaseArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: gcp:sql/getDatabase:getDatabase
  arguments:
    # arguments dictionary

The following arguments are supported:

Instance string

The name of the Cloud SQL database instance in which the database belongs.

Name string

The name of the database.

Project string

The ID of the project in which the instance belongs.

Instance string

The name of the Cloud SQL database instance in which the database belongs.

Name string

The name of the database.

Project string

The ID of the project in which the instance belongs.

instance String

The name of the Cloud SQL database instance in which the database belongs.

name String

The name of the database.

project String

The ID of the project in which the instance belongs.

instance string

The name of the Cloud SQL database instance in which the database belongs.

name string

The name of the database.

project string

The ID of the project in which the instance belongs.

instance str

The name of the Cloud SQL database instance in which the database belongs.

name str

The name of the database.

project str

The ID of the project in which the instance belongs.

instance String

The name of the Cloud SQL database instance in which the database belongs.

name String

The name of the database.

project String

The ID of the project in which the instance belongs.

getDatabase Result

The following output properties are available:

Charset string
Collation string
DeletionPolicy string
Id string

The provider-assigned unique ID for this managed resource.

Instance string
Name string
SelfLink string
Project string
Charset string
Collation string
DeletionPolicy string
Id string

The provider-assigned unique ID for this managed resource.

Instance string
Name string
SelfLink string
Project string
charset String
collation String
deletionPolicy String
id String

The provider-assigned unique ID for this managed resource.

instance String
name String
selfLink String
project String
charset string
collation string
deletionPolicy string
id string

The provider-assigned unique ID for this managed resource.

instance string
name string
selfLink string
project string
charset str
collation str
deletion_policy str
id str

The provider-assigned unique ID for this managed resource.

instance str
name str
self_link str
project str
charset String
collation String
deletionPolicy String
id String

The provider-assigned unique ID for this managed resource.

instance String
name String
selfLink String
project String

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.