1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. sql
  5. getDatabases
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

gcp.sql.getDatabases

Explore with Pulumi AI

gcp logo
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

    Use this data source to get information about a list of databases in a Cloud SQL instance.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const qa = gcp.sql.getDatabases({
        instance: main.name,
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    qa = gcp.sql.get_databases(instance=main["name"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v8/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: main.Name,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var qa = Gcp.Sql.GetDatabases.Invoke(new()
        {
            Instance = main.Name,
        });
    
    });
    
    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(main.name())
                .build());
    
        }
    }
    
    variables:
      qa:
        fn::invoke:
          Function: gcp:sql:getDatabases
          Arguments:
            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.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    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.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    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.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    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.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    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.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    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.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    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
    The charset value. See MySQL's Supported Character Sets and Collations and Postgres' Character Set Support for more details and supported values. Postgres databases only support a value of 'UTF8' at creation time.
    Collation string
    The collation value. See MySQL's Supported Character Sets and Collations and Postgres' Collation Support for more details and supported values. Postgres databases only support a value of 'en_US.UTF8' at creation time.
    DeletionPolicy string
    The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible values are: "ABANDON", "DELETE". Defaults to "DELETE".
    Instance string
    The name of the Cloud SQL database instance in which the database belongs.
    Name string
    The name of the database in the Cloud SQL instance. This does not include the project ID or instance name.
    Project string

    The ID of the project in which the instance belongs.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    SelfLink string
    Charset string
    The charset value. See MySQL's Supported Character Sets and Collations and Postgres' Character Set Support for more details and supported values. Postgres databases only support a value of 'UTF8' at creation time.
    Collation string
    The collation value. See MySQL's Supported Character Sets and Collations and Postgres' Collation Support for more details and supported values. Postgres databases only support a value of 'en_US.UTF8' at creation time.
    DeletionPolicy string
    The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible values are: "ABANDON", "DELETE". Defaults to "DELETE".
    Instance string
    The name of the Cloud SQL database instance in which the database belongs.
    Name string
    The name of the database in the Cloud SQL instance. This does not include the project ID or instance name.
    Project string

    The ID of the project in which the instance belongs.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    SelfLink string
    charset String
    The charset value. See MySQL's Supported Character Sets and Collations and Postgres' Character Set Support for more details and supported values. Postgres databases only support a value of 'UTF8' at creation time.
    collation String
    The collation value. See MySQL's Supported Character Sets and Collations and Postgres' Collation Support for more details and supported values. Postgres databases only support a value of 'en_US.UTF8' at creation time.
    deletionPolicy String
    The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible values are: "ABANDON", "DELETE". Defaults to "DELETE".
    instance String
    The name of the Cloud SQL database instance in which the database belongs.
    name String
    The name of the database in the Cloud SQL instance. This does not include the project ID or instance name.
    project String

    The ID of the project in which the instance belongs.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    selfLink String
    charset string
    The charset value. See MySQL's Supported Character Sets and Collations and Postgres' Character Set Support for more details and supported values. Postgres databases only support a value of 'UTF8' at creation time.
    collation string
    The collation value. See MySQL's Supported Character Sets and Collations and Postgres' Collation Support for more details and supported values. Postgres databases only support a value of 'en_US.UTF8' at creation time.
    deletionPolicy string
    The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible values are: "ABANDON", "DELETE". Defaults to "DELETE".
    instance string
    The name of the Cloud SQL database instance in which the database belongs.
    name string
    The name of the database in the Cloud SQL instance. This does not include the project ID or instance name.
    project string

    The ID of the project in which the instance belongs.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    selfLink string
    charset str
    The charset value. See MySQL's Supported Character Sets and Collations and Postgres' Character Set Support for more details and supported values. Postgres databases only support a value of 'UTF8' at creation time.
    collation str
    The collation value. See MySQL's Supported Character Sets and Collations and Postgres' Collation Support for more details and supported values. Postgres databases only support a value of 'en_US.UTF8' at creation time.
    deletion_policy str
    The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible values are: "ABANDON", "DELETE". Defaults to "DELETE".
    instance str
    The name of the Cloud SQL database instance in which the database belongs.
    name str
    The name of the database in the Cloud SQL instance. This does not include the project ID or instance name.
    project str

    The ID of the project in which the instance belongs.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    self_link str
    charset String
    The charset value. See MySQL's Supported Character Sets and Collations and Postgres' Character Set Support for more details and supported values. Postgres databases only support a value of 'UTF8' at creation time.
    collation String
    The collation value. See MySQL's Supported Character Sets and Collations and Postgres' Collation Support for more details and supported values. Postgres databases only support a value of 'en_US.UTF8' at creation time.
    deletionPolicy String
    The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible values are: "ABANDON", "DELETE". Defaults to "DELETE".
    instance String
    The name of the Cloud SQL database instance in which the database belongs.
    name String
    The name of the database in the Cloud SQL instance. This does not include the project ID or instance name.
    project String

    The ID of the project in which the instance belongs.

    Note This datasource performs client-side sorting to provide consistent ordering of the databases.

    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.
    gcp logo
    Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi