Terraform MongoDB(PaidTier)

Create MongoDB Cluster using Terraform


Requisites
mongodb_org_id
mongodb_atlas_public_key
mongodb_atlas_private_key

→ Go to
→ Login in MongoDB Atlas

it will show like this → Create Organization
image.png

Organization is created
image.png

Go to Organization → settings → Copy Organization ID & save it for further use
image.png

Go to Organization → Access Manager → Create API -KEY
image.png

Create API-Key
give permission according to your choice
image.png

Copy & Store Public-key & Private-key for further use
image.png

Now we have
mongodb_org_id
mongodb_atlas_public_key
mongodb_atlas_private_key


Download Terraform

Extract zip file

→ run terraform.exe
check terraform version
terraform --version

Download code from here
go to Folder → create terraform.tfvars file
add below content
atlas_public_key = "" #public key
atlas_private_key = "" #Private Key
atlas_org_id = "" #Org_id
project_name = "Test-Demo" # Project Name
cluster_name = "Test-Cluster" # Cluster Name
cluster_type = "REPLICASET"
provider_instance_size_name = "M10" #Instance size
provider_name = "AWS" #Provider name
disk_size_gb = 20 #according to your choice
provider_region_name = "AP_SOUTH_1" #Mumbai region
mongo_db_major_version = 5.0
database_username = "" #username
database_password = "" #password
ip_address =[”ip_addres_1” , “ip_adress_1” , “ip_address_3”] #ipaddress for access
→ Save the file

→ Open Terminal in that Folder
terraform init

terraform plan

terraform apply


in terminal
it print out MongoDB Connection String
e.g. → mongodb+srv://jackk:<password>@test-cluster.jipsy.mongodb.net

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.