Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC-322: Deployment guide for Surreal Cloud #1101

Merged
merged 8 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/content/doc-surrealdb/deployment/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import LightGoogle from "@img/icon/light/google.png";
import LightAmazon from "@img/icon/light/amazon.png";
import LightAzure from "@img/icon/light/azure.png";

import LightCloud from '@img/image/cloud/surrealcloud.png';
import DarkCloud from '@img/image/cloud/surrealcloud.png';

import DarkFly from "@img/icon/dark/fly.png";
import DarkHeroku from "@img/icon/dark/heroku.png";
import DarkRailway from "@img/icon/dark/railway.png";
Expand All @@ -34,6 +37,16 @@ Getting started with SurrealDB is intended to be quick and easy. All of SurrealD
## Single-node instance

<Boxes>
<IconBox
title="Surreal Cloud"
description="Learn how to deploy a single-node instance of SurrealDB on Surreal Cloud."
href="/docs/surrealdb/deployment/surreal-cloud"
status="available"
icon={{
light: LightCloud,
dark: DarkCloud,
}}
/>
<IconBox
title="Fly.io"
description="Learn how to deploy a single-node instance of SurrealDB on Fly."
Expand Down
169 changes: 169 additions & 0 deletions src/content/doc-surrealdb/deployment/surreal cloud.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
sidebar_position: 1
sidebar_label: Deploy on Surreal Cloud (Beta)
title: Deploy on Surreal Cloud (Beta) | Deployment
description: This tutorial provides a guide to the process of deploying SurrealDB using Surreal Cloud.
---

import Image from "@components/Image.astro";

import NamespaceDatabaseLight from '@img/image/cloud/namespace-database.png';
import NamespaceDatabaseDark from '@img/image/cloud/namespace-database.png';

import LightCloud from '@img/image/cloud/surrealcloud.png';
import DarkCloud from '@img/image/cloud/surrealcloud.png';

import OpenInSDK from '@img/image/cloud/open-in-sdk.png';

import QueryingInstanceLight from '@img/image/cloud/querying-instance.png';
import QueryingInstanceDark from '@img/image/cloud/querying-instance.png';

import OpenInHTTPCurlLight from '@img/image/cloud/open-in-http.png';
import OpenInHTTPCurlDark from '@img/image/cloud/open-in-http.png';

<Image
alt="Surreal Cloud (Beta)"
width={100}
className="flag-image-title"
src={{
light: LightCloud,
dark: DarkCloud,
}}
/>
# Deploy on Surreal Cloud (Beta)

## What is Surreal Cloud (Beta)?

Surreal Cloud is a fully managed database service that provides a seamless deployment experience for SurrealDB. It's designed to be lightweight, leveraging the open-Source SurrealDB product as much as possible. Its features are intended to complement those of the open-source version and offer you a seamless deployment experience.
Dhghomon marked this conversation as resolved.
Show resolved Hide resolved

In this guide, we'll walk through the process and options to deploy SurrealDB using [Surreal Cloud](/docs/cloud).

## Requirements

