Create MongoDB Cluster using Terraform
Requisites
mongodb_atlas_private_key
→ Login in MongoDB Atlas
it will show like this → Create Organization
Organization is created
Go to Organization → settings → Copy Organization ID & save it for further use
Go to Organization → Access Manager → Create API -KEY
Create API-Key
give permission according to your choice
Copy & Store Public-key & Private-key for further use
Now we have
mongodb_atlas_private_key
Download Terraform
Extract zip file
→ run terraform.exe
check 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 provider_instance_size_name = "M0" backing_provider_name = "AWS" provider_region_name = "AP_SOUTH_1" mongo_db_major_version = 5.0 database_username = "" #username database_password = "" #password ip_addresses =[”ip_addres_1” , “ip_adress_1” , “ip_address_3”] # ip-address → Save the file
→ Open Terminal in that Folder
in terminal
it print out MongoDB Connection String e.g. → mongodb+srv://jackk:<password>@test-cluster.jipsy.mongodb.net