1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. firestore
  5. getDocument
Google Cloud v8.40.0 published on Monday, Aug 11, 2025 by Pulumi

gcp.firestore.getDocument

Explore with Pulumi AI

gcp logo
Google Cloud v8.40.0 published on Monday, Aug 11, 2025 by Pulumi

    Reads a document from a Firestore database. See the official documentation and API.

    Example Usage

    Retrieve a document from the Firestore database.

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const mydoc = new gcp.firestore.Document("mydoc", {
        project: database.project,
        database: database.name,
        collection: "somenewcollection",
        documentId: "my-doc-id",
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    mydoc = gcp.firestore.Document("mydoc",
        project=database["project"],
        database=database["name"],
        collection="somenewcollection",
        document_id="my-doc-id")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/firestore"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := firestore.NewDocument(ctx, "mydoc", &firestore.DocumentArgs{
    			Project:    pulumi.Any(database.Project),
    			Database:   pulumi.Any(database.Name),
    			Collection: pulumi.String("somenewcollection"),
    			DocumentId: pulumi.String("my-doc-id"),
    		})
    		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 mydoc = new Gcp.Firestore.Document("mydoc", new()
        {
            Project = database.Project,
            Database = database.Name,
            Collection = "somenewcollection",
            DocumentId = "my-doc-id",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.firestore.Document;
    import com.pulumi.gcp.firestore.DocumentArgs;
    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 mydoc = new Document("mydoc", DocumentArgs.builder()
                .project(database.project())
                .database(database.name())
                .collection("somenewcollection")
                .documentId("my-doc-id")
                .build());
    
        }
    }
    
    resources:
      mydoc:
        type: gcp:firestore:Document
        properties:
          project: ${database.project}
          database: ${database.name}
          collection: somenewcollection
          documentId: my-doc-id
    

    Using getDocument

    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 getDocument(args: GetDocumentArgs, opts?: InvokeOptions): Promise<GetDocumentResult>
    function getDocumentOutput(args: GetDocumentOutputArgs, opts?: InvokeOptions): Output<GetDocumentResult>
    def get_document(collection: Optional[str] = None,
                     database: Optional[str] = None,
                     document_id: Optional[str] = None,
                     project: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetDocumentResult
    def get_document_output(collection: Optional[pulumi.Input[str]] = None,
                     database: Optional[pulumi.Input[str]] = None,
                     document_id: Optional[pulumi.Input[str]] = None,
                     project: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetDocumentResult]
    func LookupDocument(ctx *Context, args *LookupDocumentArgs, opts ...InvokeOption) (*LookupDocumentResult, error)
    func LookupDocumentOutput(ctx *Context, args *LookupDocumentOutputArgs, opts ...InvokeOption) LookupDocumentResultOutput

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

    public static class GetDocument 
    {
        public static Task<GetDocumentResult> InvokeAsync(GetDocumentArgs args, InvokeOptions? opts = null)
        public static Output<GetDocumentResult> Invoke(GetDocumentInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetDocumentResult> getDocument(GetDocumentArgs args, InvokeOptions options)
    public static Output<GetDocumentResult> getDocument(GetDocumentArgs args, InvokeOptions options)
    
    fn::invoke:
      function: gcp:firestore/getDocument:getDocument
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Collection string
    The name of the collection of documents.
    Database string
    The name of the Firestore database.
    DocumentId string
    The id of the document to get.
    Project string
    The project in which the database resides.
    Collection string
    The name of the collection of documents.
    Database string
    The name of the Firestore database.
    DocumentId string
    The id of the document to get.
    Project string
    The project in which the database resides.
    collection String
    The name of the collection of documents.
    database String
    The name of the Firestore database.
    documentId String
    The id of the document to get.
    project String
    The project in which the database resides.
    collection string
    The name of the collection of documents.
    database string
    The name of the Firestore database.
    documentId string
    The id of the document to get.
    project string
    The project in which the database resides.
    collection str
    The name of the collection of documents.
    database str
    The name of the Firestore database.
    document_id str
    The id of the document to get.
    project str
    The project in which the database resides.
    collection String
    The name of the collection of documents.
    database String
    The name of the Firestore database.
    documentId String
    The id of the document to get.
    project String
    The project in which the database resides.

    getDocument Result

    The following output properties are available:

    Collection string
    CreateTime string
    Database string
    DocumentId string
    Fields string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Path string
    UpdateTime string
    Project string
    Collection string
    CreateTime string
    Database string
    DocumentId string
    Fields string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Path string
    UpdateTime string
    Project string
    collection String
    createTime String
    database String
    documentId String
    fields String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    path String
    updateTime String
    project String
    collection string
    createTime string
    database string
    documentId string
    fields string
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    path string
    updateTime string
    project string
    collection str
    create_time str
    database str
    document_id str
    fields str
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    path str
    update_time str
    project str
    collection String
    createTime String
    database String
    documentId String
    fields String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    path String
    updateTime 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 v8.40.0 published on Monday, Aug 11, 2025 by Pulumi