Skip to content

Commit dd63412

Browse files
doc: Updates the examples/mongodbatlas_federated_settings_org_role_mapping (#2335)
* docs: Updates the `examples/mongodbatlas_federated_settings_org_role_mapping` * Add back SAML import and remove identity_provider_id variable * rename readme * Update examples/mongodbatlas_federated_settings_org_role_mapping/README.md Co-authored-by: John Williams <[email protected]> --------- Co-authored-by: John Williams <[email protected]>
1 parent f84b9ee commit dd63412

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

examples/mongodbatlas_federated_settings_org_role_mapping/Readme.md renamed to examples/mongodbatlas_federated_settings_org_role_mapping/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This project aims to provide an example of using Okta and MongoDB Atlas together
77

88
* Terraform v0.13
99
* Okta account
10-
* A MongoDB Atlas account
11-
10+
* A MongoDB Atlas account with an organization configured with [Federated Authentication](https://www.mongodb.com/docs/atlas/security/federated-authentication/#federation-management-console)
11+
* Get the `federated_settings_id` from the url, e.g., <https://cloud.mongodb.com/v2#/federation/{federated_settings_id}/overview>
1212
```
1313
Terraform v0.13.0
1414
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.4.0
@@ -27,33 +27,37 @@ Now create **terraform.tfvars** file with all the variable values and make sure
2727
Execute the below command and ensure you are happy with the plan.
2828

2929
``` bash
30-
$ terraform plan
30+
terraform plan
3131
```
3232
This project currently does the below deployments:
3333

3434
- MongoDB Atlas Federated Settings Organizational Role Mapping
35-
- MongoDB Atlas Federated Settings Organizational Identity Provider
35+
- MongoDB Atlas Federated Settings Organizational Identity Provider SAML
36+
- MongoDB Atlas Federated Settings Organizational Identity Provider OIDC
3637
- MongoDB Atlas Federated Settings Organizational configuration
3738

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

41+
- find `idp_id` of your SAML identity provider in <https://cloud.mongodb.com/v2#/federation/{federation_settings_id}/identityProviders>
42+
- replace `federation_settings_id`, `idp_id`, and `org_id` and run:
43+
44+
``` bash
45+
terraform import mongodbatlas_federated_settings_identity_provider.saml_identity_provider {federated_settings_id}-{idp_id}
46+
terraform import mongodbatlas_federated_settings_org_config.org_connections_import {federated_settings_id}-{org_id}
4347
```
4448

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

4751
Now execute the plan to provision the Federated settings resources.
4852

4953
``` bash
50-
$ terraform apply
54+
terraform apply
5155
```
5256

5357
**6\. Destroy the resources.**
5458

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

5761
``` bash
58-
$ terraform destroy
62+
terraform destroy
5963
```

examples/mongodbatlas_federated_settings_org_role_mapping/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ resource "mongodbatlas_federated_settings_org_role_mapping" "org_role_mapping" {
3030

3131
}
3232
resource "mongodbatlas_federated_settings_org_config" "org_connections_import" {
33-
federation_settings_id = data.mongodbatlas_federated_settings.federated_settings.id
34-
org_id = var.org_id
35-
identity_provider_id = var.identity_provider_id
36-
domain_restriction_enabled = false
37-
domain_allow_list = ["yourdomain.com"]
38-
post_auth_role_grants = ["ORG_MEMBER"]
33+
federation_settings_id = data.mongodbatlas_federated_settings.federated_settings.id
34+
org_id = var.org_id
35+
identity_provider_id = mongodbatlas_federated_settings_identity_provider.saml_identity_provider.okta_idp_id
36+
domain_restriction_enabled = false
37+
domain_allow_list = ["yourdomain.com"]
38+
post_auth_role_grants = ["ORG_MEMBER"]
39+
data_access_identity_provider_ids = [mongodbatlas_federated_settings_identity_provider.oidc_identity_provider.idp_id]
3940
}
4041

4142
resource "mongodbatlas_federated_settings_identity_provider" "saml_identity_provider" {

examples/mongodbatlas_federated_settings_org_role_mapping/variables.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ variable "org_id" {
1212
}
1313
variable "group_id" {
1414
type = string
15-
description = "MongoDB Group ID"
15+
description = "MongoDB Group/Project ID"
1616
}
1717

1818
variable "name" {
1919
type = string
2020
description = "MongoDB Identity Provider Name"
2121
default = "mongodb_federation_test"
2222
}
23-
24-
variable "identity_provider_id" {
25-
type = string
26-
description = "MongoDB Identity Provider ID"
27-
default = "5754gdhgd758"
28-
}

0 commit comments

Comments
 (0)