diff --git a/.github/tflint-matcher.json b/.github/tflint-matcher.json new file mode 100644 index 0000000000..888ff582cb --- /dev/null +++ b/.github/tflint-matcher.json @@ -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 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 93d8b69b48..daa8791a50 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -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 diff --git a/.gitignore b/.gitignore index d359912656..6366b3c11a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ terraform.tfplan terraform.tfstate .terraform.lock.hcl bin/ +bin-examples/ /pkg/ .vagrant/ *.backup diff --git a/GNUmakefile b/GNUmakefile index 7505b4ac43..4cd8ddf1e8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 @@ -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 diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index 31c1c84479..f6bb290e63 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -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. @@ -11,7 +11,7 @@ ## Example Usage ```terraform -resource "mongodbatlas_cluster" "example" { +resource "mongodbatlas_advanced_cluster" "example" { project_id = "" name = "cluster-test" cluster_type = "REPLICASET" @@ -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 } ``` diff --git a/docs/data-sources/backup_compliance_policy.md b/docs/data-sources/backup_compliance_policy.md index abcc0a1687..411ce1d300 100644 --- a/docs/data-sources/backup_compliance_policy.md +++ b/docs/data-sources/backup_compliance_policy.md @@ -9,20 +9,28 @@ ## Example Usage ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - 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 = "" + 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 diff --git a/docs/data-sources/cloud_backup_schedule.md b/docs/data-sources/cloud_backup_schedule.md index a3bca33bc8..1aa383656a 100644 --- a/docs/data-sources/cloud_backup_schedule.md +++ b/docs/data-sources/cloud_backup_schedule.md @@ -7,20 +7,28 @@ ## Example Usage ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - 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 = "" + 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 diff --git a/docs/data-sources/cloud_provider_snapshot_backup_policy.md b/docs/data-sources/cloud_provider_snapshot_backup_policy.md index d06361850a..09724c9aa8 100644 --- a/docs/data-sources/cloud_provider_snapshot_backup_policy.md +++ b/docs/data-sources/cloud_provider_snapshot_backup_policy.md @@ -14,20 +14,28 @@ subcategory: "Deprecated" ## Example Usage ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - 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 = "" + 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 @@ -35,31 +43,31 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { 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" diff --git a/docs/data-sources/data_lake_pipeline.md b/docs/data-sources/data_lake_pipeline.md index 3e4d8aa410..fbceb31afa 100644 --- a/docs/data-sources/data_lake_pipeline.md +++ b/docs/data-sources/data_lake_pipeline.md @@ -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 @@ -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" } diff --git a/docs/data-sources/data_lake_pipeline_run.md b/docs/data-sources/data_lake_pipeline_run.md index 29bf7389c4..fc7ba90cdb 100644 --- a/docs/data-sources/data_lake_pipeline_run.md +++ b/docs/data-sources/data_lake_pipeline_run.md @@ -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" } diff --git a/docs/data-sources/data_lake_pipeline_runs.md b/docs/data-sources/data_lake_pipeline_runs.md index 4e44f5459c..8132b939a6 100644 --- a/docs/data-sources/data_lake_pipeline_runs.md +++ b/docs/data-sources/data_lake_pipeline_runs.md @@ -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" } diff --git a/docs/data-sources/ldap_verify.md b/docs/data-sources/ldap_verify.md index 68a4e66fbe..3a4ec5c3f3 100644 --- a/docs/data-sources/ldap_verify.md +++ b/docs/data-sources/ldap_verify.md @@ -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" { @@ -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" { diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index ef93549c0f..e4eff9132a 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -303,21 +303,21 @@ resource "mongodbatlas_advanced_cluster" "cluster" { Standard ```terraform output "standard" { - value = mongodbatlas_cluster.cluster-test.connection_strings[0].standard + value = mongodbatlas_advanced_cluster.cluster.connection_strings[0].standard } # Example return string: standard = "mongodb://cluster-atlas-shard-00-00.ygo1m.mongodb.net:27017,cluster-atlas-shard-00-01.ygo1m.mongodb.net:27017,cluster-atlas-shard-00-02.ygo1m.mongodb.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12diht-shard-0" ``` Standard srv ```terraform output "standard_srv" { - value = mongodbatlas_cluster.cluster-test.connection_strings[0].standard_srv + value = mongodbatlas_advanced_cluster.cluster.connection_strings[0].standard_srv } # Example return string: standard_srv = "mongodb+srv://cluster-atlas.ygo1m.mongodb.net" ``` Private with Network peering and Custom DNS AWS enabled ```terraform output "private" { - value = mongodbatlas_cluster.cluster-test.connection_strings[0].private + value = mongodbatlas_advanced_cluster.cluster.connection_strings[0].private } # Example return string: private = "mongodb://cluster-atlas-shard-00-00-pri.ygo1m.mongodb.net:27017,cluster-atlas-shard-00-01-pri.ygo1m.mongodb.net:27017,cluster-atlas-shard-00-02-pri.ygo1m.mongodb.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12diht-shard-0" private = "mongodb+srv://cluster-atlas-pri.ygo1m.mongodb.net" @@ -325,7 +325,7 @@ private = "mongodb+srv://cluster-atlas-pri.ygo1m.mongodb.net" Private srv with Network peering and Custom DNS AWS enabled ```terraform output "private_srv" { - value = mongodbatlas_cluster.cluster-test.connection_strings[0].private_srv + value = mongodbatlas_advanced_cluster.cluster.connection_strings[0].private_srv } # Example return string: private_srv = "mongodb+srv://cluster-atlas-pri.ygo1m.mongodb.net" ``` diff --git a/docs/resources/backup_compliance_policy.md b/docs/resources/backup_compliance_policy.md index 47454a054e..cc2320df87 100644 --- a/docs/resources/backup_compliance_policy.md +++ b/docs/resources/backup_compliance_policy.md @@ -18,8 +18,8 @@ We first suggest disabling `mongodbatlas_backup_compliance_policy` resource, whi * For example, replace: ``` 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 ... } ``` @@ -37,21 +37,28 @@ We first suggest disabling `mongodbatlas_backup_compliance_policy` resource, whi ## Example Usage ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - 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 = "" + name = "clusterTest" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup snapshots + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = var.region + 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 diff --git a/docs/resources/cloud_backup_schedule.md b/docs/resources/cloud_backup_schedule.md index ab064c2968..4643b4c524 100644 --- a/docs/resources/cloud_backup_schedule.md +++ b/docs/resources/cloud_backup_schedule.md @@ -6,7 +6,7 @@ -> **NOTE:** If Backup Compliance Policy is enabled for the project for which this backup schedule is defined, you cannot modify the backup schedule for an individual cluster below the minimum requirements set in the Backup Compliance Policy. See [Backup Compliance Policy Prohibited Actions and Considerations](https://www.mongodb.com/docs/atlas/backup/cloud-backup/backup-compliance-policy/#configure-a-backup-compliance-policy). --> **NOTE:** When creating a backup schedule you **must either** use the `depends_on` clause to indicate the cluster to which it refers **or** specify the values of `project_id` and `cluster_name` as reference of the cluster resource (e.g. `cluster_name = mongodbatlas_cluster.my_cluster.name` - see the example below). Failure in doing so will result in an error when executing the plan. +-> **NOTE:** When creating a backup schedule you **must either** use the `depends_on` clause to indicate the cluster to which it refers **or** specify the values of `project_id` and `cluster_name` as reference of the cluster resource (e.g. `cluster_name = mongodbatlas_advanced_cluster.my_cluster.name` - see the example below). Failure in doing so will result in an error when executing the plan. In the Terraform MongoDB Atlas Provider 1.0.0 we have re-architected the way in which Cloud Backup Policies are manged with Terraform to significantly reduce the complexity. Due to this change we've provided multiple examples below to help express how this new resource functions. @@ -16,20 +16,28 @@ In the Terraform MongoDB Atlas Provider 1.0.0 we have re-architected the way in You can create a new cluster with `cloud_backup` enabled and then immediately overwrite the default cloud backup policy that Atlas creates by default at the same time with this example. ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - project_id = "" - name = "clusterTest" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_CENTRAL_1" - provider_instance_size_name = "M10" - cloud_backup = true // must be enabled in order to use cloud_backup_schedule resource +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "clusterTest" + cluster_type = "REPLICASET" + backup_enabled = true # must be enabled in order to use cloud_backup_schedule resource + + 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 @@ -55,20 +63,28 @@ resource "mongodbatlas_cloud_backup_schedule" "test" { You can enable `cloud_backup` in the Cluster resource and then use the `cloud_backup_schedule` resource with no policy items to remove the default policy that Atlas creates when you enable Cloud Backup. This allows you to then create a policy when you are ready to via Terraform. ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - project_id = "" - name = "clusterTest" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_CENTRAL_1" - provider_instance_size_name = "M10" - cloud_backup = true // must be enabled in order to use cloud_backup_schedule resource +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "clusterTest" + cluster_type = "REPLICASET" + backup_enabled = true # must be enabled in order to use cloud_backup_schedule resource + + 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 @@ -83,20 +99,28 @@ If you followed the example to Create a Cluster with Cloud Backup Enabled but No The cluster already exists with `cloud_backup` enabled ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - project_id = "" - name = "clusterTest" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_CENTRAL_1" - provider_instance_size_name = "M10" - cloud_backup = true // must be enabled in order to use cloud_backup_schedule resource +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "clusterTest" + cluster_type = "REPLICASET" + backup_enabled = true # must be enabled in order to use cloud_backup_schedule resource + + 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 @@ -138,20 +162,28 @@ resource "mongodbatlas_cloud_backup_schedule" "test" { You can enable `cloud_backup` in the Cluster resource and then use the `cloud_backup_schedule` resource with a basic policy for Cloud Backup. ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - project_id = "" - name = "clusterTest" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "US_EAST_2" - provider_instance_size_name = "M10" - cloud_backup = true // must be enabled in order to use cloud_backup_schedule resource +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "clusterTest" + cluster_type = "REPLICASET" + backup_enabled = true # must be enabled in order to use cloud_backup_schedule resource + + 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 @@ -172,7 +204,7 @@ resource "mongodbatlas_cloud_backup_schedule" "test" { "YEARLY", "ON_DEMAND"] region_name = "US_EAST_1" - replication_spec_id = mongodbatlas_cluster.my_cluster.replication_specs.*.id[0] + replication_spec_id = mongodbatlas_advanced_cluster.my_cluster.replication_specs.*.id[0] should_copy_oplogs = false } diff --git a/docs/resources/cloud_backup_snapshot.md b/docs/resources/cloud_backup_snapshot.md index 1563886195..ef67fe7ea9 100644 --- a/docs/resources/cloud_backup_snapshot.md +++ b/docs/resources/cloud_backup_snapshot.md @@ -10,32 +10,40 @@ On-demand snapshots happen immediately, unlike scheduled snapshots which occur a ## Example Usage ```terraform - resource "mongodbatlas_cluster" "my_cluster" { - project_id = "5cf5a45a9ccf6400e60981b6" - name = "MyCluster" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_WEST_2" - provider_instance_size_name = "M10" - cloud_backup = true // enable cloud backup snapshots - } - - resource "mongodbatlas_cloud_backup_snapshot" "test" { - project_id = mongodbatlas_cluster.my_cluster.project_id - cluster_name = mongodbatlas_cluster.my_cluster.name - description = "myDescription" - retention_in_days = 1 - } - - resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { - project_id = mongodbatlas_cloud_backup_snapshot.test.project_id - cluster_name = mongodbatlas_cloud_backup_snapshot.test.cluster_name - snapshot_id = mongodbatlas_cloud_backup_snapshot.test.snapshot_id - delivery_type_config { - download = true +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup snapshots + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } +} + +resource "mongodbatlas_cloud_backup_snapshot" "test" { + project_id = mongodbatlas_advanced_cluster.my_cluster.project_id + cluster_name = mongodbatlas_advanced_cluster.my_cluster.name + description = "myDescription" + retention_in_days = 1 +} + +resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { + project_id = mongodbatlas_cloud_backup_snapshot.test.project_id + cluster_name = mongodbatlas_cloud_backup_snapshot.test.cluster_name + snapshot_id = mongodbatlas_cloud_backup_snapshot.test.snapshot_id + delivery_type_config { + download = true + } +} ``` ## Argument Reference diff --git a/docs/resources/cloud_backup_snapshot_restore_job.md b/docs/resources/cloud_backup_snapshot_restore_job.md index 2f4d5e0b6e..3107922d51 100644 --- a/docs/resources/cloud_backup_snapshot_restore_job.md +++ b/docs/resources/cloud_backup_snapshot_restore_job.md @@ -19,85 +19,107 @@ ### Example automated delivery type ```terraform - resource "mongodbatlas_cluster" "my_cluster" { - project_id = "5cf5a45a9ccf6400e60981b6" - name = "MyCluster" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_WEST_2" - provider_instance_size_name = "M10" - cloud_backup = true // enable cloud backup snapshots +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup snapshots + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } + } } +} - resource "mongodbatlas_cloud_provider_snapshot" "test" { - project_id = mongodbatlas_cluster.my_cluster.project_id - cluster_name = mongodbatlas_cluster.my_cluster.name - description = "myDescription" - retention_in_days = 1 - } +resource "mongodbatlas_cloud_provider_snapshot" "test" { + project_id = mongodbatlas_advanced_cluster.my_cluster.project_id + cluster_name = mongodbatlas_advanced_cluster.my_cluster.name + description = "myDescription" + retention_in_days = 1 +} - resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { - project_id = mongodbatlas_cloud_provider_snapshot.test.project_id - cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name - snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type_config { - automated = true - target_cluster_name = "MyCluster" - target_project_id = "5cf5a45a9ccf6400e60981b6" - } +resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { + project_id = mongodbatlas_cloud_provider_snapshot.test.project_id + cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name + snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id + delivery_type_config { + automated = true + target_cluster_name = "MyCluster" + target_project_id = "5cf5a45a9ccf6400e60981b6" } +} ``` ### Example download delivery type ```terraform - resource "mongodbatlas_cluster" "my_cluster" { - project_id = "5cf5a45a9ccf6400e60981b6" - name = "MyCluster" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_WEST_2" - provider_instance_size_name = "M10" - cloud_backup = true // enable cloud backup snapshots +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup snapshots + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } + } } +} - resource "mongodbatlas_cloud_provider_snapshot" "test" { - project_id = mongodbatlas_cluster.my_cluster.project_id - cluster_name = mongodbatlas_cluster.my_cluster.name - description = "myDescription" - retention_in_days = 1 - } - - resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { - project_id = mongodbatlas_cloud_provider_snapshot.test.project_id - cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name - snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type_config { - download = true - } +resource "mongodbatlas_cloud_provider_snapshot" "test" { + project_id = mongodbatlas_advanced_cluster.my_cluster.project_id + cluster_name = mongodbatlas_advanced_cluster.my_cluster.name + description = "myDescription" + retention_in_days = 1 +} + +resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { + project_id = mongodbatlas_cloud_provider_snapshot.test.project_id + cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name + snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id + delivery_type_config { + download = true } +} ``` ### Example of a point in time restore ``` -resource "mongodbatlas_cluster" "cluster_test" { - project_id = mongodbatlas_project.project_test.id - name = var.cluster_name - - # Provider Settings "block" - provider_name = "AWS" - provider_region_name = "US_EAST_1" - provider_instance_size_name = "M10" - cloud_backup = true # enable cloud provider snapshots - pit_enabled = true +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup snapshots + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } + } + } } - resource "mongodbatlas_cloud_backup_snapshot" "test" { - project_id = mongodbatlas_cluster.cluster_test.project_id - cluster_name = mongodbatlas_cluster.cluster_test.name + project_id = mongodbatlas_advanced_cluster.cluster_test.project_id + cluster_name = mongodbatlas_advanced_cluster.cluster_test.name description = "My description" retention_in_days = "1" } @@ -110,8 +132,8 @@ resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { delivery_type_config { point_in_time = true - target_cluster_name = mongodbatlas_cluster.cluster_test.name - target_project_id = mongodbatlas_cluster.cluster_test.project_id + target_cluster_name = mongodbatlas_advanced_cluster.cluster_test.name + target_project_id = mongodbatlas_advanced_cluster.cluster_test.project_id point_in_time_utc_seconds = var.point_in_time_utc_seconds } } diff --git a/docs/resources/cloud_provider_snapshot.md b/docs/resources/cloud_provider_snapshot.md index 6d7f756632..df20876be0 100644 --- a/docs/resources/cloud_provider_snapshot.md +++ b/docs/resources/cloud_provider_snapshot.md @@ -15,33 +15,41 @@ On-demand snapshots happen immediately, unlike scheduled snapshots which occur a ## Example Usage ```terraform - resource "mongodbatlas_cluster" "my_cluster" { - project_id = "5cf5a45a9ccf6400e60981b6" - name = "MyCluster" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_WEST_2" - provider_instance_size_name = "M10" - cloud_backup = true // enable cloud backup snapshots - } - - resource "mongodbatlas_cloud_provider_snapshot" "test" { - project_id = mongodbatlas_cluster.my_cluster.project_id - cluster_name = mongodbatlas_cluster.my_cluster.name - description = "myDescription" - retention_in_days = 1 - timeout = "10m" - } - - resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { - project_id = mongodbatlas_cloud_provider_snapshot.test.project_id - cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name - snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type_config { - download = true +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup snapshots + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } +} + +resource "mongodbatlas_cloud_provider_snapshot" "test" { + project_id = mongodbatlas_advanced_cluster.my_cluster.project_id + cluster_name = mongodbatlas_advanced_cluster.my_cluster.name + description = "myDescription" + retention_in_days = 1 + timeout = "10m" +} + +resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { + project_id = mongodbatlas_cloud_provider_snapshot.test.project_id + cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name + snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id + delivery_type_config { + download = true + } +} ``` ## Argument Reference diff --git a/docs/resources/cloud_provider_snapshot_backup_policy.md b/docs/resources/cloud_provider_snapshot_backup_policy.md index 91c057cb2a..f28a17a553 100644 --- a/docs/resources/cloud_provider_snapshot_backup_policy.md +++ b/docs/resources/cloud_provider_snapshot_backup_policy.md @@ -17,20 +17,28 @@ When Cloud Backup is enabled for a cluster MongoDB Atlas automatically creates a ## Example Usage - Create a Cluster and Modify the 4 Default Policies Simultaneously ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - project_id = "" - name = "clusterTest" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_CENTRAL_1" - provider_instance_size_name = "M10" - cloud_backup = true // must be enabled in order to use cloud_provider_snapshot_backup_policy resource +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # must be enabled in order to use cloud_provider_snapshot_backup_policy resource + + 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 @@ -39,10 +47,10 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { //Keep all 4 default policies but modify the units and values //Could also just reflect the policy defaults here for later management 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" @@ -50,7 +58,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { } 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" @@ -58,7 +66,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { } 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" @@ -66,7 +74,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { } 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" @@ -81,20 +89,28 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { ## Example Usage - Create a Cluster and Modify 3 Default Policies and Remove 1 Default Policy Simultaneously ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - project_id = "" - name = "clusterTest" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_CENTRAL_1" - provider_instance_size_name = "M10" - cloud_backup = true // must be enabled in order to use cloud_provider_snapshot_backup_policy resource +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # must be enabled in order to use cloud_provider_snapshot_backup_policy resource + + 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 @@ -102,10 +118,10 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { 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" @@ -113,7 +129,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { } 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" @@ -122,7 +138,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { # Item removed # 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" @@ -130,7 +146,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { # } 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" @@ -147,20 +163,28 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { ## Example Usage - Remove 3 Default Policies Items After the Cluster Has Already Been Created and Modify One Policy ```terraform -resource "mongodbatlas_cluster" "my_cluster" { - project_id = "" - name = "clusterTest" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_CENTRAL_1" - provider_instance_size_name = "M10" - cloud_backup = true // must be enabled in order to use cloud_provider_snapshot_backup_policy resource +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # must be enabled in order to use cloud_provider_snapshot_backup_policy resource + + 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 @@ -168,11 +192,11 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { 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 # Item removed # 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" @@ -181,7 +205,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { # Item removed # 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" @@ -190,7 +214,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { # Item removed # 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" @@ -208,7 +232,7 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { } ``` --> **NOTE:** In this example we decided to remove the first 3 items so we can't use `mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.3.id` to retrieve the monthly id value of the cluster state due to once the cluster being modified or makes a `terraform refresh` will cause that the three items will remove from the state, so we will get an error due to the index 3 doesn't exists any more and our monthly policy item is moved to the first place of the array. So we use `5f0747cad187d8609a72f546`, which is an example of an id MongoDB Atlas returns for the policy item we want to keep. Here it is hard coded because you need to either use the actual value from the Terraform state or look to map the policy item you want to keep to it's current placement in the state file array. +-> **NOTE:** In this example we decided to remove the first 3 items so we can't use `mongodbatlas_advanced_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.3.id` to retrieve the monthly id value of the cluster state due to once the cluster being modified or makes a `terraform refresh` will cause that the three items will remove from the state, so we will get an error due to the index 3 doesn't exists any more and our monthly policy item is moved to the first place of the array. So we use `5f0747cad187d8609a72f546`, which is an example of an id MongoDB Atlas returns for the policy item we want to keep. Here it is hard coded because you need to either use the actual value from the Terraform state or look to map the policy item you want to keep to it's current placement in the state file array. ## Argument Reference @@ -221,11 +245,11 @@ resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" { ### Policies * `policies` - (Required) Contains a document for each backup policy item in the desired updated backup policy. -* `policies.#.id` - (Required) Unique identifier of the backup policy that you want to update. policies.#.id is a value obtained via the mongodbatlas_cluster resource. `cloud_backup` of the mongodbatlas_cluster resource must be set to true. See the example above for how to refer to the mongodbatlas_cluster resource for policies.#.id +* `policies.#.id` - (Required) Unique identifier of the backup policy that you want to update. policies.#.id is a value obtained via the mongodbatlas_advanced_cluster resource. `cloud_backup` of the mongodbatlas_advanced_cluster resource must be set to true. See the example above for how to refer to the mongodbatlas_advanced_cluster resource for policies.#.id #### Policy Item * `policies.#.policy_item` - (Required) Array of backup policy items. -* `policies.#.policy_item.#.id` - (Required) Unique identifier of the backup policy item. `policies.#.policy_item.#.id` is a value obtained via the mongodbatlas_cluster resource. `cloud_backup` of the mongodbatlas_cluster resource must be set to true. See the example above for how to refer to the mongodbatlas_cluster resource for policies.#.policy_item.#.id +* `policies.#.policy_item.#.id` - (Required) Unique identifier of the backup policy item. `policies.#.policy_item.#.id` is a value obtained via the mongodbatlas_advanced_cluster resource. `cloud_backup` of the mongodbatlas_advanced_cluster resource must be set to true. See the example above for how to refer to the mongodbatlas_advanced_cluster resource for policies.#.policy_item.#.id * `policies.#.policy_item.#.frequency_interval` - (Required) Desired frequency of the new backup policy item specified by frequencyType. * `policies.#.policy_item.#.frequency_type` - (Required) Frequency associated with the backup policy item. One of the following values: hourly, daily, weekly or monthly. * `policies.#.policy_item.#.retention_unit` - (Required) Scope of the backup policy item: days, weeks, or months. diff --git a/docs/resources/cloud_provider_snapshot_restore_job.md b/docs/resources/cloud_provider_snapshot_restore_job.md index 5df4d1b533..00d0f36875 100644 --- a/docs/resources/cloud_provider_snapshot_restore_job.md +++ b/docs/resources/cloud_provider_snapshot_restore_job.md @@ -23,66 +23,82 @@ subcategory: "Deprecated" ### Example automated delivery type. ```terraform - resource "mongodbatlas_cluster" "my_cluster" { - project_id = "5cf5a45a9ccf6400e60981b6" - name = "MyCluster" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_WEST_2" - provider_instance_size_name = "M10" - cloud_backup = true // enable cloud backup snapshots - } - - resource "mongodbatlas_cloud_provider_snapshot" "test" { - project_id = mongodbatlas_cluster.my_cluster.project_id - cluster_name = mongodbatlas_cluster.my_cluster.name - description = "myDescription" - retention_in_days = 1 - } - - resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { - project_id = mongodbatlas_cloud_provider_snapshot.test.project_id - cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name - snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type_config { - automated = true - target_cluster_name = "MyCluster" - target_project_id = "5cf5a45a9ccf6400e60981b6" +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup snapshots + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } } - depends_on = [mongodbatlas_cloud_provider_snapshot.test] } +} + +resource "mongodbatlas_cloud_provider_snapshot" "test" { + project_id = mongodbatlas_advanced_cluster.my_cluster.project_id + cluster_name = mongodbatlas_advanced_cluster.my_cluster.name + description = "myDescription" + retention_in_days = 1 +} + +resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { + project_id = mongodbatlas_cloud_provider_snapshot.test.project_id + cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name + snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id + delivery_type_config { + automated = true + target_cluster_name = "MyCluster" + target_project_id = "5cf5a45a9ccf6400e60981b6" + } + depends_on = [mongodbatlas_cloud_provider_snapshot.test] +} ``` ### Example download delivery type. ```terraform - resource "mongodbatlas_cluster" "my_cluster" { - project_id = "5cf5a45a9ccf6400e60981b6" - name = "MyCluster" - - //Provider Settings "block" - provider_name = "AWS" - provider_region_name = "EU_WEST_2" - provider_instance_size_name = "M10" - cloud_backup = true // enable cloud backup snapshots - } - - resource "mongodbatlas_cloud_provider_snapshot" "test" { - project_id = mongodbatlas_cluster.my_cluster.project_id - cluster_name = mongodbatlas_cluster.my_cluster.name - description = "myDescription" - retention_in_days = 1 - } - - resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { - project_id = mongodbatlas_cloud_provider_snapshot.test.project_id - cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name - snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type_config { - download = true +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = "" + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup snapshots + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } +} + +resource "mongodbatlas_cloud_provider_snapshot" "test" { + project_id = mongodbatlas_advanced_cluster.my_cluster.project_id + cluster_name = mongodbatlas_advanced_cluster.my_cluster.name + description = "myDescription" + retention_in_days = 1 +} + +resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { + project_id = mongodbatlas_cloud_provider_snapshot.test.project_id + cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name + snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id + delivery_type_config { + download = true + } +} ``` ## Argument Reference diff --git a/docs/resources/data_lake_pipeline.md b/docs/resources/data_lake_pipeline.md index a32acac567..7b94a14291 100644 --- a/docs/resources/data_lake_pipeline.md +++ b/docs/resources/data_lake_pipeline.md @@ -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 @@ -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" } diff --git a/docs/resources/encryption_at_rest.md b/docs/resources/encryption_at_rest.md index 37e711aa56..ea85a74fa2 100644 --- a/docs/resources/encryption_at_rest.md +++ b/docs/resources/encryption_at_rest.md @@ -84,25 +84,26 @@ resource "mongodbatlas_encryption_at_rest" "example" { } } -resource "mongodbatlas_cluster" "example_cluster" { - project_id = mongodbatlas_encryption_at_rest.example.project_id - name = "CLUSTER NAME" - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "example_cluster" { + project_id = mongodbatlas_encryption_at_rest.example.project_id + name = "CLUSTER NAME" + cluster_type = "REPLICASET" + backup_enabled = true + encryption_at_rest_provider = "AZURE" + replication_specs { - num_shards = 1 - regions_config { - region_name = "REGION" - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AZURE" + region_name = "REGION" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - - provider_name = "AZURE" - provider_instance_size_name = "M10" - mongo_db_major_version = "7.0" - encryption_at_rest_provider = "AZURE" } + ``` ## Argument Reference diff --git a/docs/resources/ldap_verify.md b/docs/resources/ldap_verify.md index 4bb9530b2b..681a2d0223 100644 --- a/docs/resources/ldap_verify.md +++ b/docs/resources/ldap_verify.md @@ -10,15 +10,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 = "NAME OF THE CLUSTER" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud backup 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" { @@ -27,7 +35,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 ] } ``` diff --git a/docs/resources/network_peering.md b/docs/resources/network_peering.md index b62d67e2de..57b73ca768 100644 --- a/docs/resources/network_peering.md +++ b/docs/resources/network_peering.md @@ -102,30 +102,25 @@ resource "google_compute_network_peering" "peering" { } # Create the cluster once the peering connection is completed -resource "mongodbatlas_cluster" "test" { - project_id = local.project_id - name = "terraform-manually-test" - num_shards = 1 - - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "test" { + project_id = local.project_id + name = "terraform-manually-test" + cluster_type = "REPLICASET" + backup_enabled = true + replication_specs { - num_shards = 1 - regions_config { - region_name = "US_EAST_4" - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "GCP" + region_name = "US_EAST_4" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - - auto_scaling_disk_gb_enabled = true - mongo_db_major_version = "7.0" - - # Provider Settings "block" - provider_name = "GCP" - provider_instance_size_name = "M10" - depends_on = ["google_compute_network_peering.peering"] + depends_on = [ google_compute_network_peering.peering ] } # Private connection strings are not available w/ GCP until the reciprocal @@ -166,32 +161,26 @@ resource "mongodbatlas_network_peering" "test" { } # Create the cluster once the peering connection is completed -resource "mongodbatlas_cluster" "test" { - project_id = local.project_id - name = "terraform-manually-test" +resource "mongodbatlas_advanced_cluster" "test" { + project_id = local.project_id + name = "terraform-manually-test" + cluster_type = "REPLICASET" + backup_enabled = true - cluster_type = "REPLICASET" replication_specs { - num_shards = 1 - regions_config { - region_name = "US_EAST_2" - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AZURE" + region_name = "US_EAST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - auto_scaling_disk_gb_enabled = true - mongo_db_major_version = "7.0" - - # Provider Settings "block" - provider_name = "AZURE" - provider_disk_type_name = "P4" - provider_instance_size_name = "M10" - - depends_on = ["mongodbatlas_network_peering.test"] + depends_on = [ mongodbatlas_network_peering.test ] } - ``` ## Example Usage - Peering Connection Only, Container Exists @@ -201,27 +190,23 @@ You can create a peering connection if an appropriate container for your cloud p ```terraform # Create an Atlas cluster, this creates a container if one # does not yet exist for this AWS region -resource "mongodbatlas_cluster" "test" { - project_id = local.project_id - name = "terraform-test" - - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "test" { + project_id = local.project_id + name = "terraform-manually-test" + cluster_type = "REPLICASET" + backup_enabled = true + replication_specs { - num_shards = 1 - regions_config { - region_name = "US_EAST_2" - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "US_EAST_1" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - - auto_scaling_disk_gb_enabled = false - mongo_db_major_version = "7.0" - - //Provider Settings "block" - provider_name = "AWS" - provider_instance_size_name = "M10" } # the following assumes an AWS provider is configured @@ -235,7 +220,7 @@ resource "aws_default_vpc" "default" { resource "mongodbatlas_network_peering" "mongo_peer" { accepter_region_name = "us-east-2" project_id = local.project_id - container_id = mongodbatlas_cluster.test.container_id + container_id = one(values(mongodbatlas_advanced_cluster.test.container_id)) provider_name = "AWS" route_table_cidr_block = "172.31.0.0/16" vpc_id = aws_default_vpc.default.id @@ -257,27 +242,23 @@ resource "aws_vpc_peering_connection_accepter" "aws_peer" { ```terraform # Create an Atlas cluster, this creates a container if one # does not yet exist for this GCP -resource "mongodbatlas_cluster" "test" { - project_id = local.project_id - name = "terraform-manually-test" +resource "mongodbatlas_advanced_cluster" "test" { + project_id = local.project_id + name = "terraform-manually-test" + cluster_type = "REPLICASET" + backup_enabled = true - cluster_type = "REPLICASET" replication_specs { - num_shards = 1 - regions_config { - region_name = "US_EAST_2" - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "GCP" + region_name = "US_EAST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - - auto_scaling_disk_gb_enabled = true - mongo_db_major_version = "7.0" - - //Provider Settings "block" - provider_name = "GCP" - provider_instance_size_name = "M10" } # Create the peering connection request @@ -285,7 +266,7 @@ resource "mongodbatlas_network_peering" "test" { project_id = local.project_id atlas_cidr_block = "192.168.0.0/18" - container_id = mongodbatlas_cluster.test.container_id + container_id = one(values(mongodbatlas_advanced_cluster.test.replication_specs[0].container_id)) provider_name = "GCP" gcp_project_id = local.GCP_PROJECT_ID network_name = "default" @@ -313,33 +294,29 @@ resource "google_compute_network_peering" "peering" { # Create an Atlas cluster, this creates a container if one # does not yet exist for this AZURE region -resource "mongodbatlas_cluster" "test" { - project_id = local.project_id - name = "cluster-azure" +resource "mongodbatlas_advanced_cluster" "test" { + project_id = local.project_id + name = "cluster-azure" + cluster_type = "REPLICASET" + backup_enabled = true - cluster_type = "REPLICASET" replication_specs { - num_shards = 1 - regions_config { - region_name = "US_EAST_2" - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AZURE" + region_name = "US_EAST_2" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - - auto_scaling_disk_gb_enabled = false - mongo_db_major_version = "7.0" - - //Provider Settings "block" - provider_name = "AZURE" - provider_instance_size_name = "M10" } # Create the peering connection request resource "mongodbatlas_network_peering" "test" { project_id = local.project_id - container_id = mongodbatlas_cluster.test.container_id + container_id = one(values(mongodbatlas_advanced_cluster.test.replication_specs[0].container_id)) provider_name = "AZURE" azure_directory_id = local.AZURE_DIRECTORY_ID azure_subscription_id = local.AZURE_SUBSCRIPTION_ID diff --git a/examples/mongodbatlas_api_key/create-and-assign-pak-together/versions.tf b/examples/mongodbatlas_api_key/create-and-assign-pak-together/versions.tf index 5a81a39da8..1888453805 100644 --- a/examples/mongodbatlas_api_key/create-and-assign-pak-together/versions.tf +++ b/examples/mongodbatlas_api_key/create-and-assign-pak-together/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { mongodbatlas = { source = "mongodb/mongodbatlas" - version = "~> 1.13.2" + version = "~> 1.0" } } required_version = ">= 1.0" diff --git a/examples/mongodbatlas_api_key/create-and-assign-pak/versions.tf b/examples/mongodbatlas_api_key/create-and-assign-pak/versions.tf index 5a81a39da8..1888453805 100644 --- a/examples/mongodbatlas_api_key/create-and-assign-pak/versions.tf +++ b/examples/mongodbatlas_api_key/create-and-assign-pak/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { mongodbatlas = { source = "mongodb/mongodbatlas" - version = "~> 1.13.2" + version = "~> 1.0" } } required_version = ">= 1.0" diff --git a/examples/mongodbatlas_api_key/create-api-key-assign-to-multiple-projects/versions.tf b/examples/mongodbatlas_api_key/create-api-key-assign-to-multiple-projects/versions.tf index 5a81a39da8..1888453805 100644 --- a/examples/mongodbatlas_api_key/create-api-key-assign-to-multiple-projects/versions.tf +++ b/examples/mongodbatlas_api_key/create-api-key-assign-to-multiple-projects/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { mongodbatlas = { source = "mongodb/mongodbatlas" - version = "~> 1.13.2" + version = "~> 1.0" } } required_version = ">= 1.0" diff --git a/examples/mongodbatlas_cloud_backup_snapshot_export_job/main.tf b/examples/mongodbatlas_cloud_backup_snapshot_export_job/main.tf index ec16baddb9..952daf02b9 100644 --- a/examples/mongodbatlas_cloud_backup_snapshot_export_job/main.tf +++ b/examples/mongodbatlas_cloud_backup_snapshot_export_job/main.tf @@ -22,20 +22,28 @@ resource "aws_s3_bucket" "test_bucket" { } } -resource "mongodbatlas_cluster" "my_cluster" { - project_id = var.project_id - name = "MyCluster" - disk_size_gb = 1 - - provider_name = "AWS" - provider_region_name = "US_EAST_1" - provider_instance_size_name = "M10" - cloud_backup = true +resource "mongodbatlas_advanced_cluster" "my_cluster" { + project_id = var.project_id + name = "MyCluster" + cluster_type = "REPLICASET" + backup_enabled = true + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "US_EAST_1" + electable_specs { + instance_size = "M10" + node_count = 3 + } + } + } } resource "mongodbatlas_cloud_backup_snapshot" "test" { project_id = var.project_id - cluster_name = mongodbatlas_cluster.my_cluster.name + cluster_name = mongodbatlas_advanced_cluster.my_cluster.name description = "myDescription" retention_in_days = 1 } @@ -50,7 +58,7 @@ resource "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" { resource "mongodbatlas_cloud_backup_snapshot_export_job" "test" { project_id = var.project_id - cluster_name = mongodbatlas_cluster.my_cluster.name + cluster_name = mongodbatlas_advanced_cluster.my_cluster.name snapshot_id = mongodbatlas_cloud_backup_snapshot.test.snapshot_id export_bucket_id = mongodbatlas_cloud_backup_snapshot_export_bucket.test.export_bucket_id diff --git a/examples/mongodbatlas_cloud_provider_snapshot_restore_job/point-in-time/main.tf b/examples/mongodbatlas_cloud_provider_snapshot_restore_job/point-in-time/main.tf index 7c518367ed..e146add173 100644 --- a/examples/mongodbatlas_cloud_provider_snapshot_restore_job/point-in-time/main.tf +++ b/examples/mongodbatlas_cloud_provider_snapshot_restore_job/point-in-time/main.tf @@ -5,23 +5,31 @@ resource "mongodbatlas_project" "project_test" { org_id = var.org_id } -resource "mongodbatlas_cluster" "cluster_test" { - project_id = mongodbatlas_project.project_test.id - name = var.cluster_name +resource "mongodbatlas_advanced_cluster" "cluster_test" { + project_id = mongodbatlas_project.project_test.id + name = var.cluster_name + cluster_type = "REPLICASET" - # Provider Settings "block" - provider_name = "AWS" - provider_region_name = "US_EAST_1" - provider_instance_size_name = "M10" - cloud_backup = true # enable cloud provider snapshots - pit_enabled = true - retain_backups_enabled = true # keep the backup snapshopts once the cluster is deleted -} + backup_enabled = true # enable cloud provider snapshots + pit_enabled = true + retain_backups_enabled = true # keep the backup snapshopts once the cluster is deleted + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "US_EAST_1" + electable_specs { + instance_size = "M10" + node_count = 3 + } + } + } +} resource "mongodbatlas_cloud_backup_snapshot" "test" { - project_id = mongodbatlas_cluster.cluster_test.project_id - cluster_name = mongodbatlas_cluster.cluster_test.name + project_id = mongodbatlas_advanced_cluster.cluster_test.project_id + cluster_name = mongodbatlas_advanced_cluster.cluster_test.name description = "My description" retention_in_days = "1" } @@ -34,8 +42,8 @@ resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { delivery_type_config { point_in_time = true - target_cluster_name = mongodbatlas_cluster.cluster_test.name - target_project_id = mongodbatlas_cluster.cluster_test.project_id + target_cluster_name = mongodbatlas_advanced_cluster.cluster_test.name + target_project_id = mongodbatlas_advanced_cluster.cluster_test.project_id point_in_time_utc_seconds = var.point_in_time_utc_seconds } } diff --git a/examples/mongodbatlas_database_user/atlas_cluster.tf b/examples/mongodbatlas_database_user/atlas_cluster.tf index 75ad5ba2a0..985cc4462c 100644 --- a/examples/mongodbatlas_database_user/atlas_cluster.tf +++ b/examples/mongodbatlas_database_user/atlas_cluster.tf @@ -1,24 +1,22 @@ -resource "mongodbatlas_cluster" "cluster" { - project_id = mongodbatlas_project.project1.id - name = "MongoDB_Atlas" - mongo_db_major_version = "7.0" - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "cluster" { + project_id = mongodbatlas_project.project1.id + name = "MongoDB_Atlas" + cluster_type = "REPLICASET" + backup_enabled = true + replication_specs { - num_shards = 1 - regions_config { - region_name = var.region - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AWS" + region_name = var.region + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - # Provider Settings "block" - cloud_backup = true - auto_scaling_disk_gb_enabled = true - provider_name = "AWS" - disk_size_gb = 10 - provider_instance_size_name = "M10" } + output "atlasclusterstring" { - value = mongodbatlas_cluster.cluster.connection_strings + value = mongodbatlas_advanced_cluster.cluster.connection_strings } diff --git a/examples/mongodbatlas_database_user/main.tf b/examples/mongodbatlas_database_user/main.tf index c685f0c7c1..5ee8b13f6a 100644 --- a/examples/mongodbatlas_database_user/main.tf +++ b/examples/mongodbatlas_database_user/main.tf @@ -15,7 +15,7 @@ resource "mongodbatlas_database_user" "user1" { } scopes { - name = mongodbatlas_cluster.cluster.name + name = mongodbatlas_advanced_cluster.cluster.name type = "CLUSTER" } } diff --git a/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster/README.md b/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster/README.md index 01b3fc0988..f3c104f821 100644 --- a/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster/README.md +++ b/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster/README.md @@ -70,15 +70,15 @@ terraform destroy 1. Import the cluster using the Project ID and cluster name (e.g. `5beae24579358e0ae95492af-MyCluster`): - $ terraform import mongodbatlas_cluster.my_cluster ProjectId-ClusterName + $ terraform import mongodbatlas_advanced_cluster.cluster ProjectId-ClusterName -2. Add any non-default values to the cluster resource *mongodbatlas_cluster.my_cluster* in *main.tf*. And add the following attribute: `encryption_at_rest_provider = "AWS"` +2. Add any non-default values to the cluster resource *mongodbatlas_advanced_cluster.cluster* in *main.tf*. And add the following attribute: `encryption_at_rest_provider = "AWS"` 3. Run terraform apply to enable encryption at rest for the cluster: `terraform apply` 4. (Optional) To remove the cluster from TF state, in case you want to disable project-level encryption and delete the role and key without deleting the imported cluster: - 1. First disable encryption on the cluster by changing the attribute `encryption_at_rest_provider = "NONE"` for the cluster resource *mongodbatlas_cluster.my_cluster* in *main.tf*. If you skip this and the next step, you won't be able to disable encryption on the project-level + 1. First disable encryption on the cluster by changing the attribute `encryption_at_rest_provider = "NONE"` for the cluster resource *mongodbatlas_advanced_cluster.cluster* in *main.tf*. If you skip this and the next step, you won't be able to disable encryption on the project-level 2. Run terraform apply to disable encryption for the cluster: `terraform apply` 3. Finally, remove the cluster from TF state: - terraform state rm mongodbatlas_cluster.my_cluster + terraform state rm mongodbatlas_advanced_cluster.cluster 4. You should now be able to run terraform destroy without deleting the cluster: `terraform destroy` diff --git a/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster/main.tf b/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster/main.tf index c4fb0b4e7b..fb4b6d9826 100644 --- a/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster/main.tf +++ b/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster/main.tf @@ -23,13 +23,22 @@ resource "mongodbatlas_encryption_at_rest" "test" { } } -resource "mongodbatlas_cluster" "cluster" { +resource "mongodbatlas_advanced_cluster" "cluster" { project_id = var.atlas_project_id name = "MyCluster" cluster_type = "REPLICASET" - provider_name = "AWS" + backup_enabled = true encryption_at_rest_provider = "AWS" - backing_provider_name = "AWS" - provider_region_name = "US_EAST_1" - provider_instance_size_name = "M10" + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "US_EAST_1" + electable_specs { + instance_size = "M10" + node_count = 3 + } + } + } } diff --git a/examples/mongodbatlas_federated_settings_identity_provider/azure/atlas.tf b/examples/mongodbatlas_federated_settings_identity_provider/azure/atlas.tf index 575ba671cd..42a890c75e 100644 --- a/examples/mongodbatlas_federated_settings_identity_provider/azure/atlas.tf +++ b/examples/mongodbatlas_federated_settings_identity_provider/azure/atlas.tf @@ -1,5 +1,5 @@ locals { - mongodb_uri = mongodbatlas_cluster.this.connection_strings[0].standard + mongodb_uri = mongodbatlas_advanced_cluster.this.connection_strings[0].standard } data "mongodbatlas_federated_settings" "this" { @@ -16,25 +16,22 @@ resource "mongodbatlas_project_ip_access_list" "mongo-access" { cidr_block = "0.0.0.0/0" } -resource "mongodbatlas_cluster" "this" { - project_id = mongodbatlas_project.this.id - name = var.project_name - mongo_db_major_version = "7.0" - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "this" { + project_id = mongodbatlas_project.this.id + name = var.project_name + cluster_type = "REPLICASET" + replication_specs { - num_shards = 1 - regions_config { - region_name = var.region - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AWS" + region_name = var.region + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - cloud_backup = false - auto_scaling_disk_gb_enabled = false - provider_name = "AWS" - disk_size_gb = 10 - provider_instance_size_name = "M10" } resource "mongodbatlas_federated_settings_identity_provider" "oidc" { diff --git a/examples/mongodbatlas_federated_settings_identity_provider/azure/outputs.tf b/examples/mongodbatlas_federated_settings_identity_provider/azure/outputs.tf index 57cdf85701..04d4a84209 100644 --- a/examples/mongodbatlas_federated_settings_identity_provider/azure/outputs.tf +++ b/examples/mongodbatlas_federated_settings_identity_provider/azure/outputs.tf @@ -9,7 +9,7 @@ output "ssh_connection_string" { } output "user_test_conn_string" { - value = "mongodb+srv://${local.test_user_username}:${local.test_user_password}@${replace(mongodbatlas_cluster.this.srv_address, "mongodb+srv://", "")}/?retryWrites=true" + value = "mongodb+srv://${local.test_user_username}:${local.test_user_password}@${replace(mongodbatlas_advanced_cluster.this.connection_strings[0].standard_srv, "mongodb+srv://", "")}/?retryWrites=true" sensitive = true description = "Useful for connecting to the database from Compass or other tool to validate data" } diff --git a/examples/mongodbatlas_network_peering/aws/main.tf b/examples/mongodbatlas_network_peering/aws/main.tf index 7c1b945b80..28da1d5cda 100644 --- a/examples/mongodbatlas_network_peering/aws/main.tf +++ b/examples/mongodbatlas_network_peering/aws/main.tf @@ -8,27 +8,23 @@ resource "mongodbatlas_project" "aws_atlas" { org_id = var.atlas_org_id } -resource "mongodbatlas_cluster" "cluster-atlas" { - project_id = mongodbatlas_project.aws_atlas.id - name = "cluster-atlas" - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "cluster-atlas" { + project_id = mongodbatlas_project.aws_atlas.id + name = "cluster-atlas" + cluster_type = "REPLICASET" + backup_enabled = true + replication_specs { - num_shards = 1 - regions_config { - region_name = var.atlas_region - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AWS" + region_name = var.atlas_region + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - cloud_backup = true - auto_scaling_disk_gb_enabled = true - mongo_db_major_version = "7.0" - - # Provider Settings "block" - provider_name = "AWS" - disk_size_gb = 10 - provider_instance_size_name = "M10" } resource "mongodbatlas_database_user" "db-user" { @@ -46,7 +42,7 @@ resource "mongodbatlas_database_user" "db-user" { resource "mongodbatlas_network_peering" "aws-atlas" { accepter_region_name = var.aws_region project_id = mongodbatlas_project.aws_atlas.id - container_id = mongodbatlas_cluster.cluster-atlas.container_id + container_id = one(values(mongodbatlas_advanced_cluster.cluster-atlas.replication_specs[0].container_id)) provider_name = "AWS" route_table_cidr_block = aws_vpc.primary.cidr_block vpc_id = aws_vpc.primary.id diff --git a/examples/mongodbatlas_network_peering/azure/atlas.tf b/examples/mongodbatlas_network_peering/azure/atlas.tf index 4cfe740422..5485899bcf 100644 --- a/examples/mongodbatlas_network_peering/azure/atlas.tf +++ b/examples/mongodbatlas_network_peering/azure/atlas.tf @@ -3,34 +3,31 @@ provider "mongodbatlas" { public_key = var.public_key private_key = var.private_key } + # Create the mongodb atlas Azure cluster -resource "mongodbatlas_cluster" "azure-cluster" { - project_id = var.project_id - name = var.name - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "azure-cluster" { + project_id = var.project_id + name = var.name + cluster_type = "REPLICASET" + backup_enabled = true + replication_specs { - num_shards = 1 - regions_config { - region_name = var.provider_region_name - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AZURE" + region_name = var.provider_region_name + electable_specs { + instance_size = var.provider_instance_size_name + node_count = 3 + } } } - backup_enabled = false - auto_scaling_disk_gb_enabled = true - mongo_db_major_version = "7.0" - - # Provider settings block in this case it is Azure - provider_name = "AZURE" - provider_disk_type_name = var.provider_disk_type_name - provider_instance_size_name = var.provider_instance_size_name } # Create the peering connection request resource "mongodbatlas_network_peering" "test" { project_id = var.project_id - container_id = mongodbatlas_cluster.azure-cluster.container_id + container_id = one(values(mongodbatlas_advanced_cluster.azure-cluster.replication_specs[0].container_id)) provider_name = "AZURE" azure_directory_id = data.azurerm_client_config.current.tenant_id azure_subscription_id = data.azurerm_client_config.current.subscription_id diff --git a/examples/mongodbatlas_network_peering/azure/variables.tf b/examples/mongodbatlas_network_peering/azure/variables.tf index 998e4db4c2..cffaacb7e2 100644 --- a/examples/mongodbatlas_network_peering/azure/variables.tf +++ b/examples/mongodbatlas_network_peering/azure/variables.tf @@ -10,9 +10,6 @@ variable "project_id" { variable "provider_instance_size_name" { type = string } -variable "provider_disk_type_name" { - type = string -} variable "resource_group_name" { type = string } diff --git a/examples/mongodbatlas_network_peering/gcp/cluster.tf b/examples/mongodbatlas_network_peering/gcp/cluster.tf index a3683eebca..b8e1d9ebe1 100644 --- a/examples/mongodbatlas_network_peering/gcp/cluster.tf +++ b/examples/mongodbatlas_network_peering/gcp/cluster.tf @@ -1,45 +1,45 @@ # This cluster is in GCP cloud-provider with VPC peering enabled -resource "mongodbatlas_cluster" "cluster" { - project_id = var.project_id - name = "cluster-test" - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "cluster" { + project_id = var.project_id + name = "cluster-test" + cluster_type = "REPLICASET" + backup_enabled = true # enable cloud provider snapshots + replication_specs { - num_shards = 1 - regions_config { - region_name = var.atlas_region - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "GCP" + region_name = var.atlas_region + electable_specs { + instance_size = "M10" + node_count = 3 + } + auto_scaling { + compute_enabled = true + compute_scale_down_enabled = true + compute_min_instance_size = "M10" + compute_max_instance_size = "M20" + disk_gb_enabled = true + } } } - labels { + tags { key = "environment" value = "prod" } - cloud_backup = true - auto_scaling_disk_gb_enabled = true - mongo_db_major_version = "7.0" - auto_scaling_compute_enabled = true - auto_scaling_compute_scale_down_enabled = true - - - # Provider Settings "block" - provider_name = "GCP" - provider_instance_size_name = "M10" - provider_auto_scaling_compute_max_instance_size = "M20" - provider_auto_scaling_compute_min_instance_size = "M10" - disk_size_gb = 40 advanced_configuration { minimum_enabled_tls_protocol = "TLS1_2" } + lifecycle { ignore_changes = [ - provider_instance_size_name + replication_specs[0].region_configs[0].electable_specs[0].instance_size, ] } } + # The connection strings available for the GCP MognoDB Atlas cluster output "connection_string" { - value = mongodbatlas_cluster.cluster.connection_strings + value = mongodbatlas_advanced_cluster.cluster.connection_strings } diff --git a/examples/mongodbatlas_online_archive/main.tf b/examples/mongodbatlas_online_archive/main.tf index bb3d21bad2..ebb9eb8cdc 100644 --- a/examples/mongodbatlas_online_archive/main.tf +++ b/examples/mongodbatlas_online_archive/main.tf @@ -31,15 +31,22 @@ resource "mongodbatlas_online_archive" "users_archive" { } } -# tflint-ignore: terraform_unused_declarations data "mongodbatlas_online_archive" "read_archive" { project_id = mongodbatlas_online_archive.users_archive.project_id cluster_name = mongodbatlas_online_archive.users_archive.cluster_name archive_id = mongodbatlas_online_archive.users_archive.archive_id } -# tflint-ignore: terraform_unused_declarations data "mongodbatlas_online_archives" "all" { project_id = mongodbatlas_online_archive.users_archive.project_id cluster_name = mongodbatlas_online_archive.users_archive.cluster_name } + +output "online_archive_state" { + value = data.mongodbatlas_online_archive.read_archive.state +} + +output "online_archives_results" { + value = data.mongodbatlas_online_archives.all.results +} + diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/cluster/README.md b/examples/mongodbatlas_privatelink_endpoint/aws/cluster/README.md index 4f2402e7c0..eb703bcc3e 100644 --- a/examples/mongodbatlas_privatelink_endpoint/aws/cluster/README.md +++ b/examples/mongodbatlas_privatelink_endpoint/aws/cluster/README.md @@ -83,7 +83,7 @@ $ terraform destroy 2. `mongodbatlas_privatelink_endpoint` is dependent on the `mongodbatlas_project` 3. `aws_vpc_endpoint` is dependent on the `mongodbatlas_privatelink_endpoint`, and its dependencies. 4. `mongodbatlas_privatelink_endpoint_service` is dependent on `aws_vpc_endpoint` and its dependencies. -5. `mongodbatlas_cluster` is dependent only on the `mongodbatlas_project`, howerver; its `connection_strings` are sourced from the `mongodbatlas_privatelink_endpoint_service`. `mongodbatlas_privatelink_endpoint_service` has explicitly been added to the `mongodbatlas_cluster` `depends_on` to ensure the private connection strings are correct following `terraform apply`. +5. `mongodbatlas_advanced_cluster` is dependent only on the `mongodbatlas_project`, howerver; its `connection_strings` are sourced from the `mongodbatlas_privatelink_endpoint_service`. `mongodbatlas_privatelink_endpoint_service` has explicitly been added to the `mongodbatlas_advanced_cluster` `depends_on` to ensure the private connection strings are correct following `terraform apply`. **Important Point** @@ -123,7 +123,7 @@ Cluster `connection_strings` is a list of maps matching the signature below. `aw In order to output the `private_endpoint.#.srv_connection_string` for the `aws_vpc_endpoint`, utilize locals such as the [following](output.tf): ``` locals { - private_endpoints = flatten([for cs in mongodbatlas_cluster.aws_private_connection.connection_strings : cs.private_endpoint]) + private_endpoints = flatten([for cs in mongodbatlas_advanced_cluster.aws_private_connection.connection_strings : cs.private_endpoint]) connection_strings = [ for pe in local.private_endpoints : pe.srv_connection_string diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/cluster/atlas-cluster.tf b/examples/mongodbatlas_privatelink_endpoint/aws/cluster/atlas-cluster.tf index 4bf9bd3384..38e08232b1 100644 --- a/examples/mongodbatlas_privatelink_endpoint/aws/cluster/atlas-cluster.tf +++ b/examples/mongodbatlas_privatelink_endpoint/aws/cluster/atlas-cluster.tf @@ -1,23 +1,19 @@ -resource "mongodbatlas_cluster" "aws_private_connection" { - project_id = var.project_id - name = var.cluster_name - cloud_backup = true - auto_scaling_disk_gb_enabled = true - mongo_db_major_version = "7.0" - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "aws_private_connection" { + project_id = var.project_id + name = var.cluster_name + cluster_type = "REPLICASET" + backup_enabled = true + replication_specs { - num_shards = 1 - regions_config { - region_name = "US_EAST_1" - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "US_EAST_1" + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - # Provider settings - provider_name = "AWS" - disk_size_gb = 10 - provider_instance_size_name = "M10" - depends_on = [mongodbatlas_privatelink_endpoint_service.pe_east_service] } diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/cluster/output.tf b/examples/mongodbatlas_privatelink_endpoint/aws/cluster/output.tf index 45294b427f..28ce135c8d 100644 --- a/examples/mongodbatlas_privatelink_endpoint/aws/cluster/output.tf +++ b/examples/mongodbatlas_privatelink_endpoint/aws/cluster/output.tf @@ -1,5 +1,5 @@ locals { - private_endpoints = flatten([for cs in mongodbatlas_cluster.aws_private_connection.connection_strings : cs.private_endpoint]) + private_endpoints = flatten([for cs in mongodbatlas_advanced_cluster.aws_private_connection.connection_strings : cs.private_endpoint]) connection_strings = [ for pe in local.private_endpoints : pe.srv_connection_string diff --git a/examples/mongodbatlas_privatelink_endpoint/azure/main.tf b/examples/mongodbatlas_privatelink_endpoint/azure/main.tf index 6ccf44be28..f94d8046cd 100644 --- a/examples/mongodbatlas_privatelink_endpoint/azure/main.tf +++ b/examples/mongodbatlas_privatelink_endpoint/azure/main.tf @@ -19,12 +19,12 @@ resource "azurerm_virtual_network" "test" { } resource "azurerm_subnet" "test" { - name = "testsubnet" - resource_group_name = var.resource_group_name - virtual_network_name = azurerm_virtual_network.test.name - address_prefixes = ["10.0.1.0/24"] - enforce_private_link_service_network_policies = true - enforce_private_link_endpoint_network_policies = true + name = "testsubnet" + resource_group_name = var.resource_group_name + virtual_network_name = azurerm_virtual_network.test.name + address_prefixes = ["10.0.1.0/24"] + private_link_service_network_policies_enabled = true + private_endpoint_network_policies_enabled = true } resource "mongodbatlas_privatelink_endpoint" "test" { diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf index 2c683de23d..d40e580bc5 100644 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf +++ b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf @@ -19,12 +19,12 @@ resource "azurerm_virtual_network" "test" { } resource "azurerm_subnet" "test" { - name = "testsubnet" - resource_group_name = var.resource_group_name - virtual_network_name = azurerm_virtual_network.test.name - address_prefixes = ["10.0.1.0/24"] - enforce_private_link_service_network_policies = true - enforce_private_link_endpoint_network_policies = true + name = "testsubnet" + resource_group_name = var.resource_group_name + virtual_network_name = azurerm_virtual_network.test.name + address_prefixes = ["10.0.1.0/24"] + private_link_service_network_policies_enabled = true + private_endpoint_network_policies_enabled = true } resource "mongodbatlas_privatelink_endpoint_serverless" "test" { diff --git a/examples/mongodbatlas_search_deployment/versions.tf b/examples/mongodbatlas_search_deployment/versions.tf index 7cac4906f0..1888453805 100644 --- a/examples/mongodbatlas_search_deployment/versions.tf +++ b/examples/mongodbatlas_search_deployment/versions.tf @@ -2,8 +2,8 @@ terraform { required_providers { mongodbatlas = { source = "mongodb/mongodbatlas" - version = "~> 1.13" + version = "~> 1.0" } } required_version = ">= 1.0" -} \ No newline at end of file +} diff --git a/examples/mongodbatlas_third_party_integration/prometheus-and-teams/third-party-integration.tf b/examples/mongodbatlas_third_party_integration/prometheus-and-teams/third-party-integration.tf index 2c624722eb..8236cd0f5e 100644 --- a/examples/mongodbatlas_third_party_integration/prometheus-and-teams/third-party-integration.tf +++ b/examples/mongodbatlas_third_party_integration/prometheus-and-teams/third-party-integration.tf @@ -10,7 +10,6 @@ resource "mongodbatlas_third_party_integration" "test_prometheus" { user_name = var.user_name password = var.password service_discovery = "file" - scheme = "https" enabled = true } diff --git a/examples/starter/Readme.md b/examples/starter/Readme.md index b145aec076..e855faa776 100644 --- a/examples/starter/Readme.md +++ b/examples/starter/Readme.md @@ -75,7 +75,7 @@ Or to fetch the connection string using terraform follow the below steps: ```hcl output "atlasclusterstring" { - value = mongodbatlas_cluster.cluster.connection_strings + value = mongodbatlas_advanced_cluster.cluster.connection_strings } ``` **Outputs:** @@ -100,7 +100,7 @@ To fetch a particular connection string, use the **lookup()** function of terraf ``` output "plstring" { - value = lookup(mongodbatlas_cluster.cluster.connection_strings[0].aws_private_link_srv, aws_vpc_endpoint.ptfe_service.id) + value = lookup(mongodbatlas_advanced_cluster.cluster.connection_strings[0].aws_private_link_srv, aws_vpc_endpoint.ptfe_service.id) } ``` **Output:** diff --git a/examples/starter/atlas_cluster.tf b/examples/starter/atlas_cluster.tf index f07552a47c..18fff374e6 100644 --- a/examples/starter/atlas_cluster.tf +++ b/examples/starter/atlas_cluster.tf @@ -1,24 +1,23 @@ -resource "mongodbatlas_cluster" "cluster" { - project_id = mongodbatlas_project.project.id - name = var.cluster_name - mongo_db_major_version = var.mongodbversion - cluster_type = "REPLICASET" +resource "mongodbatlas_advanced_cluster" "cluster" { + project_id = mongodbatlas_project.project.id + name = var.cluster_name + cluster_type = "REPLICASET" + backup_enabled = true + replication_specs { - num_shards = 1 - regions_config { - region_name = var.region - electable_nodes = 3 - priority = 7 - read_only_nodes = 0 + region_configs { + priority = 7 + provider_name = var.cloud_provider + region_name = var.region + electable_specs { + instance_size = "M10" + node_count = 3 + } } } - # Provider Settings "block" - cloud_backup = true - auto_scaling_disk_gb_enabled = true - provider_name = var.cloud_provider - provider_instance_size_name = "M10" } + output "connection_strings" { - value = mongodbatlas_cluster.cluster.connection_strings[0].standard_srv + value = mongodbatlas_advanced_cluster.cluster.connection_strings[0].standard_srv } diff --git a/examples/starter/variables.tf b/examples/starter/variables.tf index 4307ced129..2072e854be 100644 --- a/examples/starter/variables.tf +++ b/examples/starter/variables.tf @@ -26,10 +26,6 @@ variable "region" { type = string description = "MongoDB Atlas Cluster Region, must be a region for the provider given" } -variable "mongodbversion" { - type = string - description = "The Major MongoDB Version" -} variable "dbuser" { type = string description = "MongoDB Atlas Database User Name" diff --git a/scripts/tf-validate.sh b/scripts/tf-validate.sh index d97035651a..9d6c1ffa05 100755 --- a/scripts/tf-validate.sh +++ b/scripts/tf-validate.sh @@ -16,29 +16,30 @@ set -Eeou pipefail -arch_name=$(uname -m) +# Delete Terraform execution files so the script can be run multiple times +find ./examples -type d -name ".terraform" -exec rm -rf {} + +find ./examples -type f -name ".terraform.lock.hcl" -exec rm -f {} + + +export TF_CLI_CONFIG_FILE="$PWD/bin-examples/tf-validate.tfrc" + +# Use local provider to validate examples +go build -o bin-examples/terraform-provider-mongodbatlas . + +cat << EOF > "$TF_CLI_CONFIG_FILE" +provider_installation { + dev_overrides { + "mongodb/mongodbatlas" = "$PWD/bin-examples" + } + direct {} +} +EOF for DIR in $(find ./examples -type f -name '*.tf' -exec dirname {} \; | sort -u); do [ ! -d "$DIR" ] && continue - - - # Skip directories with "v08" or "v09" in their name for ARM64 - if [[ "$arch_name" == "arm64" ]] && echo "$DIR" | grep -qE "v08|v09"; then - echo "Skip directories with \"v08\" or \"v09\" in their name for ARM64" - echo "TF provider does not have a package available for ARM64 for version < 1.0" - echo "Skipping directory: $DIR" - continue - fi - pushd "$DIR" - - echo; echo -e "\e[1;35m===> Initializing Example: $DIR <===\e[0m"; echo - terraform init - - echo; echo -e "\e[1;35m===> Format Checking Example: $DIR <===\e[0m"; echo + echo; echo -e "\e[1;35m===> Example: $DIR <===\e[0m"; echo + terraform init > /dev/null # supress output as it's very verbose terraform fmt -check -recursive - - echo; echo -e "\e[1;35m===> Validating Example: $DIR <===\e[0m"; echo terraform validate popd done diff --git a/scripts/tflint.sh b/scripts/tflint.sh deleted file mode 100755 index 9f404abac0..0000000000 --- a/scripts/tflint.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2021 MongoDB Inc -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -Eeou pipefail - -for DIR in $(find ./examples -type f -name '*.tf' -exec dirname {} \; | sort -u); do - [ ! -d "$DIR" ] && continue - - pushd "$DIR" - - echo; echo -e "\e[1;35m===> Validating Syntax Example: $DIR <===\e[0m"; echo - # Terraform syntax checks - tflint \ - --enable-rule=terraform_deprecated_interpolation \ - --enable-rule=terraform_deprecated_index \ - --enable-rule=terraform_unused_declarations \ - --enable-rule=terraform_comment_syntax \ - --enable-rule=terraform_required_version \ - --minimum-failure-severity=warning - popd -done