Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-Release staging v1.4.0 #763

Merged
merged 17 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3f4615e
INTMDB-310: Potential bug when disabling auditing (#705)
martinstibbe Apr 24, 2022
3099c5d
Add support for schema migration (#717)
martinstibbe Apr 24, 2022
de24563
Correct import function for snapshot export bucket (#715)
martinstibbe Apr 24, 2022
5d6b7cb
INTMDB-311: Feature Add: Prometheus and Microsoft Team to the Third P…
martinstibbe Apr 24, 2022
6bc4c37
INTMDB-328: Update resource & data source to address change in go SDK…
martinstibbe May 27, 2022
a34b968
Merge branch 'master' into release-staging-v1.4.0
martinstibbe May 27, 2022
5e46ed0
INTMDB-319: Add support for parameter unordered in resource_mongodbat…
martinstibbe Jun 2, 2022
34249fb
Chore(deps): Bump github.com/gruntwork-io/terratest (#744)
dependabot[bot] Jun 2, 2022
bd16e6d
Chore(deps): Bump github.com/hashicorp/terraform-plugin-sdk/v2 (#743)
dependabot[bot] Jun 2, 2022
a4fc08d
INTMDB-321: Add support for cloud export backup to mongodbatlas_cloud…
martinstibbe Jun 3, 2022
dc519e9
INTMDB-313: Update the project resource with new settings (#741)
martinstibbe Jun 3, 2022
cbe6a47
Merge branch 'master' into release-staging-v1.4.0
martinstibbe Jun 10, 2022
7a3f20d
INTMDB-307 Allow setting of regional mode setting on a group (#718)
evertsd Jun 28, 2022
0f04f70
INTDB-301-DOC: Move Federated Docs to separate branch (#747)
martinstibbe Jun 30, 2022
67ac9e8
INTMDB-301: Feature add: Add support for managment of federated authe…
martinstibbe Jun 30, 2022
0705acc
Update CHANGELOG.md
martinstibbe Jun 30, 2022
d9008a2
Update CHANGELOG.md
martinstibbe Jun 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ $ export MONGODB_ATLAS_API_KEYS_IDS=<API_KEYS_IDS>
export SKIP_TEST_EXTERNAL_CREDENTIALS=TRUE
```

- For `Federated Settings` resource configuration:
```sh
$ export MONGODB_ATLAS_FEDERATION_SETTINGS_ID=<YOUR_FEDERATION_SETTINGS_ID>
$ export ONGODB_ATLAS_FEDERATED_ORG_ID=<YOUR_FEDERATED_ORG_ID>
$ export MONGODB_ATLAS_FEDERATED_PROJECT_ID=<YOUR_VPC_FEDERATED_PROJECT_ID>
$ export MONGODB_ATLAS_FEDERATED_GROUP_ID=<YOUR_FEDERATED_GROUP_ID>
$ export MONGODB_ATLAS_FEDERATED_ROLE_MAPPING_ID=<YOUR_FEDERATED_ROLE_MAPPING_ID>
$ export MONGODB_ATLAS_FEDERATED_OKTA_IDP_ID=<YOUR_FEDERATED_OKTA_IDP_ID>
$ export MONGODB_ATLAS_FEDERATED_SSO_URL=<YOUR_FEDERATED_SSO_URL>
$ export MONGODB_ATLAS_FEDERATED_ISSUER_URI=<YOUR_FEDERATED_ISSUER_URI>
```
~> **Notice:** For more information about the Federation configuration resource, see: https://www.mongodb.com/docs/atlas/reference/api/federation-configuration/

##### AWS env variables

- For `Network Peering` resource configuration:
Expand Down
59 changes: 59 additions & 0 deletions examples/Federated-Settings/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Example - Okta and MongoDB Atlas Federated Settings Configuration

This project aims to provide an example of using Okta and MongoDB Atlas together.


## Dependencies

* Terraform v0.13
* Okta account
* A MongoDB Atlas account

```
Terraform v0.13.0
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.4.0
```

## Usage

**1\. Ensure your Okta/Mongodb Atlas Federal settings configuration is set up to have a working set of organizations, verified domains, and identity providers.**

**2\. TFVARS**

Now create **terraform.tfvars** file with all the variable values and make sure **not to commit it**.

**3\. Review the Terraform plan. **

Execute the below command and ensure you are happy with the plan.

``` bash
$ terraform plan
```
This project currently does the below deployments:

- MongoDB Atlas Federated Settings Organizational Role Mapping
- MongoDB Atlas Federated Settings Organizational Identity Provider
- MongoDB Atlas Federated Settings Organizational configuration

**4\. Execute the Terraform import for 2 resources that do not support create.**
``` bash
$ terraform import mongodbatlas_federated_settings_identity_provider.identity_provider 6287a67f7f7f7f7f441c6c-0oad7f7f7f7fk1297
terraform import mongodbatlas_federated_settings_org_config.org_connections_import 6287a67f7f7f7f7f441c6c-627a96837f7f7f7f7e306f14

```

**5\. Execute the Terraform apply.**

Now execute the plan to provision the Federated settings resources.

``` bash
$ terraform apply
```

**6\. Destroy the resources.**

Once you are finished your testing, ensure you destroy the resources to avoid unnecessary Atlas charges.

``` bash
$ terraform destroy
```
50 changes: 50 additions & 0 deletions examples/Federated-Settings/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
data "mongodbatlas_federated_settings" "federated_settings" {
org_id = var.org_id
}
data "mongodbatlas_federated_settings_identity_providers" "identity_provider" {
federation_settings_id = data.mongodbatlas_federated_settings.federated_settings.id
}

data "mongodbatlas_federated_settings_org_configs" "org_configs_ds" {
federation_settings_id = data.mongodbatlas_federated_settings.federated_settings.id
}

data "mongodbatlas_federated_settings_org_role_mappings" "org_role_mapping" {
federation_settings_id = data.mongodbatlas_federated_settings.federated_settings.id
org_id = var.org_id
}
resource "mongodbatlas_federated_settings_org_role_mapping" "org_role_mapping" {
federation_settings_id = data.mongodbatlas_federated_settings.federated_settings.id
org_id = var.org_id
external_group_name = "newgroup"

role_assignments {
group_id = var.group_id
roles = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN", "GROUP_SEARCH_INDEX_EDITOR", "GROUP_DATA_ACCESS_READ_ONLY"]
}

role_assignments {
org_id = var.org_id
roles = ["ORG_OWNER", "ORG_MEMBER"]
}

}
resource "mongodbatlas_federated_settings_org_config" "org_connections_import" {
federation_settings_id = data.mongodbatlas_federated_settings.federated_settings.id
org_id = var.org_id
identity_provider_id = var.identity_provider_id
domain_restriction_enabled = false
domain_allow_list = ["yourdomain.com"]
}

resource "mongodbatlas_federated_settings_identity_provider" "identity_provider" {
federation_settings_id = data.mongodbatlas_federated_settings.federated_settings.id
name = var.name
associated_domains = ["yourdomain.com"]
sso_debug_enabled = true
status = "ACTIVE"
sso_url = "https://mysso.oktapreview.com/app/mysso_terrafssotesdev_1/exk1f7f7f7fk5wp50h8/sso/saml"
issuer_uri = "http://www.okta.com/exk1f716hf7f750h8"
request_binding = "HTTP-POST"
response_signature_algorithm = "SHA-256"
}
15 changes: 15 additions & 0 deletions examples/Federated-Settings/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "federated_settings_ds" {
value = data.mongodbatlas_federated_settings.federated_settings.id
}

output "identity_provider" {
value = data.mongodbatlas_federated_settings_identity_providers.identity_provider.id
}

output "org_configs_ds" {
value = data.mongodbatlas_federated_settings_org_configs.org_configs_ds.id
}

output "org_role_mapping" {
value = data.mongodbatlas_federated_settings_org_role_mappings.org_role_mapping.id
}
4 changes: 4 additions & 0 deletions examples/Federated-Settings/provider.tf
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
}
28 changes: 28 additions & 0 deletions examples/Federated-Settings/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 "group_id" {
type = string
description = "MongoDB Group ID"
}

variable "name" {
type = string
description = "MongoDB Identity Provider Name"
default = "mongodb_federation_test"
}

variable "identity_provider_id" {
type = string
description = "MongoDB Identity Provider ID"
default = "5754gdhgd758"
}
11 changes: 11 additions & 0 deletions examples/Federated-Settings/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
}
mongodbatlas = {
source = "mongodb/mongodbatlas"
}
}
required_version = ">= 0.13"
}
5 changes: 5 additions & 0 deletions examples/MongoDB-Atlas-Third-Party-Integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
iatlaspl.code-workspace
terraform.tfvars
.terraform/
*.tfstate*

68 changes: 68 additions & 0 deletions examples/MongoDB-Atlas-Third-Party-Integration/Readme.md
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
```

7 changes: 7 additions & 0 deletions examples/MongoDB-Atlas-Third-Party-Integration/project.tf
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
}
4 changes: 4 additions & 0 deletions examples/MongoDB-Atlas-Third-Party-Integration/provider.tf
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
}
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 examples/MongoDB-Atlas-Third-Party-Integration/variables.tf
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"
}
8 changes: 8 additions & 0 deletions examples/MongoDB-Atlas-Third-Party-Integration/versions.tf
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"
}
Loading