Skip to content

Commit 1a26462

Browse files
authored
INTMDB-206 Documentation and example updates (#453)
* documentation update * example for encryption at rest using the cloud provider access with two resources * updating using the depends on * PagerDuty note * PR comments :) * linter
1 parent 0980072 commit 1a26462

File tree

10 files changed

+216
-2
lines changed

10 files changed

+216
-2
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
resource "aws_iam_role_policy" "test_policy" {
2+
name = "mongo_setup_policy"
3+
role = aws_iam_role.test_role.id
4+
5+
policy = <<-EOF
6+
{
7+
"Version": "2012-10-17",
8+
"Statement": [
9+
{
10+
"Effect": "Allow",
11+
"Action": "*",
12+
"Resource": "*"
13+
}
14+
]
15+
}
16+
EOF
17+
}
18+
19+
resource "aws_iam_role" "test_role" {
20+
name = "mongo_setup_test_role"
21+
22+
assume_role_policy = <<EOF
23+
{
24+
"Version": "2012-10-17",
25+
"Statement": [
26+
{
27+
"Effect": "Allow",
28+
"Principal": {
29+
"AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}"
30+
},
31+
"Action": "sts:AssumeRole",
32+
"Condition": {
33+
"StringEquals": {
34+
"sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}"
35+
}
36+
}
37+
}
38+
]
39+
}
40+
EOF
41+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
resource "mongodbatlas_cloud_provider_access_setup" "setup_only" {
2+
project_id = var.project_id
3+
provider_name = var.cloud_provider_access_name
4+
}
5+
6+
resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" {
7+
project_id = var.project_id
8+
role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id
9+
10+
aws = {
11+
iam_assumed_role_arn = aws_iam_role.test_role.arn
12+
}
13+
}
14+
15+
resource "mongodbatlas_encryption_at_rest" "test" {
16+
project_id = var.project_id
17+
18+
aws_kms = {
19+
enabled = true
20+
customer_master_key_id = var.customer_master_key
21+
region = var.atlas_region
22+
role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
23+
}
24+
25+
}
26+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
provider "mongodbatlas" {
2+
public_key = var.public_key
3+
private_key = var.private_key
4+
}
5+
provider "aws" {
6+
access_key = var.access_key
7+
secret_key = var.secret_key
8+
region = var.aws_region
9+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// mongo
2+
variable project_id {
3+
type = string
4+
}
5+
variable cloud_provider_access_name {
6+
type = string
7+
default = "AWS"
8+
}
9+
variable public_key {
10+
type = string
11+
}
12+
variable private_key {
13+
type = string
14+
}
15+
16+
// aws
17+
variable access_key {
18+
type = string
19+
}
20+
variable secret_key {
21+
type = string
22+
}
23+
variable aws_region {
24+
type = string
25+
}
26+
27+
// encryption at rest
28+
variable "customer_master_key" {
29+
description = "The customer master secret key for AWS Account"
30+
default = ""
31+
}
32+
33+
variable "atlas_region" {
34+
default = "US_EAST_1"
35+
description = "Atlas Region"
36+
}
37+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_providers {
3+
mongodbatlas = {
4+
source = "mongodb/mongodbatlas"
5+
}
6+
}
7+
required_version = ">= 0.13"
8+
}
9+

website/docs/guides/0.9.0-upgrade-guide.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: |-
1111

