Skip to content

Commit

Permalink
doc: Updates examples & docs that use replicaSet clusters (#2428)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lantoli authored Jul 18, 2024
1 parent b4b9109 commit 5cad7be
Show file tree
Hide file tree
Showing 52 changed files with 876 additions and 758 deletions.
19 changes: 19 additions & 0 deletions .github/tflint-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"problemMatcher": [
{
"owner": "tflint-compact",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):(\\d+):(\\d+):\\s(Error|Warning|Notice)\\s-\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
33 changes: 4 additions & 29 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,27 @@ env:
jobs:
tf-validate:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
terraform_version: ["${{vars.TF_VERSION_LATEST}}"]
permissions: {}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0
- run: echo "GO_VERSION=$(cat .go-version)" >> "${GITHUB_ENV}"
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version-file: 'go.mod'
- name: go build
run: go build -o terraform-plugin-dir/terraform-provider-mongodbatlas-dev_v99.99.99_x5 .
- name: override plugin
run: |
# For newer versions
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/mongodbatlas-dev/99.99.99/"$(go env GOOS)"_"$(go env GOARCH)"/
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)"/
- name: replace names of provider for local development
run: grep --include=\*versions.tf -rnl './examples' -e 'source = "mongodb/mongodbatlas"' | xargs sed -i s@mongodb/mongodbatlas@hashicorp/mongodbatlas-dev@g
- name: remove version of provider for local development
run: grep --include=\*versions.tf -rnl './examples' -e 'version =' | xargs sed -i '/^\s*version =/d'
- name: Fix format after substitutions
run: grep --include=\*versions.tf -rnl './examples' -e 'source[[:space:]]\+=' | xargs sed -i 's@\(\([[:space:]]*\)source\)[[:space:]]\+=[[:space:]]*@\2source = @g'
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8
with:
terraform_version: ${{ matrix.terraform_version }}
# Needed to use the output of `terraform validate -json`
terraform_version: ${{ vars.TF_VERSION_LATEST }}
terraform_wrapper: false
- name: tf-validate
run: make tools tf-validate
tflint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
terraform_version: ["${{vars.TF_VERSION_LATEST}}"]
permissions: {}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version-file: 'go.mod'
- name: tflint
run: make tools tflint
run: |
echo "::add-matcher::.github/tflint-matcher.json"
make tools tflint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ terraform.tfplan
terraform.tfstate
.terraform.lock.hcl
bin/
bin-examples/
/pkg/
.vagrant/
*.backup
Expand Down
6 changes: 3 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ lint:
tools: ## Install dev tools
@echo "==> Installing dependencies..."
go install github.com/icholy/gomajor@latest
go install github.com/terraform-linters/tflint@v0.49.0
go install github.com/terraform-linters/tflint@v0.52.0
go install github.com/rhysd/actionlint/cmd/actionlint@latest
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
Expand All @@ -91,11 +91,11 @@ docs:

.PHONY: tflint
tflint: fmtcheck
@scripts/tflint.sh
tflint -f compact --recursive --minimum-failure-severity=warning

.PHONY: tf-validate
tf-validate: fmtcheck
@scripts/tf-validate.sh
scripts/tf-validate.sh

.PHONY: link-git-hooks
link-git-hooks: ## Install git hooks
Expand Down
10 changes: 5 additions & 5 deletions docs/data-sources/advanced_clusters.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Data Source: mongodbatlas_clusters
# Data Source: mongodbatlas_advanced_clusters

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

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

Expand All @@ -11,7 +11,7 @@
## Example Usage

```terraform
resource "mongodbatlas_cluster" "example" {
resource "mongodbatlas_advanced_cluster" "example" {
project_id = "<YOUR-PROJECT-ID>"
name = "cluster-test"
cluster_type = "REPLICASET"
Expand All @@ -29,8 +29,8 @@ resource "mongodbatlas_cluster" "example" {
}
}
data "mongodbatlas_clusters" "example" {
project_id = mongodbatlas_cluster.example.project_id
data "mongodbatlas_advanced_clusters" "example" {
project_id = mongodbatlas_advanced_cluster.example.project_id
}
```

Expand Down
30 changes: 19 additions & 11 deletions docs/data-sources/backup_compliance_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@
## Example Usage

```terraform
resource "mongodbatlas_cluster" "my_cluster" {
project_id = "<PROJECT-ID>"
name = "clusterTest"
//Provider Settings "block"
provider_name = "AWS"
provider_region_name = "EU_CENTRAL_1"
provider_instance_size_name = "M10"
cloud_backup = true // enable cloud backup snapshots
resource "mongodbatlas_advanced_cluster" "my_cluster" {
project_id = "<PROJECT-ID>"
name = "clusterTest"
cluster_type = "REPLICASET"
backup_enabled = true # enable cloud backup snapshots
replication_specs {
region_configs {
priority = 7
provider_name = "AWS"
region_name = "EU_CENTRAL_1"
electable_specs {
instance_size = "M10"
node_count = 3
}
}
}
}
resource "mongodbatlas_cloud_backup_schedule" "test" {
project_id = mongodbatlas_cluster.my_cluster.project_id
cluster_name = mongodbatlas_cluster.my_cluster.name
project_id = mongodbatlas_advanced_cluster.my_cluster.project_id
cluster_name = mongodbatlas_advanced_cluster.my_cluster.name
reference_hour_of_day = 3
reference_minute_of_hour = 45
Expand Down
30 changes: 19 additions & 11 deletions docs/data-sources/cloud_backup_schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@
## Example Usage

```terraform
resource "mongodbatlas_cluster" "my_cluster" {
project_id = "<PROJECT-ID>"
name = "clusterTest"
//Provider Settings "block"
provider_name = "AWS"
provider_region_name = "EU_CENTRAL_1"
provider_instance_size_name = "M10"
cloud_backup = true // enable cloud backup snapshots
resource "mongodbatlas_advanced_cluster" "my_cluster" {
project_id = "<PROJECT-ID>"
name = "clusterTest"
cluster_type = "REPLICASET"
backup_enabled = true # enable cloud backup snapshots
replication_specs {
region_configs {
priority = 7
provider_name = "AWS"
region_name = "EU_CENTRAL_1"
electable_specs {
instance_size = "M10"
node_count = 3
}
}
}
}
resource "mongodbatlas_cloud_backup_schedule" "test" {
project_id = mongodbatlas_cluster.my_cluster.project_id
cluster_name = mongodbatlas_cluster.my_cluster.name
project_id = mongodbatlas_advanced_cluster.my_cluster.project_id
cluster_name = mongodbatlas_advanced_cluster.my_cluster.name
reference_hour_of_day = 3
reference_minute_of_hour = 45
Expand Down
40 changes: 24 additions & 16 deletions docs/data-sources/cloud_provider_snapshot_backup_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,60 @@ subcategory: "Deprecated"
## Example Usage

```terraform
resource "mongodbatlas_cluster" "my_cluster" {
project_id = "<PROJECT-ID>"
name = "clusterTest"
//Provider Settings "block"
provider_name = "AWS"
provider_region_name = "EU_CENTRAL_1"
provider_instance_size_name = "M10"
cloud_backup = true // enable cloud backup snapshots
resource "mongodbatlas_advanced_cluster" "my_cluster" {
project_id = "<PROJECT-ID>"
name = "clusterTest"
cluster_type = "REPLICASET"
backup_enabled = true # enable cloud backup snapshots
replication_specs {
region_configs {
priority = 7
provider_name = "AWS"
region_name = "EU_CENTRAL_1"
electable_specs {
instance_size = "M10"
node_count = 3
}
}
}
}
resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" {
project_id = mongodbatlas_cluster.my_cluster.project_id
cluster_name = mongodbatlas_cluster.my_cluster.name
project_id = mongodbatlas_advanced_cluster.my_cluster.project_id
cluster_name = mongodbatlas_advanced_cluster.my_cluster.name
reference_hour_of_day = 3
reference_minute_of_hour = 45
restore_window_days = 4
policies {
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.id
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.id
policy_item {
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.0.id
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.0.id
frequency_interval = 1
frequency_type = "hourly"
retention_unit = "days"
retention_value = 1
}
policy_item {
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.1.id
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.1.id
frequency_interval = 1
frequency_type = "daily"
retention_unit = "days"
retention_value = 2
}
policy_item {
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.2.id
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.2.id
frequency_interval = 4
frequency_type = "weekly"
retention_unit = "weeks"
retention_value = 3
}
policy_item {
id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.3.id
id = mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.3.id
frequency_interval = 5
frequency_type = "monthly"
retention_unit = "months"
Expand Down
27 changes: 17 additions & 10 deletions docs/data-sources/data_lake_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@ resource "mongodbatlas_project" "projectTest" {
}
resource "mongodbatlas_advanced_cluster" "automated_backup_test" {
project_id = "63f4d4a47baeac59406dc131"
name = "automated-backup-test"
provider_name = "GCP"
provider_region_name = "US_EAST_4"
provider_instance_size_name = "M10"
cloud_backup = true // enable cloud backup snapshots
mongo_db_major_version = "7.0"
project_id = var.project_id
name = "automated-backup-test"
cluster_type = "REPLICASET"
backup_enabled = true # enable cloud backup snapshots
replication_specs {
region_configs {
priority = 7
provider_name = "GCP"
region_name = "US_EAST_4"
electable_specs {
instance_size = "M10"
node_count = 3
}
}
}
}
resource "mongodbatlas_data_lake_pipeline" "pipeline" {
project_id = mongodbatlas_project.projectTest.project_id
Expand All @@ -38,7 +45,7 @@ resource "mongodbatlas_data_lake_pipeline" "pipeline" {
source {
type = "ON_DEMAND_CPS"
cluster_name = mongodbatlas_cluster.automated_backup_test.name
cluster_name = mongodbatlas_advanced_cluster.automated_backup_test.name
database_name = "sample_airbnb"
collection_name = "listingsAndReviews"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/data_lake_pipeline_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "mongodbatlas_data_lake_pipeline" "pipeline" {
}
source {
type = "ON_DEMAND_CPS"
cluster_name = mongodbatlas_cluster.clusterTest.name
cluster_name = mongodbatlas_advanced_cluster.clusterTest.name
database_name = "sample_airbnb"
collection_name = "listingsAndReviews"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/data_lake_pipeline_runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "mongodbatlas_data_lake_pipeline" "pipeline" {
}
source {
type = "ON_DEMAND_CPS"
cluster_name = mongodbatlas_cluster.clusterTest.name
cluster_name = mongodbatlas_advanced_cluster.clusterTest.name
database_name = "sample_airbnb"
collection_name = "listingsAndReviews"
}
Expand Down
28 changes: 18 additions & 10 deletions docs/data-sources/ldap_verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@ resource "mongodbatlas_project" "test" {
org_id = "ORG ID"
}
resource "mongodbatlas_cluster" "test" {
project_id = mongodbatlas_project.test.id
name = "NAME OF THE CLUSTER"
// Provider Settings "block"
provider_name = "AWS"
provider_region_name = "US_EAST_2"
provider_instance_size_name = "M10"
cloud_backup = true //enable cloud provider snapshots
resource "mongodbatlas_advanced_cluster" "test" {
project_id = mongodbatlas_project.test.id
name = "ClusterName"
cluster_type = "REPLICASET"
backup_enabled = true # enable cloud provider snapshots
replication_specs {
region_configs {
priority = 7
provider_name = "AWS"
region_name = "US_EAST_1"
electable_specs {
instance_size = "M10"
node_count = 3
}
}
}
}
resource "mongodbatlas_ldap_verify" "test" {
Expand All @@ -30,7 +38,7 @@ resource "mongodbatlas_ldap_verify" "test" {
port = 636
bind_username = "USERNAME"
bind_password = "PASSWORD"
depends_on = [mongodbatlas_cluster.test]
depends_on = [mongodbatlas_advanced_cluster.test]
}
data "mongodbatlas_ldap_verify" "test" {
Expand Down
Loading

0 comments on commit 5cad7be

Please sign in to comment.