From b0dd7f4f18f535a027638ce439f848db6511499b Mon Sep 17 00:00:00 2001 From: Melissa Plunkett Date: Tue, 15 Jun 2021 10:29:59 -0500 Subject: [PATCH] Starter example improvements and doc update (#474) * Starter example improvements and doc update -Updated the doc index to point to the examples directory -Added a few more variables and such to the starter example that seemed useful after writing a demo using it. * Update atlas_cluster.tf --- examples/starter/Readme.md | 6 ++-- examples/starter/atlas_cluster.tf | 11 +++---- examples/starter/ip_access_list.tf | 4 +-- examples/starter/variables.tf | 50 ++++++++++++++++++++++-------- website/docs/index.html.markdown | 7 +++-- 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/examples/starter/Readme.md b/examples/starter/Readme.md index 2b6ff73bf..044f9196f 100644 --- a/examples/starter/Readme.md +++ b/examples/starter/Readme.md @@ -7,16 +7,16 @@ This project aims to provide a very straight-forward example of setting up Terra - Database User - IP Access List -You can refer to the MongoDB Atlas documentation to know about the region names used in MongoDB Atlas respective to the Cloud Provier's region name. +You can refer to the MongoDB Atlas documentation to know about the region names used in MongoDB Atlas respective to the Cloud Provider's region name. [Amazon Web Services (AWS)](https://docs.atlas.mongodb.com/reference/amazon-aws/#amazon-aws) [Google Cloud Platform (GCP)](https://docs.atlas.mongodb.com/reference/google-gcp/#google-gcp) [Microsoft Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/#microsoft-azure) ## Dependencies -* Terraform v0.13 +* Terraform v0.13 or greater * A MongoDB Atlas account -* provider.mongodbatlas: version = "~> 0.7.0" +* provider.mongodbatlas: version = "~> 0.9.1" ## Usage diff --git a/examples/starter/atlas_cluster.tf b/examples/starter/atlas_cluster.tf index 1cf14d08d..749de871a 100644 --- a/examples/starter/atlas_cluster.tf +++ b/examples/starter/atlas_cluster.tf @@ -1,6 +1,6 @@ resource "mongodbatlas_cluster" "cluster" { project_id = mongodbatlas_project.project.id - name = "mongodb-atlas" + name = var.cluster_name mongo_db_major_version = var.mongodbversion cluster_type = "REPLICASET" replication_specs { @@ -15,11 +15,10 @@ resource "mongodbatlas_cluster" "cluster" { //Provider Settings "block" provider_backup_enabled = true auto_scaling_disk_gb_enabled = true - provider_name = "AWS" - disk_size_gb = 10 + provider_name = var.cloud_provider provider_instance_size_name = "M10" - provider_encrypt_ebs_volume = true } -output "atlasclusterstring" { - value = mongodbatlas_cluster.cluster.connection_strings +output "connection_strings" { + value = mongodbatlas_cluster.cluster.connection_strings.0.standard_srv } + diff --git a/examples/starter/ip_access_list.tf b/examples/starter/ip_access_list.tf index f64d0292e..0e4701b2f 100644 --- a/examples/starter/ip_access_list.tf +++ b/examples/starter/ip_access_list.tf @@ -1,7 +1,7 @@ resource "mongodbatlas_project_ip_access_list" "ip" { project_id = mongodbatlas_project.project.id - ip_address = "77.107.233.162" - comment = "cidr block for accessing the cluster" + ip_address = var.ip_address + comment = "IP Address for accessing the cluster" } output "ipaccesslist" { value = mongodbatlas_project_ip_access_list.ip.ip_address diff --git a/examples/starter/variables.tf b/examples/starter/variables.tf index 58cf49f45..465e3a0a9 100644 --- a/examples/starter/variables.tf +++ b/examples/starter/variables.tf @@ -1,27 +1,51 @@ variable "public_key" { - description = "Public API key to authenticate to Atlas" + type = string + description = "Public Programmatic API key to authenticate to Atlas" } variable "private_key" { - description = "Private API key to authenticate to Atlas" + type = string + description = "Private Programmatic API key to authenticate to Atlas" } -variable "dbuser" { - description = "MongoDB Atlas Database User" +variable "org_id" { + type = string + description = "MongoDB Organization ID" } -variable "dbuser_password" { - description = "MongoDB Atlas Database User Password" +variable "project_name" { + type = string + description = "The MongoDB Atlas Project Name" } -variable "database_name" { - description = "The Database in the cluster" +variable "cluster_name" { + type = string + description = "The MongoDB Atlas Cluster Name" } -variable "org_id" { - description = "MongoDB Organization ID" +variable "cloud_provider" { + type = string + description = "The cloud provider to use, must be AWS, GCP or AZURE" } variable "region" { - description = "MongoDB Atlas Cluster Region" + type = string + description = "MongoDB Atlas Cluster Region, must be a region for the provider given" } variable "mongodbversion" { + type = string description = "The Major MongoDB Version" } -variable "project_name" { - description = "The Atlas Project Name" +variable "dbuser" { + type = string + description = "MongoDB Atlas Database User Name" +} +variable "dbuser_password" { + type = string + description = "MongoDB Atlas Database User Password" +} +variable "database_name" { + type = string + description = "The database in the cluster to limit the database user to, the database does not have to exist yet" +} +variable "ip_address" { + type = string + description = "The IP address that the cluster will be accessed from, can also be a CIDR range or AWS security group" } + + + diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index cc0ec690d..90d0616ed 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -95,8 +95,9 @@ For more information on configuring and managing programmatic API Keys see the [ [Support](https://docs.atlas.mongodb.com/support/) covered by MongoDB Atlas support plans, Developer and above. -## Examples from the Community +## Examples from MongoDB and the Community -Have a good example you've created and want to share? Let us know the details via an [issue](https://github.com/mongodb/terraform-provider-mongodbatlas/issues) +We have [example configurations](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples) in our GitHub repo that will help both beginner and more advanced users. + +Have a good example you've created and want to share? Let us know the details via an [issue](https://github.com/mongodb/terraform-provider-mongodbatlas/issues) or submit a PR of your work to add it to the examples directory in our [GitHub repo](https://github.com/mongodb/terraform-provider-mongodbatlas/). -[Example - AWS and Atlas PrivateLink with Terraform](https://github.com/nikhil-mongo/aws-atlas-privatelink)