-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INTMDB-311: Feature Add: Prometheus and Microsoft Team to the Third P…
…arty Integration Settings (#706) * INTMDB-311: Feature Add: Promethus and Microsoft Team to the Third Party Integration Settings * Update documentation add additional schema values * Map to temporary branch for testing * Fix Lint * Add boolean field for Prometheus enabled * Remove Name from Teams integration * Remove extra Name field from Teams integration type add examples * Terraform fmt * Correct version * Fix lint issue * terraform fmt example * Update third party integration resource enabled to boolean * Rename example file * Simplify example to integration only Doc updates password optional field
- Loading branch information
1 parent
de24563
commit 5d6b7cb
Showing
16 changed files
with
341 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
iatlaspl.code-workspace | ||
terraform.tfvars | ||
.terraform/ | ||
*.tfstate* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Example - A basic example configuring MongoDB Atlas Third Party Integrations and Terraform | ||
|
||
This project aims to provide a very straight-forward example of setting up Terraform with MongoDB Atlas. This will create the following resources in MongoDB Atlas: | ||
|
||
- Atlas Project | ||
- Microst Teams Third Party Integration | ||
- Prometheus Third Party Integration | ||
|
||
|
||
You can refer to the MongoDB Atlas documentation to know about the parameters that support Third Party Integrations. | ||
|
||
[Prometheus](https://www.mongodb.com/docs/atlas/tutorial/prometheus-integration/#std-label-httpsd-prometheus-config) | ||
|
||
[Microsoft Teams](https://www.mongodb.com/docs/atlas/tutorial/integrate-msft-teams/) | ||
|
||
## Dependencies | ||
|
||
* Terraform v0.13 or greater | ||
* A MongoDB Atlas account | ||
* provider.mongodbatlas: version = "~> 0.9.1" | ||
|
||
## Usage | ||
|
||
**1\. Ensure your MongoDB Atlas credentials are set up.** | ||
|
||
This can be done using environment variables: | ||
|
||
```bash | ||
export MONGODB_ATLAS_PUBLIC_KEY="xxxx" | ||
export MONGODB_ATLAS_PRIVATE_KEY="xxxx" | ||
``` | ||
|
||
... or follow as in the `variables.tf` file and create **terraform.tfvars** file with all the variable values and make sure **not to commit it**. | ||
|
||
|
||
> **IMPORTANT** Hard-coding your MongoDB Atlas programmatic API key pair into a Terraform configuration is not recommended. Consider the risks, especially the inadvertent submission of a configuration file containing secrets to a public repository. | ||
|
||
**2\. Review the Terraform plan.** | ||
|
||
Execute the below command and ensure you are happy with the plan. | ||
|
||
``` bash | ||
$ terraform plan | ||
``` | ||
|
||
This project currently creates the below deployments: | ||
|
||
- Atlas Project | ||
- Microst Teams Third Party Integration | ||
- Prometheus Third Party Integration | ||
|
||
**3\. Execute the Terraform apply.** | ||
|
||
Now execute the plan to provision the MongoDB Atlas resources. | ||
|
||
``` bash | ||
$ terraform apply | ||
``` | ||
|
||
**4\. Destroy the resources.** | ||
|
||
Once you are finished your testing, ensure you destroy the resources to avoid unnecessary charges. | ||
|
||
``` bash | ||
$ terraform destroy | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resource "mongodbatlas_project" "project" { | ||
name = var.project_name | ||
org_id = var.org_id | ||
} | ||
output "project_name" { | ||
value = mongodbatlas_project.project.name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
provider "mongodbatlas" { | ||
public_key = var.public_key | ||
private_key = var.private_key | ||
} |
15 changes: 15 additions & 0 deletions
15
examples/MongoDB-Atlas-Third-Party-Integration/third-party-integration.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource "mongodbatlas_third_party_integration" "test_msteams" { | ||
project_id = mongodbatlas_project.project.id | ||
type = "MICROSOFT_TEAMS" | ||
microsoft_teams_webhook_url = var.microsoft_teams_webhook_url | ||
} | ||
|
||
resource "mongodbatlas_third_party_integration" "test_prometheus" { | ||
project_id = mongodbatlas_project.project.id | ||
type = "PROMETHEUS" | ||
user_name = var.user_name | ||
password = var.password | ||
service_discovery = "file" | ||
scheme = "https" | ||
enabled = true | ||
} |
31 changes: 31 additions & 0 deletions
31
examples/MongoDB-Atlas-Third-Party-Integration/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
variable "public_key" { | ||
type = string | ||
description = "Public Programmatic API key to authenticate to Atlas" | ||
} | ||
variable "private_key" { | ||
type = string | ||
description = "Private Programmatic API key to authenticate to Atlas" | ||
} | ||
variable "org_id" { | ||
type = string | ||
description = "MongoDB Organization ID" | ||
} | ||
variable "project_name" { | ||
type = string | ||
description = "The MongoDB Atlas Project Name" | ||
} | ||
variable "user_name" { | ||
type = string | ||
description = "The Prometheus User Name" | ||
default = "puser" | ||
} | ||
variable "password" { | ||
type = string | ||
description = "The Prometheus Password" | ||
default = "ppassword" | ||
} | ||
variable "microsoft_teams_webhook_url" { | ||
type = string | ||
description = "The Microsoft Teams Webhook URL" | ||
default = "https://yourcompany.webhook.office.com/webhookb2/zzz@yyy/IncomingWebhook/xyz" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.