extend-nosql-database
The Extend NoSQL Database is currently in closed alpha.
Overview
Extend NoSQL Database allows Extend Apps to store data in an Amazon DocumentDB (with MongoDB compatibility) database. It provides a managed, scalable database solution that eliminates the complexity of setting up and maintaining your own database infrastructure. This allows developers to focus on building innovative features and functionality.
Extend NoSQL Database can be attached to all types of Extend Apps. This unlocks a wide range of use cases that require persistent data storage capabilities.
Provision Extend NoSQL Cluster
You can provision the Extend NoSQL cluster once you have been approved as a Closed Alpha tester. This action can be performed at the Publisher or Studio namespace level.
-
Go to the Development Utilities menu and click Extend Database Integration. Select the Extend NoSQL Database profile based on your needs, then click the Create NoSQL Database button.

-
Wait for the cluster to be provisioned for a few minutes.

-
The status changes to
AVAILABLEonce the cluster is provisioned.
-
To integrate your Extend App with the Extend NoSQL Database, proceed to the Setting up Extend NoSQL Database for your Extend App section.
Update Extend NoSQL Cluster Database Profile
You can update the database profile if you need to change the cluster size. This action can be performed at the Publisher or Studio namespace level.
-
In the Extend Database Integration menu, click the Edit button.

-
Select the Extend NoSQL Database profile based on your needs, then click the Update button.

-
In the confirmation dialog, type
UPDATEto confirm the update action and click the Update button.
-
Wait for the cluster to be updated.

-
The status changes back to
AVAILABLEonce the cluster is updated.
Delete Extend NoSQL Cluster
You can delete the cluster when you no longer need it, and it can only be deleted when it is in AVAILABLE status. This action can be performed at the Publisher or Studio namespace level.
-
In the Extend Database Integration menu, click the Delete Cluster button.

-
In the confirmation dialog, type
DELETEto confirm the deletion and click the Delete Instance button.
-
The page returns to the Extend Database Integration page once the cluster is deleted.
Setting up Extend NoSQL Database for your Extend App
This action can be performed at the Game namespace level, and you can only create the database when the NoSQL cluster is in AVAILABLE status.
-
In your Extend App details, switch to the NoSQL Database tab and click the Add NoSQL Database button.

-
Enter your database name and password, then click the Add button.

-
Take note of the information in the Database Summary page.

The database host, name, username, and password are automatically added to your Extend App secrets and variables as
DOCDB_HOST,DOCDB_DATABASE_NAME,DOCDB_USERNAME, andDOCDB_PASSWORD, respectively.
Connecting your Extend App to Extend NoSQL Database
-
Add MongoDB v2 driver to your Extend App.
- Go
Run the following
go getcommand to get the latest version of MongoDB driver.go get go.mongodb.org/mongo-driver/v2/mongoIt is recommended to run the
go mod tidycommand afterward.go mod tidy -
Configure the MongoDB v2 driver to connect to the NoSQL Database. Use the
DOCDB_HOST,DOCDB_USERNAME,DOCDB_PASSWORD, andDOCDB_CA_CERT_FILE_PATHenvironment variables to construct the connection string.- Go
import (
...
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
...
)
...
docdbHost := os.Getenv("DOCDB_HOST")
docdbUsername := os.Getenv("DOCDB_USERNAME")
docdbPassword := os.Getenv("DOCDB_PASSWORD")
docdbCaCertFilePath := os.Getenv("DOCDB_CA_CERT_FILE_PATH")
connectionString := fmt.Sprintf("mongodb://%s:%s@%s/?tls=true&tlsCAFile=%s", docdbUsername, docdbPassword, docdbHost, docdbCaCertFilePath)
client, err := mongo.Connect(options.Client().
ApplyURI(connectionString).
SetRetryWrites(false).
SetMinPoolSize(5).
SetMaxPoolSize(30))
...importantFor compatibility with Amazon DocumentDB,
SetRetryWritesmust be set tofalse.importantTLS is enabled by default on the cluster. The option
tlsmust be set totrue. The TLS certificate is automatically added and is exposed byDOCDB_CA_CERT_FILE_PATHenvironment variable. -
Connect to the MongoDB database and use it to insert, update, find, or delete documents. Use the
DOCDB_DATABASE_NAMEenvironment variable for the database name.- Go
...
docdbDatabaseName := os.Getenv("DOCDB_DATABASE_NAME")
database := client.Database(docdbDatabaseName)
...ヒントTo learn how to insert, update, find, or delete documents, see the MongoDB Go Driver tutorial.
Accessing the Extend NoSQL Database through Extend TCP Tunneling
You can connect to your Extend NoSQL Database from a local development environment using Extend TCP Tunneling via the Extend Helper CLI. You can only perform this action when the NoSQL cluster is in AVAILABLE status.
-
Make sure the Extend Helper CLI is set up. Then add the following permission to the IAM client you use with it.
- For AGS Private Cloud customers:
ADMIN:NAMESPACE:{namespace}:EXTEND:TUNNEL [READ]
- For AGS Shared Cloud customers:
- Extend > TCP Tunneling (Read)
- For AGS Private Cloud customers:
-
Copy the Resource Name information from the NoSQL Database tab.

-
Start Extend TCP Tunneling to the Extend NoSQL Database using Extend Helper CLI. Pass the
Resource Nameinformation from step 2 as the--resource-nameoption parameter.extend-helper-cli tunnel --resource-name <Resource Name> --namespace <namespace> --local-port <port>importantAuthentication may fail if your system clock is not synchronized. Ensure your local time is accurate before running the command.
ヒントYou can also copy the full command from the Tunnel Command information in the NoSQL Database tab.
-
Make sure you have downloaded the AWS DocumentDB TLS certificate from
https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem(TLS is enabled and requires the certificate to connect). -
Use your MongoDB client (such as MongoDB Compass, Studio 3T, or mongosh) to connect to the Extend NoSQL Database through the local port you specified in step 3. Use your database name, username, and password from the information you noted when setting up the database. The connection string should look like the following.
mongodb://<username>:<password>@localhost:<port>/<database-name>?serverSelectionTimeoutMS=10000&tls=true&tlsCAFile=<path-to-certs-file>&tlsAllowInvalidHostnames=trueimportantMake sure to include
serverSelectionTimeoutMS=10000option in the connection string. Otherwise, you may have trouble connecting. You may also try to use a bigger value than 10000 if you still have a problem connecting.The option
tlsAllowInvalidHostnames=trueis used to allow TLS connected via localhost.
Samples
The sample Extend App below is an Extend Service Extension guild service that stores its data in Extend NoSQL Database.
- Go
git clone https://github.com/AccelByte/extend-service-extension-with-mongodb-go.git
Observability
You can monitor your NoSQL cluster performance through a Grafana Cloud dashboard. The dashboard provides panels displaying key performance metrics including CPU utilization, latency, IOPS, database connections, etc., allowing you to identify bottlenecks and optimize your application's database usage.
-
In the NoSQL Database tab, click the Database Dashboard button.

-
A new tab opens with the Grafana Cloud login page. Log in with AccelByte credentials by clicking the Sign in with Admin Portal button.

-
Once you are logged in, you will see the dashboard.
