1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. sql
  5. getDatabase
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

gcp.sql.getDatabase

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

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

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const qa = gcp.sql.getDatabase({
        name: "test-sql-database",
        instance: main.name,
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    qa = gcp.sql.get_database(name="test-sql-database",
        instance=main["name"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/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: 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.GetDatabase.Invoke(new()
        {
            Name = "test-sql-database",
            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.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(main.name())
                .build());
    
        }
    }
    
    variables:
      qa:
        fn::invoke:
          Function: gcp:sql:getDatabase
          Arguments:
            name: test-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.
    gcp logo
    Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi