Skip to content

Commit 5cad7be

Browse files
authored
doc: Updates examples & docs that use replicaSet clusters (#2428)
* update basic examples * fix linter * fix tf-validate * update tflint version * fix validate * remove tf linter exceptions * make linter fail * simplify and show linter errors in GH * tlint problem matcher * problem matcher * minimum severity warning * fix linter * make tf-validate logic easier to be run in local * less verbose tf init * fix /mongodbatlas_network_peering/aws * doc for backup_compliance_policy * fix container_id reference * fix mongodbatlas_network_peering/azure * use temp fodler * fix examples/mongodbatlas_network_peering/gcp * remaining examples * fix mongodbatlas_clusters * fix adv_cluster doc * remaining doc changes * fix typo * fix examples with deprecated arguments * get the first value for containter_id * container_id in doc * address feedback
1 parent b4b9109 commit 5cad7be

File tree

52 files changed

+876
-758
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+876
-758
lines changed

.github/tflint-matcher.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "tflint-compact",
5+
"severity": "warning",
6+
"pattern": [
7+
{
8+
"regexp": "^(.+):(\\d+):(\\d+):\\s(Error|Warning|Notice)\\s-\\s(.+)\\s\\((.+)\\)$",
9+
"file": 1,
10+
"line": 2,
11+
"column": 3,
12+
"severity": 4,
13+
"message": 5,
14+
"code": 6
15+
}
16+
]
17+
}
18+
]
19+
}

.github/workflows/examples.yml

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,27 @@ env:
1515
jobs:
1616
tf-validate:
1717
runs-on: ubuntu-latest
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
terraform_version: ["${{vars.TF_VERSION_LATEST}}"]
2218
permissions: {}
2319
steps:
2420
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
25-
with:
26-
fetch-depth: 0
27-
- run: echo "GO_VERSION=$(cat .go-version)" >> "${GITHUB_ENV}"
2821
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
2922
with:
3023
go-version-file: 'go.mod'
31-
- name: go build
32-
run: go build -o terraform-plugin-dir/terraform-provider-mongodbatlas-dev_v99.99.99_x5 .
33-
- name: override plugin
34-
run: |
35-
# For newer versions
36-
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/mongodbatlas-dev/99.99.99/"$(go env GOOS)"_"$(go env GOARCH)"/
37-
cp terraform-plugin-dir/terraform-provider-mongodbatlas-dev_v99.99.99_x5 ~/.terraform.d/plugins/registry.terraform.io/hashicorp/mongodbatlas-dev/99.99.99/"$(go env GOOS)"_"$(go env GOARCH)"/
38-
- name: replace names of provider for local development
39-
run: grep --include=\*versions.tf -rnl './examples' -e 'source = "mongodb/mongodbatlas"' | xargs sed -i s@mongodb/mongodbatlas@hashicorp/mongodbatlas-dev@g
40-
- name: remove version of provider for local development
41-
run: grep --include=\*versions.tf -rnl './examples' -e 'version =' | xargs sed -i '/^\s*version =/d'
42-
- name: Fix format after substitutions
43-
run: grep --include=\*versions.tf -rnl './examples' -e 'source[[:space:]]\+=' | xargs sed -i 's@\(\([[:space:]]*\)source\)[[:space:]]\+=[[:space:]]*@\2source = @g'
4424
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8
4525
with:
46-
terraform_version: ${{ matrix.terraform_version }}
47-
# Needed to use the output of `terraform validate -json`
26+
terraform_version: ${{ vars.TF_VERSION_LATEST }}
4827
terraform_wrapper: false
4928
- name: tf-validate
5029
run: make tools tf-validate
5130
tflint:
5231
runs-on: ubuntu-latest
53-
strategy:
54-
fail-fast: false
55-
matrix:
56-
terraform_version: ["${{vars.TF_VERSION_LATEST}}"]
5732
permissions: {}
5833
steps:
5934
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
60-
with:
61-
fetch-depth: 0
6235
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
6336
with:
6437
go-version-file: 'go.mod'
6538
- name: tflint
66-
run: make tools tflint
39+
run: |
40+
echo "::add-matcher::.github/tflint-matcher.json"
41+
make tools tflint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ terraform.tfplan
77
terraform.tfstate
88
.terraform.lock.hcl
99
bin/
10+
bin-examples/
1011
/pkg/
1112
.vagrant/
1213
*.backup

GNUmakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ lint:
7575
tools: ## Install dev tools
7676
@echo "==> Installing dependencies..."
7777
go install github.com/icholy/gomajor@latest
78-
go install github.com/terraform-linters/tflint@v0.49.0
78+
go install github.com/terraform-linters/tflint@v0.52.0
7979
go install github.com/rhysd/actionlint/cmd/actionlint@latest
8080
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
8181
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
@@ -91,11 +91,11 @@ docs:
9191

9292
.PHONY: tflint
9393
tflint: fmtcheck
94-
@scripts/tflint.sh
94+
tflint -f compact --recursive --minimum-failure-severity=warning
9595

9696
.PHONY: tf-validate
9797
tf-validate: fmtcheck
98-
@scripts/tf-validate.sh
98+
scripts/tf-validate.sh
9999

100100
.PHONY: link-git-hooks
101101
link-git-hooks: ## Install git hooks

docs/data-sources/advanced_clusters.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Data Source: mongodbatlas_clusters
1+
# Data Source: mongodbatlas_advanced_clusters
22

3-
`mongodbatlas_cluster` describes all Advanced Clusters by the provided project_id. The data source requires your Project ID.
3+
`mongodbatlas_advanced_clusters` describes all Advanced Clusters by the provided project_id. The data source requires your Project ID.
44

55
-> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation.
66

@@ -11,7 +11,7 @@
1111
## Example Usage
1212

1313
```terraform
14-
resource "mongodbatlas_cluster" "example" {
14+
resource "mongodbatlas_advanced_cluster" "example" {
1515
project_id = "<YOUR-PROJECT-ID>"
1616
name = "cluster-test"
1717
cluster_type = "REPLICASET"
@@ -29,8 +29,8 @@ resource "mongodbatlas_cluster" "example" {
2929
}
3030
}
3131
32-
data "mongodbatlas_clusters" "example" {
33-
project_id = mongodbatlas_cluster.example.project_id
32+
data "mongodbatlas_advanced_clusters" "example" {
33+
project_id = mongodbatlas_advanced_cluster.example.project_id
3434
}
3535
```
3636

docs/data-sources/backup_compliance_policy.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,28 @@
99
## Example Usage
1010

1111
```terraform
12-
resource "mongodbatlas_cluster" "my_cluster" {
13-
project_id = "<PROJECT-ID>"
14-
name = "clusterTest"
15-
16-
//Provider Settings "block"
17-
provider_name = "AWS"
18-
provider_region_name = "EU_CENTRAL_1"
19-
provider_instance_size_name = "M10"
20-
cloud_backup = true // enable cloud backup snapshots
12+
resource "mongodbatlas_advanced_cluster" "my_cluster" {
13+
project_id = "<PROJECT-ID>"
14+
name = "clusterTest"
15+
cluster_type = "REPLICASET"
16+
backup_enabled = true # enable cloud backup snapshots
17+
18+
replication_specs {
19+
region_configs {
20+
priority = 7
21+
provider_name = "AWS"
22+
region_name = "EU_CENTRAL_1"
23+
electable_specs {
24+
instance_size = "M10"
25+
node_count = 3
26+
}
27+
}
28+
}
2129
}
2230
2331
resource "mongodbatlas_cloud_backup_schedule" "test" {
24-
project_id = mongodbatlas_cluster.my_cluster.project_id
25-
cluster_name = mongodbatlas_cluster.my_cluster.name
32+
project_id = mongodbatlas_advanced_cluster.my_cluster.project_id
33+
cluster_name = mongodbatlas_advanced_cluster.my_cluster.name
2634
2735
reference_hour_of_day = 3
2836
reference_minute_of_hour = 45

docs/data-sources/cloud_backup_schedule.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,28 @@
77
## Example Usage
88

99
```terraform
10-
resource "mongodbatlas_cluster" "my_cluster" {
11-
project_id = "<PROJECT-ID>"
12-
name = "clusterTest"
13-
14-
//Provider Settings "block"
15-
provider_name = "AWS"
16-
provider_region_name = "EU_CENTRAL_1"
17-
provider_instance_size_name = "M10"
18-
cloud_backup = true // enable cloud backup snapshots
10+
resource "mongodbatlas_advanced_cluster" "my_cluster" {
11+
project_id = "<PROJECT-ID>"
12+
name = "clusterTest"
13+
cluster_type = "REPLICASET"
14+
backup_enabled = true # enable cloud backup snapshots
15+
16+
replication_specs {
17+
region_configs {
18+
priority = 7
19+
provider_name = "AWS"
20+
region_name = "EU_CENTRAL_1"
21+
electable_specs {
22+
instance_size = "M10"
23+
node_count = 3
24+
}
25+
}
26+
}
1927
}
2028
2129
resource "mongodbatlas_cloud_backup_schedule" "test" {
22-
project_id = mongodbatlas_cluster.my_cluster.project_id
23-
cluster_name = mongodbatlas_cluster.my_cluster.name
30+
project_id = mongodbatlas_advanced_cluster.my_cluster.project_id
31+
cluster_name = mongodbatlas_advanced_cluster.my_cluster.name
2432
2533
reference_hour_of_day = 3
2634
reference_minute_of_hour = 45

docs/data-sources/cloud_provider_snapshot_backup_policy.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,60 @@ subcategory: "Deprecated"
1414
## Example Usage
1515

1616
```terraform
17-
resource "mongodbatlas_cluster" "my_cluster" {
18-
project_id = "<PROJECT-ID>"
19-
name = "clusterTest"
20-
21-
//Provider Settings "block"
22-
provider_name = "AWS"
23-
provider_region_name = "EU_CENTRAL_1"
24-
provider_instance_size_name = "M10"
25-
cloud_backup = true // enable cloud backup snapshots
17+
resource "mongodbatlas_advanced_cluster" "my_cluster" {
18+
project_id = "<PROJECT-ID>"
19+
name = "clusterTest"
20+
cluster_type = "REPLICASET"
21+
backup_enabled = true # enable cloud backup snapshots
22+
23+
replication_specs {
24+
region_configs {
25+
priority = 7
26+
provider_name = "AWS"
27+
region_name = "EU_CENTRAL_1"
28+
electable_specs {
29+
instance_size = "M10"
30+
node_count = 3
31+
}
32+
}
33+
}
2634
}
2735
2836
resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" {
29-
project_id = mongodbatlas_cluster.my_cluster.project_id
30-
cluster_name = mongodbatlas_cluster.my_cluster.name
37+
project_id = mongodbatlas_advanced_cluster.my_cluster.project_id
38+
cluster_name = mongodbatlas_advanced_cluster.my_cluster.name
3139
3240
reference_hour_of_day = 3
3341
reference_minute_of_hour = 45
3442
restore_window_days = 4
3543
3644
3745
policies {
38-
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.id
46+
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.id
3947
4048
policy_item {
41-
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.0.id
49+
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.0.id
4250
frequency_interval = 1
4351
frequency_type = "hourly"
4452
retention_unit = "days"
4553
retention_value = 1
4654
}
4755
policy_item {
48-
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.1.id
56+
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.1.id
4957
frequency_interval = 1
5058
frequency_type = "daily"
5159
retention_unit = "days"
5260
retention_value = 2
5361
}
5462
policy_item {
55-
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.2.id
63+
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.2.id
5664
frequency_interval = 4
5765
frequency_type = "weekly"
5866
retention_unit = "weeks"
5967
retention_value = 3
6068
}
6169
policy_item {
62-
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.3.id
70+
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.3.id
6371
frequency_interval = 5
6472
frequency_type = "monthly"
6573
retention_unit = "months"

docs/data-sources/data_lake_pipeline.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ resource "mongodbatlas_project" "projectTest" {
1414
}
1515
1616
resource "mongodbatlas_advanced_cluster" "automated_backup_test" {
17-
project_id = "63f4d4a47baeac59406dc131"
18-
name = "automated-backup-test"
19-
20-
provider_name = "GCP"
21-
provider_region_name = "US_EAST_4"
22-
provider_instance_size_name = "M10"
23-
cloud_backup = true // enable cloud backup snapshots
24-
mongo_db_major_version = "7.0"
17+
project_id = var.project_id
18+
name = "automated-backup-test"
19+
cluster_type = "REPLICASET"
20+
backup_enabled = true # enable cloud backup snapshots
21+
22+
replication_specs {
23+
region_configs {
24+
priority = 7
25+
provider_name = "GCP"
26+
region_name = "US_EAST_4"
27+
electable_specs {
28+
instance_size = "M10"
29+
node_count = 3
30+
}
31+
}
2532
}
26-
33+
}
2734
2835
resource "mongodbatlas_data_lake_pipeline" "pipeline" {
2936
project_id = mongodbatlas_project.projectTest.project_id
@@ -38,7 +45,7 @@ resource "mongodbatlas_data_lake_pipeline" "pipeline" {
3845
3946
source {
4047
type = "ON_DEMAND_CPS"
41-
cluster_name = mongodbatlas_cluster.automated_backup_test.name
48+
cluster_name = mongodbatlas_advanced_cluster.automated_backup_test.name
4249
database_name = "sample_airbnb"
4350
collection_name = "listingsAndReviews"
4451
}

docs/data-sources/data_lake_pipeline_run.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resource "mongodbatlas_data_lake_pipeline" "pipeline" {
2121
}
2222
source {
2323
type = "ON_DEMAND_CPS"
24-
cluster_name = mongodbatlas_cluster.clusterTest.name
24+
cluster_name = mongodbatlas_advanced_cluster.clusterTest.name
2525
database_name = "sample_airbnb"
2626
collection_name = "listingsAndReviews"
2727
}

0 commit comments

Comments
 (0)