Skip to content

Commit

Permalink
Starter example improvements and doc update (#474)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
themantissa authored Jun 15, 2021
1 parent 3581244 commit b0dd7f4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 27 deletions.
6 changes: 3 additions & 3 deletions examples/starter/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 5 additions & 6 deletions examples/starter/atlas_cluster.tf
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}

4 changes: 2 additions & 2 deletions examples/starter/ip_access_list.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
50 changes: 37 additions & 13 deletions examples/starter/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
}



7 changes: 4 additions & 3 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit b0dd7f4

Please sign in to comment.