Document
In Cloud Firestore, the unit of storage is the document. A document is a lightweight record that contains fields, which map to values. Each document is identified by a name. To get more information about Document, see:
How-to Guides
Warning: This resource creates a Firestore Document on a project that already has Firestore enabled. If you haven't already enabled it, you can create a
gcp.appengine.Application
resource withdatabase_type
set to"CLOUD_FIRESTORE"
to do so. Your Firestore location will be the same as the App Engine location specified.
Example Usage
Firestore Document Basic
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()
.collection("somenewcollection")
.documentId("my-doc-%{random_suffix}")
.fields("{\"something\":{\"mapValue\":{\"fields\":{\"akey\":{\"stringValue\":\"avalue\"}}}}}")
.project("my-project-name")
.build());
}
}
Content copied to clipboard
Firestore Document Nested Document
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()
.collection("somenewcollection")
.documentId("my-doc-%{random_suffix}")
.fields("{\"something\":{\"mapValue\":{\"fields\":{\"akey\":{\"stringValue\":\"avalue\"}}}}}")
.project("my-project-name")
.build());
var subDocument = new Document("subDocument", DocumentArgs.builder()
.collection(mydoc.path().applyValue(path -> String.format("%s/subdocs", path)))
.documentId("bitcoinkey")
.fields("{\"something\":{\"mapValue\":{\"fields\":{\"ayo\":{\"stringValue\":\"val2\"}}}}}")
.project("my-project-name")
.build());
var subSubDocument = new Document("subSubDocument", DocumentArgs.builder()
.collection(subDocument.path().applyValue(path -> String.format("%s/subsubdocs", path)))
.documentId("asecret")
.fields("{\"something\":{\"mapValue\":{\"fields\":{\"secret\":{\"stringValue\":\"hithere\"}}}}}")
.project("my-project-name")
.build());
}
}
Content copied to clipboard
Import
Document can be imported using any of these accepted formats
$ pulumi import gcp:firestore/document:Document default {{name}}
Content copied to clipboard