To get [started with Surreal Cloud](/docs/cloud/getting-started), you'll need to have an account. If you don't have one, you can sign up for a free account by [downloading Surrealist](https://github.com/surrealdb/surrealist/releases) or using the [Surrealist web app](https://surrealist.app/cloud).
Ekwuno marked this conversation as resolved.
Show resolved Hide resolved


## Create an Instance

To create an Instance, in Surrealist, click on the **Surreal Cloud** tab and select **Continue**. This will prompt you to the authentication page. If you don't have an account, you'll be asked to [sign up](/docs/cloud/getting-started/create-an-account) with an email address, Google, or GitHub.
Ekwuno marked this conversation as resolved.
Show resolved Hide resolved

After you've signed up, you'll be redirected to the Surreal Cloud dashboard. Here, you can create an Instance by clicking on the **Create Instance** button.

### Configure your Instance

While creating an Instance, you'll be asked to provide a few details about your Instance. These include:

- **Instance Name**: This is the name of your Instance. It's used to identify your Instance in the Surreal Cloud dashboard.
- **SurrealDB Version**: This is the version of SurrealDB that you want to use. You can choose the version that best fits your needs.
- **Instance Region**: This is the region where your Instance will be deployed. You can choose the region that's closest to you for better performance through a lower two-way trip time.
- **Instance Size**: This is the size of your Instance. You can choose the size that best fits your needs. For free Instances, this is set to **0.25 vCPU and 512.00MB** of memory on a single node.
- **Instance category**: This is the category of your Instance. You can choose the category that best fits your needs.
- **Production**: This is the default category. It's designed for high-performance and high-availability use cases.
- **Development**: This is a lower-cost category. It's designed for development and testing purposes.
- **Free**: This is a free category. It's designed for learning and experimenting purposes.

> [!NOTE]
> Both Production and Development categories are paid plans and allows you to further customize your Instance vCPU and memory. To use them, you'll need to upgrade to a paid plan by adding billing information. In this guide, we'll be using the free category which has a **0.25 vCPU and 512.00MB** of memory on a single node.

After you've provided the required information, click on the **Create** button. This will start the Instance provisioning process.

## Query your Instance

### Query via Surrealist

You can connect to your Instance using [Surrealist, the SurrealDB CLI, or the SurrealDB SDKs](/docs/cloud#what-can-you-do). In this guide, we'll be using Surrealist as our client.

In the connect dropdown, select the **Open in Surrealist** option. This will open the [query view](/docs/surrealist/concepts/sending-queries) in Surrealist. Before you can start querying your Instance, you'll need to create a namespace and a database.

To create a namespace, click on the **Create Namespace** button. This will open a modal to input the name of the namespace. Once you've input the name, click on the **Create** button.

<Image
alt="Namespace and Database"
src={{
light: NamespaceDatabaseLight,
dark: NamespaceDatabaseDark,
}}
/>

> [!IMPORTANT]
> A namespace is a container for databases like an organization or folder. It's used to organize your databases, so you can create multiple databases within a single namespace.

To create a database, click on the **Create Database** button. This will open a modal to input the name of the database. Once you've input the name, click on the **Create** button. This will create the database.
Ekwuno marked this conversation as resolved.
Show resolved Hide resolved

> [!IMPORTANT]
> A database is a collection of data. It's used to store your data and provide a way to manage access control.
Ekwuno marked this conversation as resolved.
Show resolved Hide resolved


After you've created a namespace and a database, you can start querying your Instance.

<Image
alt="Querying Instance"
src={{
light: QueryingInstanceLight,
dark: QueryingInstanceDark,
}}
/>


## Additional Querying Options

You can also query your Instance using the SurrealDB CLI and the SurrealDB SDKs. They work similarly by providing a connection string to your Instance. The only difference is that with the CLI, you'll be provided an authentication token to use with your Instance.

With the SDKs, you'll use the `connect` method to connect to your Instance and then provide the namespace and database you want to work in. Lets take a look at some examples of how these work.


### Connect via CLI

In your Instances dashboard, you'll see a **Connect** button, select the **Connect via CLI** option. This will provide you with a connection string to your Instance. You can then copy the connection string and use it to connect to your Instance using the SurrealDB CLI.

> [!IMPORTANT]
> To connect via CLI, you'll need to have the SurrealDB CLI installed. You can install the CLI by following the instructions [in the installation guide](/docs/surrealdb/cli).

Open your terminal and run the following command:

```bash title="Connect via CLI example"
surreal sql --endpoint wss://deploy-to-surre-06a3n6cirprtjdn3gj0np4l9kg.aws-use1.surreal.cloud --token eyJhbGciOiJQUzI1NiIsImtpZCI6IjFkNmViYjAyLWM5ZjEtNDg4Zi1iNjhjLWNlMzMzMzU4YzgyOCIsInR5cCI6IkpXVCJ9.eyJhYyI6ImNsb3VkIiwiYXVkIjoiMDZhM242Y2lycHJ0amRuM2dqMG5wNGw5a2ciLCJleHAiOjE3MzYxNzg5ODEsImlhdCI6MTczNjE3ODkyMSwicmwiOlsiT3duZXIiXX0.Lr2J7psiQc5d8X95IPYjsmkKdENB1jyKPi-PHvoBotD4EXPROuGYhnk8zquEHY10lRNUSMZEF-RDsPBmhV3cPSyUnu5nVMJgD9ii82uieXa3T4DpPfbba6LA2gnqQpqkCFBsLrn1oOU4PdcaimzzSALV-JSAfs2yqkeN0rpi6BnIsX5Xj6MWIXOWtyGW9sVXcKdTjCzo7FVm7sBABPVLqqeDo6xJwyYeEYTwHZo9PmieQnQkgPqz5d4eGIUqjKsY7CU-49Jjs8Mix7QsMCRrW7FrnDOf9D0ZjdNUTfLppipa8DussMWQWHEDkvVthxjViva0lqiXors9B792RIocog
```
This will connect you to your Instance and you can start writing queries to your Instance.

### Connect via SDKs

In addition to the first two methods, you can also connect to your Instance using the SurrealDB SDKs. The SurrealDB SDKs are available for a variety of languages, including [JavaScript / TypeScript](/docs/sdk/javascript), [Python](/docs/sdk/python), [Rust](/docs/sdk/rust), [Go](/docs/sdk/golang), and [Java](/docs/sdk/java).

To use this method, you'll need to have the SurrealDB SDK for your language installed. Once you've installed the SDK, you can use the `connect` method to connect to your Instance.

From the Surreal Cloud dashboard, you'll see a **Connect** button, select the **Connect via SDK** option. This will provide you modal to carry out the following steps:

1. Select the language of the SDK you want to use.
2. Specify the Namespace and Database to connect to.
3. Add authentication details for your Instance.
4. Copy the code snippet to your project.

<Image
alt="Open in SDK"
src={{
light: OpenInSDK,
dark: OpenInSDK,
}}
/>

Once you've completed these steps, you can use the SDK to connect to your Instance and start querying your Instance.

### Connect via HTTP

You can also connect to your Instance using the HTTP API. This allows you to connect to your Instance using any HTTP client. To get started, select the **Connect** button on your Instance. Then select **HTTP cURL**.

This will open a modal to fill in your credentials for **Namespace** and **Database** and authentication before you can copy the URL.

<Image
alt="Open in HTTP cURL"
src={{
light: OpenInHTTPCurlLight,
dark: OpenInHTTPCurlDark,
}}
/>

## Conclusion

In this guide, we've shown you how to deploy SurrealDB using Surreal Cloud (beta). We've also shown you how to query your Instance using Surrealist, the SurrealDB CLI, and the SurrealDB SDKs. For more information on Surreal Cloud, you can visit the [Surreal Cloud documentation](/docs/cloud).

Loading