gcp logo
Google Cloud Classic v6.52.0, Mar 22 23

gcp.sql.getDatabases

Use this data source to get information about a list of databases 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.GetDatabases.Invoke(new()
    {
        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.GetDatabases(ctx, &sql.GetDatabasesArgs{
			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.GetDatabasesArgs;
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.getDatabases(GetDatabasesArgs.builder()
            .instance(google_sql_database_instance.main().name())
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

qa = gcp.sql.get_databases(instance=google_sql_database_instance["main"]["name"])
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const qa = gcp.sql.getDatabases({
    instance: google_sql_database_instance.main.name,
});
variables:
  qa:
    fn::invoke:
      Function: gcp:sql:getDatabases
      Arguments:
        instance: ${google_sql_database_instance.main.name}

Using getDatabases

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 getDatabases(args: GetDatabasesArgs, opts?: InvokeOptions): Promise<GetDatabasesResult>
function getDatabasesOutput(args: GetDatabasesOutputArgs, opts?: InvokeOptions): Output<GetDatabasesResult>
def get_databases(instance: Optional[str] = None,
                  project: Optional[str] = None,
                  opts: Optional[InvokeOptions] = None) -> GetDatabasesResult
def get_databases_output(instance: Optional[pulumi.Input[str]] = None,
                  project: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetDatabasesResult]
func GetDatabases(ctx *Context, args *GetDatabasesArgs, opts ...InvokeOption) (*GetDatabasesResult, error)
func GetDatabasesOutput(ctx *Context, args *GetDatabasesOutputArgs, opts ...InvokeOption) GetDatabasesResultOutput

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

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

The following arguments are supported:

Instance string

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

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.

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.

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.

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.

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.

project String

The ID of the project in which the instance belongs.

getDatabases Result

The following output properties are available:

Databases List<GetDatabasesDatabase>
Id string

The provider-assigned unique ID for this managed resource.

Instance string
Project string
Databases []GetDatabasesDatabase
Id string

The provider-assigned unique ID for this managed resource.

Instance string
Project string
databases List<GetDatabasesDatabase>
id String

The provider-assigned unique ID for this managed resource.

instance String
project String
databases GetDatabasesDatabase[]
id string

The provider-assigned unique ID for this managed resource.

instance string
project string
databases Sequence[GetDatabasesDatabase]
id str

The provider-assigned unique ID for this managed resource.

instance str
project str
databases List<Property Map>
id String

The provider-assigned unique ID for this managed resource.

instance String
project String

Supporting Types

GetDatabasesDatabase

Charset string
Collation string
DeletionPolicy string
Instance string

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

Name string
Project string

The ID of the project in which the instance belongs.

SelfLink string
Charset string
Collation string
DeletionPolicy string
Instance string

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

Name string
Project string

The ID of the project in which the instance belongs.

SelfLink string
charset String
collation String
deletionPolicy String
instance String

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

name String
project String

The ID of the project in which the instance belongs.

selfLink String
charset string
collation string
deletionPolicy string
instance string

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

name string
project string

The ID of the project in which the instance belongs.

selfLink string
charset str
collation str
deletion_policy str
instance str

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

name str
project str

The ID of the project in which the instance belongs.

self_link str
charset String
collation String
deletionPolicy String
instance String

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

name String
project String

The ID of the project in which the instance belongs.

selfLink 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.