Navigation

createStore

The createStore command creates a store in the Atlas Data Lake storage configuration. Click on the tab below to learn more about creating a data store for the data source.

This tab contains the syntax and parameters for creating a data store for data in AWS S3 bucket.

This tab contains the syntax and parameters for creating a data store for data in an Atlas cluster.

Syntax

db.runCommand({ createStore: <store-name>, provider: <storage-provider>, region: <region-name>, bucket: <bucket-name>, delimiter: <delimiter>, prefix: <prefix> })
db.runCommand({ createStore: <store-name>, provider: <storage-provider>, clusterName: <cluster-name>, projectId: <project-id>  })

Parameters

ParameterTypeDescriptionRequired?
createStorestringName of the new data store. The data store name must be unique.yes
providerstring

Name of the service where the data is stored. Value can be one of the following:

  • s3 for an AWS S3 bucket.
  • atlas for Atlas.
yes
regionstringRegion in which the bucket is hosted. For a list of valid region names, see Amazon Web Services (AWS).yes
bucketstringName of the bucket in which data is stored. Must exactly match the name of an S3 bucket which Data Lake can access given the configured AWS IAM credentials.yes
delimiterstringCharacter used to separate path segments in the data store. If ommitted, defaults to "/".no
prefixstringValue prepended to the path. If ommitted, defaults to "".no
clusterNamestringName of the Atlas cluster on which the store is based.yes
projectIdstringUnique identifier of the project that contains the Atlas cluster.yes

Output

The command prints the following output if it succeeds. If the command fails, see Troubleshoot Errors for recommended solutions.

{
  "ok": 1,
  "store": {
    "name": "<store-name>",
    "region": "<region-name>",
    "bucket": "<bucket-name>",
    "delimiter": "<delimiter>",
    "prefix": "<prefix>",
    "provider": "<storage-provider>"
  }
}
{
        "ok" : 1,
        "store" : {
                "name" : "<store-name>",
                "provider" : "<storage-provider>",
                "clusterName" : "<cluster-name>",
                "projectId" : "<project-id>"
        }
}

Example

The following example uses the createStore command to create a new data store called myStore.

use sample
db.runCommand({ createStore: "myStore", provider: "s3", region: "us-east-1", bucket: "my-data-lake", prefix: "/sample" })

The previous command prints the following:

{
  "ok": 1,
  "store": {
    "name": "myStore",
    "region": "us-east-1",
    "bucket": "my-data-lake",
    "delimiter": "/",
    "prefix": "/sample",
    "provider": "s3"
  }
}
use sample
db.runCommand({ createStore: "myStore", provider: "atlas", clusterName: "myTestCluster", projectID: "<project-id>" })

The previous command prints the following:

{
        "ok" : 1,
        "store" : {
                "name" : "myStore",
                "provider" : "atlas",
                "clusterName" : "myTestCluster",
                "projectId" : "<project-id>"
        }
}

Troubleshoot Errors

If the command fails, it returns one of the following errors.

Reason: A data store with the name specified in createStore already exists.

{
  "ok": 0,
  "errmsg": "store <store-name> already exists",
  "code": 2,
  "codeName": "BadValue"
}

Solution: Specify a unique name for the data store.

Reason: The specified provider isn't recognized.

{
  "ok": 0,
  "errmsg": "unrecognized store provider <storage-provider>",
  "code": 2,
  "codeName": "BadValue"
}

Solution: Ensure that you specify a valid storage provider.

←  createdrop →