Skip to content
Terraform provider for MongoDB Atlas
Branch: master
Clone or download
akshaykarle Merge pull request #65 from dreamteam-gg/docs
Vpc peering doc correction
Latest commit 0a86b76 Mar 3, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Add alert configurations Oct 16, 2018
mongodbatlas Merge pull request #64 from dreamteam-gg/project-import Mar 3, 2019
scripts get test packages from GNUmakefile Aug 7, 2018
vendor update vendor for alert configurations Oct 16, 2018
website Merge pull request #65 from dreamteam-gg/docs Mar 3, 2019
.gitignore Add alert configurations Oct 16, 2018
.travis.yml add & to scripts dir for #27 Jul 27, 2018
LICENSE Lay down foundations for the mongodbatlas terraform provider Jan 5, 2018
main.go Lay down foundations for the mongodbatlas terraform provider Jan 5, 2018


Build Status GitHub release codecov GitHub downloads

Terraform provider for MongoDB Atlas.


  • Terraform 0.11.x
  • Go 1.10 (to build the provider plugin)

Installing the Provider

Follow the instructions to install it as a plugin. After placing it into your plugins directory, run terraform init to initialize it.


# Configure the MongoDB Atlas Provider
provider "mongodbatlas" {
  username = "${var.mongodb_atlas_username}"
  api_key = "${var.mongodb_atlas_api_key}"

# Create a Cluster
resource "mongodbatlas_cluster" "test" {
  # ...

Also look at the example under /examples.

Importing resources

Currently, only mongodbatlas_cluster, mongodbatlas_database_user, mongodbatlas_vpc_peering_connection and mongodbatlas_ip_whitelist can be imported.

To import any of these resources, you need the project ID (aka. group ID). This can be found in the project settings screen.

# Import a cluster
terraform import mongodbatlas_cluster.example <project ID>-<cluster name>

# Import a database user
# NOTE: you'll see a plan diff for the password, this is unavoidable since the user read API omits it
terraform import mongodbatlas_database_user.example <project ID>-<username>

# Import an ip whitelist
terraform import mongodbatlas_ip_whitelist.example <project ID>-<cidr>

# Import an vpc peering
# specify the peering connection id( pcx-xxxxxxxxx )
terrform import mongodbatlas_vpc_peering_connection.example <project ID>-<pcx id>

Building the Provider

Clone and build the repository

go get
make build

Symlink the binary to your terraform plugins directory:

ln -s $GOPATH/bin/terraform-provider-mongodbatlas ~/.terraform.d/plugins/

Updating the Provider

go get -u
make build


The mongodbatlas_container resource does not destroy the container (vpc) in mongo atlas. This is due to a limitation of the mongo atlas API as it doesn't support deleting this resource.


  • Install project dependencies: go get
  • Run tests: make test
  • Build the binary: make build
You can’t perform that action at this time.