1212
Besides the bug fixes, improvements and enhancements listed in the [CHANGELOG](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/CHANGELOG.md) for 0.9.0 we want to call out some specific features and enhancements added to this version:
1313
* Added support for LDAP configuration and database users
14-
* Added two options to Cloud Provider Access to allow for both actions in a single apply
14+
* Added two options to Cloud Provider Access to allow for both actions in a single apply **NOTE** [migration guide to Cloud Provider Access Setup](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/0.9.1-upgrade-guide#migration-to-cloud-provider-access-setup)
1515
* Apple Silicon (darwin/arm64) support
1616
* Added support for the GCP regions parameter for network containers
1717
* Added support for Custom DNS Configuration
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
layout: "mongodbatlas"
3+
page_title: "MongoDB Atlas Provider 0.9.1: Upgrade and Information Guide"
4+
sidebar_current: "docs-mongodbatlas-guides-091-upgrade-guide"
5+
description: |-
6+
MongoDB Atlas Provider 0.9.1: Upgrade and Information Guide
7+
---
8+
9+
# MongoDB Atlas Provider v0.9.1: Upgrade and Information Guide
10+
11+
## Migration to Cloud Provider Access Setup
12+
13+
To migrate from `mongodbatlas_cloud_provider_access` to `mongodbatlas_cloud_provider_access_setup` and `mongodbatlas_cloud_provider_access_authorization`
14+
perform the following steps
15+
16+
1. Add the new `mongodbatlas_cloud_provider_access_setup` to your configuration file
17+
18+
```hcl
19+
resource "mongodbatlas_cloud_provider_access_setup" "unique" {
20+
project_id = "<PROJECT-ID>"
21+
provider_name = "AWS"
22+
}
23+
```
24+
25+
2. Perform an import from your existing `mongodbatlas_cloud_provider_access` to `mongodbatlas_cloud_provider_access_setup`
26+
**NOTE:** if the import step is missing it will generate a new resource with a different ID
27+
28+
```bash
29+
terraform import mongodbatlas_cloud_provider_access_setup.unique <project_id>-AWS-<role-id>
30+
```
31+
32+
3. Add the mongodbatlas_cloud_provider_access_authorization to the configuration file
33+
34+
```hcl
35+
resource "mongodbatlas_cloud_provider_access_authorization" "auth" {
36+
37+
project_id = mongodbatlas_cloud_provider_access_setup.unique.project_id
38+
role_id = mongodbatlas_cloud_provider_access_setup.unique.role_id
39+
40+
aws = {
41+
iam_assumed_role_arn = "arn:aws:iam::772401394250:role/test-user-role"
42+
}
43+
}
44+
```
45+
46+
4. Execute a terraform plan, apply
47+
48+
```
49+
terraform plan
50+
terraform apply
51+
```
52+
53+
5. Remove your existing `mongodbatlas_cloud_provider_access` resource from terraform state
54+
**NOTE** before doing any terraform state change please do a backup
55+
56+
```bash
57+
terraform state rm mongodbatlas_cloud_provider_access.test_role
58+
```
59+
60+
6. Remove the resource from the config
61+
7. Do a terraform plan (no changes detected)
62+
63+
```bash
64+
terraform plan
65+
66+
(...)
67+
68+
No changes. Infrastructure is up-to-date.
69+
70+
This means that Terraform did not detect any differences between your
71+
configuration and real physical resources that exist. As a result, no
72+
actions need to be performed.
73+
```
74+
75+
### Helpful Links
76+
77+
* [Report bugs](https://github.com/mongodb/terraform-provider-mongodbatlas/issues)
78+
79+
* [Request Features](https://feedback.mongodb.com/forums/924145-atlas?category_id=370723)
80+
81+
* [Contact Support](https://docs.atlas.mongodb.com/support/) covered by MongoDB Atlas support plans, Developer and above.

website/docs/r/alert_configuration.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ Notifications to send when an alert condition is detected.
194194
* `email_enabled` - Flag indicating if email notifications should be sent. Configurable for `ORG`, `GROUP`, and `USER` notifications types.
195195
* `flowdock_api_token` - The Flowdock personal API token. Required for the `FLOWDOCK` notifications type. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.
196196
* `flow_name` - Flowdock flow name in lower-case letters. Required for the `FLOWDOCK` notifications type
197-
* `interval_min` - Number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved. The minimum value is 5.
197+
* `interval_min` - Number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved. The minimum value is 5. **CONDITIONAL** PAGER_DUTY manages the interval value, please do not set it in case of PAGER_DUTY
198198
* `mobile_number` - Mobile number to which alert notifications are sent. Required for the SMS notifications type.
199199
* `ops_genie_api_key` - Opsgenie API Key. Required for the `OPS_GENIE` notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.
200200
* `ops_genie_region` - Region that indicates which API URL to use. Accepted regions are: `US` ,`EU`. The default Opsgenie region is US.

website/docs/r/cloud_provider_access.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ The MongoDB Atlas provider offers two paths to perform an authorization for a cl
1515
* A two resource path, consisting of `mongodbatlas_cloud_provider_access_setup` and `mongodbatlas_cloud_provider_access_authorization`. The first resource, `mongodbatlas_cloud_provider_access_setup`, only generates
1616
the initial configuration (create, delete operations). The second resource, `mongodbatlas_cloud_provider_access_authorization`, helps to perform the authorization using the role_id of the first resource. This path is helpful in a multi-provider Terraform file, and allows a single and decoupled apply.
1717

18+
-> **IMPORTANT** If you want to move from the single resource path to the two resources path see the [migration guide](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/0.9.1-upgrade-guide#migration-to-cloud-provider-access-setup)
19+
1820
## mongodbatlas_cloud_provider_access
1921

2022
`mongodbatlas_cloud_provider_access` Allows you to register and authorize AWS IAM roles in Atlas. This is the resource to use for the single resource path described above.

website/docs/r/encryption_at_rest.html.markdown

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ resource "mongodbatlas_encryption_at_rest" "test" {
5757
}
5858
```
5959

60+
**NOTE** if using the two resources path for cloud provider access, `cloud_provider_access_setup` and `cloud_provider_access_authorization`, you may need to define a `depends_on` statement for these two resources, because terraform is not able to infer the dependency.
61+
62+
```hcl
63+
resource "mongodbatlas_encryption_at_rest" "default" {
64+
(...)
65+
depends_on = [mongodbatlas_cloud_provider_access_setup.<resource_name>, mongodbatlas_cloud_provider_access_authorization.<resource_name>]
66+
}
67+
```
68+
6069
## Argument Reference
6170

6271
* `project_id` - (Required) The unique identifier for the project.

0 commit comments

Comments
 (0)