Code Monkey home page Code Monkey logo

terraform-aws-mongodbatlas's Introduction

terraform-aws-mongodbatlas

Terraform module which creates a MongoDB Atlas cluster on AWS

These types of resources are supported:

Terraform versions

Terraform versions >=0.12 are supported

Usage

module "atlas_cluster" {
  source = ".//terraform-aws-mongodbatlas"

  project_name = "my-project"
  org_id = "5edf67f9b9b528996228111"

  teams = {
    Devops: {
      users: ["[email protected]", "[email protected]"]
      role: "GROUP_OWNER"
    },
    DevTeam: {
      users: ["[email protected]",]
      role: "GROUP_READ_ONLY"
    }
  }

  white_lists = {
    "example comment": "10.0.0.1/32",
    "second example": "10.10.10.8/32"
  }

  region = "EU_WEST_1"

  cluster_name = "MyCluster"

  instance_type = "M30"
  mongodb_major_ver = 4.2
  cluster_type = "REPLICASET"
  num_shards = 1
  replication_factor = 3
  provider_backup = true
  pit_enabled = false

}

Prerequisites

Manual tasks:

  • Configure the API key before applying the module
  • Get your MongoDB Atlas Organization ID from the UI

Create Teams:

In case you want to create Teams and associate them with the project, users must be added in advance and making sure they have accepted the invitation. Users who have not accepted an invitation to join the organization cannot be added as team members.

VPC Peering

In case vpc peering is required, AWS provider will be used, the following information is required:

You can add them manually, or through other Terraform resources, and pass it to the module via vpc_peer variable:

  vpc_peer = {
    vpc_peer1 : {
      aws_account_id : "020201234877"
      region : "eu-west-1"
      vpc_id : "vpc-0240c8a47312svc3e"
      route_table_cidr_block : "172.16.0.0/16"
    },
    vpc_peer2 : {
      aws_account_id : "0205432147877"
      region : "eu-central-1"
      vpc_id : "vpc-0f0dd82430bhv0e1a"
      route_table_cidr_block : "172.17.0.0/16"
    }
  }

You can see this example in the examples folder.

Requirements

Name Version
terraform >= 0.12

Providers

Name Version
mongodbatlas

Inputs

Name Description Type Default Required
auto_scaling_disk_gb_enabled Indicating if disk auto-scaling is enabled. bool true no
cluster_name The cluster name. string "" yes
cluster_type The MongoDB Atlas cluster type - SHARDED/REPLICASET/GEOSHARDED. string "" yes
disk_size_gb Capacity,in gigabytes,of the host’s root volume. number no
instance_type The Atlas instance-type name. string "" yes
mongodb_major_ver The MongoDB cluster major version. number "" no
num_shards number of shards. number "" no
org_id The ID of the Atlas organization you want to create the project within. string "" yes
pit_enabled Indicating if the cluster uses Continuous Cloud Backup. bool false no
project_name The name of the project you want to create. string "" yes
provider_backup Indicating if the cluster uses Cloud Backup for backups. bool true no
provider_disk_iops The maximum IOPS the system can perform. number no
provider_encrypt_ebs_volume Indicating if the AWS EBS encryption feature encrypts the server’s root volume. bool false no
region The AWS region-name that the cluster will be deployed on. string "" yes
replication_factor The Number of replica set members, possible values are 3/5/7. number no
teams An object that contains all the groups that should be created in the project. map(any) {} no
volume_type STANDARD or PROVISIONED for IOPS higher than the default instance IOPS. string STANDARD no
vpc_peer An object that contains all VPC peering requests from the cluster to AWS VPC's map(any) {} no
white_lists An object that contains all the network white-lists that should be created in the project. map(any) {} no

Outputs

Name Description
cluster_id The cluster ID.
connection_strings Set of connection strings that your applications use to connect to this cluster.
container_id he Network Peering Container ID.
mongo_db_version Version of MongoDB the cluster runs, in major-version.minor-version format.
mongo_uri Base connection string for the cluster.
mongo_uri_updated Lists when the connection string was last updated.
mongo_uri_with_options connection string for connecting to the Atlas cluster. Includes the replicaSet, ssl, and authSource query parameters in the connection string with values appropriate for the cluster.
paused Flag that indicates whether the cluster is paused or not.
srv_address Connection string for connecting to the Atlas cluster, +srv modifier forces the connection to use TLS/SSL
state_name Current state of the cluster.

terraform-aws-mongodbatlas's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

terraform-aws-mongodbatlas's Issues

Resource type not supported: mongodbatlas_project_ip_whitelist

While trying to create a cluster using the module I have found that this resource is no longer supported and that there is a warning in a field that seems to be deprecated in the provider.

Terraform version:

Terraform v0.12.31

Your version of Terraform is out of date! The latest version
is 1.0.11. You can update by downloading from https://www.terraform.io/downloads.html

The error I am getting is the following one:

Warning: Argument is deprecated

  on .terraform/modules/mongodb_atlas_cluster/main.tf line 70, in resource "mongodbatlas_cluster" "cluster":
  70:   provider_backup_enabled      = var.provider_backup

This field is deprecated,please use cloud_backup instead

(and one more similar warning elsewhere)


Error: Invalid resource type

  on .terraform/modules/mongodb_atlas_cluster/main.tf line 48, in resource "mongodbatlas_project_ip_whitelist" "whitelists":
  48: resource "mongodbatlas_project_ip_whitelist" "whitelists" {

The provider provider.mongodbatlas does not support resource type
"mongodbatlas_project_ip_whitelist".

Releasing state lock. This may take a few moments...
ERRO[0023] 1 error occurred:
        * exit status 1

Any comments or help with this will be appreciated. If you want me to submit a PR removing the resource just let me know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.