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

doc: Updates examples & docs that use replicaSet clusters #2428

Merged
merged 31 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0e6a89f
update basic examples
lantoli Jul 16, 2024
f148ae7
Merge branch 'master' into CLOUDP-260977_cluster_examples
lantoli Jul 16, 2024
6ea079e
fix linter
lantoli Jul 17, 2024
28e4c82
fix tf-validate
lantoli Jul 17, 2024
47886df
update tflint version
lantoli Jul 17, 2024
c8fb713
fix validate
lantoli Jul 17, 2024
2bffd43
remove tf linter exceptions
lantoli Jul 17, 2024
837cf4f
Merge branch 'master' into CLOUDP-260977_cluster_examples
lantoli Jul 17, 2024
5d918bf
make linter fail
lantoli Jul 17, 2024
164f644
simplify and show linter errors in GH
lantoli Jul 17, 2024
3db3316
tlint problem matcher
lantoli Jul 17, 2024
9976946
problem matcher
lantoli Jul 17, 2024
4cfb163
minimum severity warning
lantoli Jul 17, 2024
744f4c7
fix linter
lantoli Jul 17, 2024
fce2f18
make tf-validate logic easier to be run in local
lantoli Jul 17, 2024
e53b7fa
less verbose tf init
lantoli Jul 17, 2024
945057e
fix /mongodbatlas_network_peering/aws
lantoli Jul 17, 2024
f48f5b2
doc for backup_compliance_policy
lantoli Jul 17, 2024
5c310e4
fix container_id reference
lantoli Jul 17, 2024
54a5751
fix mongodbatlas_network_peering/azure
lantoli Jul 17, 2024
87da7b7
use temp fodler
lantoli Jul 17, 2024
f56d1c8
fix examples/mongodbatlas_network_peering/gcp
lantoli Jul 17, 2024
2401ec9
remaining examples
lantoli Jul 17, 2024
bb71c4a
fix mongodbatlas_clusters
lantoli Jul 17, 2024
c350caa
fix adv_cluster doc
lantoli Jul 17, 2024
115180e
remaining doc changes
lantoli Jul 18, 2024
63c97b8
fix typo
lantoli Jul 18, 2024
8ecaf0f
fix examples with deprecated arguments
lantoli Jul 18, 2024
cf4327e
get the first value for containter_id
lantoli Jul 18, 2024
c5043a0
container_id in doc
lantoli Jul 18, 2024
e27302a
address feedback
lantoli Jul 18, 2024
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
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": [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to show TF linter errors in GH UI

{
"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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it easier to run TF validate in local, so no magic is done in GH Actions and everything happens in the script

run: go build -o terraform-plugin-dir/terraform-provider-mongodbatlas-dev_v99.99.99_x5 .
- name: override plugin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify how the override of our provider is handled now?

Copy link
Member Author

@lantoli lantoli Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
lantoli marked this conversation as resolved.
Show resolved Hide resolved
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