From 9ca4c5db054cf2d2f3e28c9f26d378ad50f31921 Mon Sep 17 00:00:00 2001 From: Oriol Arbusi Date: Mon, 28 Oct 2024 17:49:05 +0100 Subject: [PATCH 01/17] wip: docs and example (missing data source --- docs/resources/flex_cluster.md | 84 +++++++++++++++++++ examples/mongodbatlas_flex_cluster/README.md | 0 examples/mongodbatlas_flex_cluster/main.tf | 11 +++ .../mongodbatlas_flex_cluster/provider.tf | 4 + .../mongodbatlas_flex_cluster/variables.tf | 12 +++ .../mongodbatlas_flex_cluster/versions.tf | 9 ++ templates/resources.md.tmpl | 2 - templates/resources/flex_cluster.md.tmpl | 21 +++++ 8 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 docs/resources/flex_cluster.md create mode 100644 examples/mongodbatlas_flex_cluster/README.md create mode 100644 examples/mongodbatlas_flex_cluster/main.tf create mode 100644 examples/mongodbatlas_flex_cluster/provider.tf create mode 100644 examples/mongodbatlas_flex_cluster/variables.tf create mode 100644 examples/mongodbatlas_flex_cluster/versions.tf create mode 100644 templates/resources/flex_cluster.md.tmpl diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md new file mode 100644 index 0000000000..2d9567d7ef --- /dev/null +++ b/docs/resources/flex_cluster.md @@ -0,0 +1,84 @@ +# Resource: mongodbatlas_flex_cluster + +`mongodbatlas_flex_cluster` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster. + +-> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: +1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). +2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. + +## Example Usages + +```terraform +resource "mongodbatlas_flex_cluster" "flex_cluster" { + project_id = var.project_id + name = "clusterName" + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} +``` + + +## Schema + +### Required + +- `name` (String) Human-readable label that identifies the instance. +- `project_id` (String) Unique 24-hexadecimal character string that identifies the project. +- `provider_settings` (Attributes) Group of cloud provider settings that configure the provisioned MongoDB flex cluster. (see [below for nested schema](#nestedatt--provider_settings)) + +### Optional + +- `tags` (Map of String) Map that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the instance. +- `termination_protection_enabled` (Boolean) Flag that indicates whether termination protection is enabled on the cluster. If set to `true`, MongoDB Cloud won't delete the cluster. If set to `false`, MongoDB Cloud will delete the cluster. + +### Read-Only + +- `backup_settings` (Attributes) Flex backup configuration (see [below for nested schema](#nestedatt--backup_settings)) +- `cluster_type` (String) Flex cluster topology. +- `connection_strings` (Attributes) Collection of Uniform Resource Locators that point to the MongoDB database. (see [below for nested schema](#nestedatt--connection_strings)) +- `create_date` (String) Date and time when MongoDB Cloud created this instance. This parameter expresses its value in ISO 8601 format in UTC. +- `id` (String) Unique 24-hexadecimal digit string that identifies the instance. +- `mongo_db_version` (String) Version of MongoDB that the instance runs. +- `state_name` (String) Human-readable label that indicates the current operating condition of this instance. +- `version_release_system` (String) Method by which the cluster maintains the MongoDB versions. + + +### Nested Schema for `provider_settings` + +Required: + +- `backing_provider_name` (String) Cloud service provider on which MongoDB Cloud provisioned the flex cluster. +- `region_name` (String) Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/). + +Read-Only: + +- `disk_size_gb` (Number) Storage capacity available to the flex cluster expressed in gigabytes. +- `provider_name` (String) Human-readable label that identifies the cloud service provider. + + + +### Nested Schema for `backup_settings` + +Read-Only: + +- `enabled` (Boolean) Flag that indicates whether backups are performed for this flex cluster. Backup uses [TODO](TODO) for flex clusters. + + + +### Nested Schema for `connection_strings` + +Read-Only: + +- `standard` (String) Public connection string that you can use to connect to this cluster. This connection string uses the mongodb:// protocol. +- `standard_srv` (String) Public connection string that you can use to connect to this flex cluster. This connection string uses the `mongodb+srv://` protocol. + +# Import +Flex Cluster resource can be imported using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`, e.g. +``` +$ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClsuterName +``` + +For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/createFlexcluster) Documentation. diff --git a/examples/mongodbatlas_flex_cluster/README.md b/examples/mongodbatlas_flex_cluster/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/mongodbatlas_flex_cluster/main.tf b/examples/mongodbatlas_flex_cluster/main.tf new file mode 100644 index 0000000000..5138e700a6 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -0,0 +1,11 @@ +resource "mongodbatlas_flex_cluster" "flex_cluster" { + project_id = var.project_id + name = "clusterName" + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +# TODO: add plural and singular data source example \ No newline at end of file diff --git a/examples/mongodbatlas_flex_cluster/provider.tf b/examples/mongodbatlas_flex_cluster/provider.tf new file mode 100644 index 0000000000..e5aeda8033 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/provider.tf @@ -0,0 +1,4 @@ +provider "mongodbatlas" { + public_key = var.public_key + private_key = var.private_key +} \ No newline at end of file diff --git a/examples/mongodbatlas_flex_cluster/variables.tf b/examples/mongodbatlas_flex_cluster/variables.tf new file mode 100644 index 0000000000..c8ac7d8475 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/variables.tf @@ -0,0 +1,12 @@ +variable "public_key" { + description = "Public API key to authenticate to Atlas" + type = string +} +variable "private_key" { + description = "Private API key to authenticate to Atlas" + type = string +} +variable "project_id" { + description = "Atlas Project ID" + type = string +} \ No newline at end of file diff --git a/examples/mongodbatlas_flex_cluster/versions.tf b/examples/mongodbatlas_flex_cluster/versions.tf new file mode 100644 index 0000000000..f4f37e1912 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + mongodbatlas = { + source = "mongodb/mongodbatlas" + version = "~> 1.22" + } + } + required_version = ">= 1.0" +} diff --git a/templates/resources.md.tmpl b/templates/resources.md.tmpl index 08d4985761..ed9ba98760 100644 --- a/templates/resources.md.tmpl +++ b/templates/resources.md.tmpl @@ -56,9 +56,7 @@ {{ else if eq .Name "mongodbatlas_ldap_verify" }} {{ else if eq .Name "mongodbatlas_third_party_integration" }} {{ else if eq .Name "mongodbatlas_x509_authentication_database_user" }} - {{ else if eq .Name "mongodbatlas_stream_processor" }} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_service_data_federation_online_archive" }} - {{ else if eq .Name "mongodbatlas_flex_cluster" }} {{ else }} {{ tffile (printf "examples/%s/main.tf" .Name )}} {{ end }} diff --git a/templates/resources/flex_cluster.md.tmpl b/templates/resources/flex_cluster.md.tmpl new file mode 100644 index 0000000000..e9f0a506e8 --- /dev/null +++ b/templates/resources/flex_cluster.md.tmpl @@ -0,0 +1,21 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster. + +-> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: +1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). +2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. + +## Example Usages + +{{ tffile (printf "examples/%s/main.tf" .Name )}} + +{{ .SchemaMarkdown | trimspace }} + +# Import +Flex Cluster resource can be imported using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`, e.g. +``` +$ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClsuterName +``` + +For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/createFlexcluster) Documentation. From b84089a15b3291dd9f83e8bbc656d4f093f7fb85 Mon Sep 17 00:00:00 2001 From: Oriol Arbusi Date: Mon, 28 Oct 2024 18:14:56 +0100 Subject: [PATCH 02/17] change version to make the CI check successful --- examples/mongodbatlas_flex_cluster/versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mongodbatlas_flex_cluster/versions.tf b/examples/mongodbatlas_flex_cluster/versions.tf index f4f37e1912..3faf38df1a 100644 --- a/examples/mongodbatlas_flex_cluster/versions.tf +++ b/examples/mongodbatlas_flex_cluster/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { mongodbatlas = { source = "mongodb/mongodbatlas" - version = "~> 1.22" + version = "~> 1.21.3" } } required_version = ">= 1.0" From 0f1dbc753d3d580ca23fee2aaa9955e6a7b88f01 Mon Sep 17 00:00:00 2001 From: Oriol Arbusi Date: Mon, 28 Oct 2024 18:34:31 +0100 Subject: [PATCH 03/17] fmt --- examples/mongodbatlas_flex_cluster/main.tf | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/mongodbatlas_flex_cluster/main.tf b/examples/mongodbatlas_flex_cluster/main.tf index 5138e700a6..1ea8019726 100644 --- a/examples/mongodbatlas_flex_cluster/main.tf +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -1,11 +1,9 @@ resource "mongodbatlas_flex_cluster" "flex_cluster" { - project_id = var.project_id - name = "clusterName" - provider_settings = { - backing_provider_name = "AWS" - region_name = "US_EAST_1" - } - termination_protection_enabled = true -} - -# TODO: add plural and singular data source example \ No newline at end of file + project_id = var.project_id + name = "clusterName" + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} # TODO: add plural and singular data source example From 0bfa6837547a734549c087d2eb8e4879a12219aa Mon Sep 17 00:00:00 2001 From: Oriol Arbusi Date: Tue, 29 Oct 2024 09:43:23 +0100 Subject: [PATCH 04/17] regenerate --- docs/resources/flex_cluster.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md index 2d9567d7ef..13e32d7715 100644 --- a/docs/resources/flex_cluster.md +++ b/docs/resources/flex_cluster.md @@ -10,14 +10,14 @@ ```terraform resource "mongodbatlas_flex_cluster" "flex_cluster" { - project_id = var.project_id - name = "clusterName" - provider_settings = { - backing_provider_name = "AWS" - region_name = "US_EAST_1" - } - termination_protection_enabled = true -} + project_id = var.project_id + name = "clusterName" + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} # TODO: add plural and singular data source example ``` From a233dd30404f9c61d6e38b6b4b41886cae5c5d4e Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Mon, 4 Nov 2024 12:31:11 +0000 Subject: [PATCH 05/17] data source examples --- examples/mongodbatlas_flex_cluster/main.tf | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/mongodbatlas_flex_cluster/main.tf b/examples/mongodbatlas_flex_cluster/main.tf index 1ea8019726..1ea8645d97 100644 --- a/examples/mongodbatlas_flex_cluster/main.tf +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -6,4 +6,14 @@ resource "mongodbatlas_flex_cluster" "flex_cluster" { region_name = "US_EAST_1" } termination_protection_enabled = true -} # TODO: add plural and singular data source example +} + +data "mongodbatlas_flex_cluster" "flex_cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.flex_cluster.name +} + +data "mongodbatlas_flex_clusters" "flex_cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.flex_cluster.name +} From 3a4a03002dadad90c43ee4c49156d70bdf4ca206 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Mon, 4 Nov 2024 12:31:48 +0000 Subject: [PATCH 06/17] readme created - to adjust preview feature note on release of flex to prod --- examples/mongodbatlas_flex_cluster/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/mongodbatlas_flex_cluster/README.md b/examples/mongodbatlas_flex_cluster/README.md index e69de29bb2..09ad2147c1 100644 --- a/examples/mongodbatlas_flex_cluster/README.md +++ b/examples/mongodbatlas_flex_cluster/README.md @@ -0,0 +1,12 @@ +# MongoDB Atlas Provider -- Atlas Flex Cluster +This example creates one flex cluster in a project. + +**NOTE**: Flex Clusters are currently in Private Preview. To use this feature, you must take the following actions: +1. Enable the `Atlas USS` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). +2. Enable the [Preview Features](../../README.md#preview-features) when running `terraform` commands. + + +Variables Required to be set: +- `public_key`: Atlas public key +- `private_key`: Atlas private key +- `project_id`: Project ID where flex cluster will be created \ No newline at end of file From def626410ef7b84a59a1c179a5add98e066c235a Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Mon, 4 Nov 2024 15:28:46 +0000 Subject: [PATCH 07/17] data source templates --- templates/data-sources/flex_cluster.md.tmpl | 14 ++++++++++++++ templates/data-sources/flex_clusters.md.tmpl | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 templates/data-sources/flex_cluster.md.tmpl create mode 100644 templates/data-sources/flex_clusters.md.tmpl diff --git a/templates/data-sources/flex_cluster.md.tmpl b/templates/data-sources/flex_cluster.md.tmpl new file mode 100644 index 0000000000..05f82d490d --- /dev/null +++ b/templates/data-sources/flex_cluster.md.tmpl @@ -0,0 +1,14 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` describes a flex cluster. + +-> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: +1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). +2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. + +## Example Usages +{{ tffile (printf "examples/%s/main.tf" .Name )}} + +{{ .SchemaMarkdown | trimspace }} + +For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/getFlexCluster) Documentation. diff --git a/templates/data-sources/flex_clusters.md.tmpl b/templates/data-sources/flex_clusters.md.tmpl new file mode 100644 index 0000000000..10543edf60 --- /dev/null +++ b/templates/data-sources/flex_clusters.md.tmpl @@ -0,0 +1,14 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` returns all flex clusters in a project. + +-> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: +1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). +2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. + +## Example Usages +{{ tffile (printf "examples/mongodbatlas_flex_cluster/main.tf" )}} + +{{ .SchemaMarkdown | trimspace }} + +For more information see: [MongoDB Atlas API - Stream Processor](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. From 1cbeec8b9b12bb7a18e390ee0e9376519f063fb8 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Mon, 4 Nov 2024 15:28:54 +0000 Subject: [PATCH 08/17] fix typo --- templates/resources/flex_cluster.md.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/resources/flex_cluster.md.tmpl b/templates/resources/flex_cluster.md.tmpl index e9f0a506e8..50b013172f 100644 --- a/templates/resources/flex_cluster.md.tmpl +++ b/templates/resources/flex_cluster.md.tmpl @@ -15,7 +15,7 @@ # Import Flex Cluster resource can be imported using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`, e.g. ``` -$ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClsuterName +$ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClusterName ``` For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/createFlexcluster) Documentation. From 075cb1cddeb4e4c3968200eee6a1e9c0cc2c13a8 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Tue, 5 Nov 2024 18:07:20 +0000 Subject: [PATCH 09/17] generate data source documentation --- docs/data-sources/flex_cluster.md | 83 +++++++++++++++++ docs/data-sources/flex_clusters.md | 93 ++++++++++++++++++++ docs/resources/flex_cluster.md | 14 ++- examples/mongodbatlas_flex_cluster/README.md | 2 +- 4 files changed, 189 insertions(+), 3 deletions(-) create mode 100644 docs/data-sources/flex_cluster.md create mode 100644 docs/data-sources/flex_clusters.md diff --git a/docs/data-sources/flex_cluster.md b/docs/data-sources/flex_cluster.md new file mode 100644 index 0000000000..277ae52c8f --- /dev/null +++ b/docs/data-sources/flex_cluster.md @@ -0,0 +1,83 @@ +# Data Source: mongodbatlas_flex_cluster + +`mongodbatlas_flex_cluster` describes a flex cluster. + +-> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: +1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). +2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. + +## Example Usages +```terraform +resource "mongodbatlas_flex_cluster" "flex_cluster" { + project_id = var.project_id + name = "clusterName" + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "flex_cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.flex_cluster.name +} + +data "mongodbatlas_flex_clusters" "flex_cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.flex_cluster.name +} +``` + + +## Schema + +### Required + +- `name` (String) Human-readable label that identifies the flex cluster. +- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access. + +**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups. + +### Read-Only + +- `backup_settings` (Attributes) Flex backup configuration (see [below for nested schema](#nestedatt--backup_settings)) +- `cluster_type` (String) Flex cluster topology. +- `connection_strings` (Attributes) Collection of Uniform Resource Locators that point to the MongoDB database. (see [below for nested schema](#nestedatt--connection_strings)) +- `create_date` (String) Date and time when MongoDB Cloud created this instance. This parameter expresses its value in ISO 8601 format in UTC. +- `id` (String) Unique 24-hexadecimal digit string that identifies the instance. +- `mongo_db_version` (String) Version of MongoDB that the instance runs. +- `provider_settings` (Attributes) Group of cloud provider settings that configure the provisioned MongoDB flex cluster. (see [below for nested schema](#nestedatt--provider_settings)) +- `state_name` (String) Human-readable label that indicates the current operating condition of this instance. +- `tags` (Map of String) Map that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the instance. +- `termination_protection_enabled` (Boolean) Flag that indicates whether termination protection is enabled on the cluster. If set to `true`, MongoDB Cloud won't delete the cluster. If set to `false`, MongoDB Cloud will delete the cluster. +- `version_release_system` (String) Method by which the cluster maintains the MongoDB versions. + + +### Nested Schema for `backup_settings` + +Read-Only: + +- `enabled` (Boolean) Flag that indicates whether backups are performed for this flex cluster. Backup uses [TODO](TODO) for flex clusters. + + + +### Nested Schema for `connection_strings` + +Read-Only: + +- `standard` (String) Public connection string that you can use to connect to this cluster. This connection string uses the mongodb:// protocol. +- `standard_srv` (String) Public connection string that you can use to connect to this flex cluster. This connection string uses the `mongodb+srv://` protocol. + + + +### Nested Schema for `provider_settings` + +Read-Only: + +- `backing_provider_name` (String) Cloud service provider on which MongoDB Cloud provisioned the flex cluster. +- `disk_size_gb` (Number) Storage capacity available to the flex cluster expressed in gigabytes. +- `provider_name` (String) Human-readable label that identifies the cloud service provider. +- `region_name` (String) Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/). + +For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/getFlexCluster) Documentation. diff --git a/docs/data-sources/flex_clusters.md b/docs/data-sources/flex_clusters.md new file mode 100644 index 0000000000..3f4b92da39 --- /dev/null +++ b/docs/data-sources/flex_clusters.md @@ -0,0 +1,93 @@ +# Data Source: mongodbatlas_flex_clusters + +`mongodbatlas_flex_clusters` returns all flex clusters in a project. + +-> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: +1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). +2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. + +## Example Usages +```terraform +resource "mongodbatlas_flex_cluster" "flex_cluster" { + project_id = var.project_id + name = "clusterName" + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "flex_cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.flex_cluster.name +} + +data "mongodbatlas_flex_clusters" "flex_cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.flex_cluster.name +} +``` + + +## Schema + +### Required + +- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access. + +**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups. + +### Read-Only + +- `results` (Attributes List) List of returned documents that MongoDB Cloud provides when completing this request. (see [below for nested schema](#nestedatt--results)) + + +### Nested Schema for `results` + +Read-Only: + +- `backup_settings` (Attributes) Flex backup configuration (see [below for nested schema](#nestedatt--results--backup_settings)) +- `cluster_type` (String) Flex cluster topology. +- `connection_strings` (Attributes) Collection of Uniform Resource Locators that point to the MongoDB database. (see [below for nested schema](#nestedatt--results--connection_strings)) +- `create_date` (String) Date and time when MongoDB Cloud created this instance. This parameter expresses its value in ISO 8601 format in UTC. +- `id` (String) Unique 24-hexadecimal digit string that identifies the instance. +- `mongo_db_version` (String) Version of MongoDB that the instance runs. +- `name` (String) Human-readable label that identifies the flex cluster. +- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access. + +**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups. +- `provider_settings` (Attributes) Group of cloud provider settings that configure the provisioned MongoDB flex cluster. (see [below for nested schema](#nestedatt--results--provider_settings)) +- `state_name` (String) Human-readable label that indicates the current operating condition of this instance. +- `tags` (Map of String) Map that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the instance. +- `termination_protection_enabled` (Boolean) Flag that indicates whether termination protection is enabled on the cluster. If set to `true`, MongoDB Cloud won't delete the cluster. If set to `false`, MongoDB Cloud will delete the cluster. +- `version_release_system` (String) Method by which the cluster maintains the MongoDB versions. + + +### Nested Schema for `results.backup_settings` + +Read-Only: + +- `enabled` (Boolean) Flag that indicates whether backups are performed for this flex cluster. Backup uses [TODO](TODO) for flex clusters. + + + +### Nested Schema for `results.connection_strings` + +Read-Only: + +- `standard` (String) Public connection string that you can use to connect to this cluster. This connection string uses the mongodb:// protocol. +- `standard_srv` (String) Public connection string that you can use to connect to this flex cluster. This connection string uses the `mongodb+srv://` protocol. + + + +### Nested Schema for `results.provider_settings` + +Read-Only: + +- `backing_provider_name` (String) Cloud service provider on which MongoDB Cloud provisioned the flex cluster. +- `disk_size_gb` (Number) Storage capacity available to the flex cluster expressed in gigabytes. +- `provider_name` (String) Human-readable label that identifies the cloud service provider. +- `region_name` (String) Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/). + +For more information see: [MongoDB Atlas API - Stream Processor](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md index 13e32d7715..0a0d45d144 100644 --- a/docs/resources/flex_cluster.md +++ b/docs/resources/flex_cluster.md @@ -17,7 +17,17 @@ resource "mongodbatlas_flex_cluster" "flex_cluster" { region_name = "US_EAST_1" } termination_protection_enabled = true -} # TODO: add plural and singular data source example +} + +data "mongodbatlas_flex_cluster" "flex_cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.flex_cluster.name +} + +data "mongodbatlas_flex_clusters" "flex_cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.flex_cluster.name +} ``` @@ -78,7 +88,7 @@ Read-Only: # Import Flex Cluster resource can be imported using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`, e.g. ``` -$ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClsuterName +$ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClusterName ``` For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/createFlexcluster) Documentation. diff --git a/examples/mongodbatlas_flex_cluster/README.md b/examples/mongodbatlas_flex_cluster/README.md index 09ad2147c1..e078c43b81 100644 --- a/examples/mongodbatlas_flex_cluster/README.md +++ b/examples/mongodbatlas_flex_cluster/README.md @@ -1,7 +1,7 @@ # MongoDB Atlas Provider -- Atlas Flex Cluster This example creates one flex cluster in a project. -**NOTE**: Flex Clusters are currently in Private Preview. To use this feature, you must take the following actions: +**NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: 1. Enable the `Atlas USS` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). 2. Enable the [Preview Features](../../README.md#preview-features) when running `terraform` commands. From 0959f5dc89f38d1be66b7b2fd87136a6fb0b5a48 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Wed, 6 Nov 2024 10:53:34 +0000 Subject: [PATCH 10/17] fix to flex_cluster example --- docs/data-sources/flex_cluster.md | 11 +++++++++-- docs/data-sources/flex_clusters.md | 11 +++++++++-- docs/resources/flex_cluster.md | 11 +++++++++-- examples/mongodbatlas_flex_cluster/main.tf | 11 +++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/docs/data-sources/flex_cluster.md b/docs/data-sources/flex_cluster.md index 277ae52c8f..86d42d0721 100644 --- a/docs/data-sources/flex_cluster.md +++ b/docs/data-sources/flex_cluster.md @@ -23,9 +23,16 @@ data "mongodbatlas_flex_cluster" "flex_cluster" { name = mongodbatlas_flex_cluster.flex_cluster.name } -data "mongodbatlas_flex_clusters" "flex_cluster" { +data "mongodbatlas_flex_clusters" "flex_clusters" { project_id = var.project_id - name = mongodbatlas_flex_cluster.flex_cluster.name +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.flex_cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.flex_clusters.results : cluster.name] } ``` diff --git a/docs/data-sources/flex_clusters.md b/docs/data-sources/flex_clusters.md index 3f4b92da39..ea93265a85 100644 --- a/docs/data-sources/flex_clusters.md +++ b/docs/data-sources/flex_clusters.md @@ -23,9 +23,16 @@ data "mongodbatlas_flex_cluster" "flex_cluster" { name = mongodbatlas_flex_cluster.flex_cluster.name } -data "mongodbatlas_flex_clusters" "flex_cluster" { +data "mongodbatlas_flex_clusters" "flex_clusters" { project_id = var.project_id - name = mongodbatlas_flex_cluster.flex_cluster.name +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.flex_cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.flex_clusters.results : cluster.name] } ``` diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md index 0a0d45d144..da9d806e48 100644 --- a/docs/resources/flex_cluster.md +++ b/docs/resources/flex_cluster.md @@ -24,9 +24,16 @@ data "mongodbatlas_flex_cluster" "flex_cluster" { name = mongodbatlas_flex_cluster.flex_cluster.name } -data "mongodbatlas_flex_clusters" "flex_cluster" { +data "mongodbatlas_flex_clusters" "flex_clusters" { project_id = var.project_id - name = mongodbatlas_flex_cluster.flex_cluster.name +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.flex_cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.flex_clusters.results : cluster.name] } ``` diff --git a/examples/mongodbatlas_flex_cluster/main.tf b/examples/mongodbatlas_flex_cluster/main.tf index 1ea8645d97..0d925f6d2e 100644 --- a/examples/mongodbatlas_flex_cluster/main.tf +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -13,7 +13,14 @@ data "mongodbatlas_flex_cluster" "flex_cluster" { name = mongodbatlas_flex_cluster.flex_cluster.name } -data "mongodbatlas_flex_clusters" "flex_cluster" { +data "mongodbatlas_flex_clusters" "flex_clusters" { project_id = var.project_id - name = mongodbatlas_flex_cluster.flex_cluster.name +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.flex_cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.flex_clusters.results : cluster.name] } From 016253b2819ed52c7aaec4de5124c90d5143f872 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Wed, 6 Nov 2024 15:41:04 +0000 Subject: [PATCH 11/17] fix to flex_cluster example --- examples/mongodbatlas_flex_cluster/README.md | 3 ++- examples/mongodbatlas_flex_cluster/main.tf | 6 +++--- examples/mongodbatlas_flex_cluster/variables.tf | 7 ++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/mongodbatlas_flex_cluster/README.md b/examples/mongodbatlas_flex_cluster/README.md index e078c43b81..72271945f2 100644 --- a/examples/mongodbatlas_flex_cluster/README.md +++ b/examples/mongodbatlas_flex_cluster/README.md @@ -9,4 +9,5 @@ This example creates one flex cluster in a project. Variables Required to be set: - `public_key`: Atlas public key - `private_key`: Atlas private key -- `project_id`: Project ID where flex cluster will be created \ No newline at end of file +- `project_id`: Project ID where flex cluster will be created +- `cluster_name`: Name of flex cluster that will be created \ No newline at end of file diff --git a/examples/mongodbatlas_flex_cluster/main.tf b/examples/mongodbatlas_flex_cluster/main.tf index 0d925f6d2e..755ef372ef 100644 --- a/examples/mongodbatlas_flex_cluster/main.tf +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -1,17 +1,17 @@ resource "mongodbatlas_flex_cluster" "flex_cluster" { project_id = var.project_id - name = "clusterName" + name = var.cluster_name provider_settings = { backing_provider_name = "AWS" region_name = "US_EAST_1" } termination_protection_enabled = true -} +} data "mongodbatlas_flex_cluster" "flex_cluster" { project_id = var.project_id name = mongodbatlas_flex_cluster.flex_cluster.name -} +} data "mongodbatlas_flex_clusters" "flex_clusters" { project_id = var.project_id diff --git a/examples/mongodbatlas_flex_cluster/variables.tf b/examples/mongodbatlas_flex_cluster/variables.tf index c8ac7d8475..5dbb16a6af 100644 --- a/examples/mongodbatlas_flex_cluster/variables.tf +++ b/examples/mongodbatlas_flex_cluster/variables.tf @@ -9,4 +9,9 @@ variable "private_key" { variable "project_id" { description = "Atlas Project ID" type = string -} \ No newline at end of file +} +variable "cluster_name" { + description = "Atlas cluster name" + type = string + default = "string" +} \ No newline at end of file From 75b7d258dd24162de943bda5515c8eaad59595b4 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Wed, 6 Nov 2024 15:50:38 +0000 Subject: [PATCH 12/17] fix to generated docs --- docs/data-sources/flex_cluster.md | 6 +++--- docs/data-sources/flex_clusters.md | 6 +++--- docs/resources/flex_cluster.md | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/data-sources/flex_cluster.md b/docs/data-sources/flex_cluster.md index 86d42d0721..69e28c2b1f 100644 --- a/docs/data-sources/flex_cluster.md +++ b/docs/data-sources/flex_cluster.md @@ -10,18 +10,18 @@ ```terraform resource "mongodbatlas_flex_cluster" "flex_cluster" { project_id = var.project_id - name = "clusterName" + name = var.cluster_name provider_settings = { backing_provider_name = "AWS" region_name = "US_EAST_1" } termination_protection_enabled = true -} +} data "mongodbatlas_flex_cluster" "flex_cluster" { project_id = var.project_id name = mongodbatlas_flex_cluster.flex_cluster.name -} +} data "mongodbatlas_flex_clusters" "flex_clusters" { project_id = var.project_id diff --git a/docs/data-sources/flex_clusters.md b/docs/data-sources/flex_clusters.md index ea93265a85..a3512af6f6 100644 --- a/docs/data-sources/flex_clusters.md +++ b/docs/data-sources/flex_clusters.md @@ -10,18 +10,18 @@ ```terraform resource "mongodbatlas_flex_cluster" "flex_cluster" { project_id = var.project_id - name = "clusterName" + name = var.cluster_name provider_settings = { backing_provider_name = "AWS" region_name = "US_EAST_1" } termination_protection_enabled = true -} +} data "mongodbatlas_flex_cluster" "flex_cluster" { project_id = var.project_id name = mongodbatlas_flex_cluster.flex_cluster.name -} +} data "mongodbatlas_flex_clusters" "flex_clusters" { project_id = var.project_id diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md index da9d806e48..64c88de29a 100644 --- a/docs/resources/flex_cluster.md +++ b/docs/resources/flex_cluster.md @@ -11,18 +11,18 @@ ```terraform resource "mongodbatlas_flex_cluster" "flex_cluster" { project_id = var.project_id - name = "clusterName" + name = var.cluster_name provider_settings = { backing_provider_name = "AWS" region_name = "US_EAST_1" } termination_protection_enabled = true -} +} data "mongodbatlas_flex_cluster" "flex_cluster" { project_id = var.project_id name = mongodbatlas_flex_cluster.flex_cluster.name -} +} data "mongodbatlas_flex_clusters" "flex_clusters" { project_id = var.project_id From eb6b6af44a1f2332f75510a2a5b3996830f31c32 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Wed, 6 Nov 2024 17:43:15 +0000 Subject: [PATCH 13/17] Added flex to dedicated migration guide --- ...ter-to-dedicated-cluster-migraton-guide.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md diff --git a/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md b/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md new file mode 100644 index 0000000000..99c6ace9ed --- /dev/null +++ b/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md @@ -0,0 +1,46 @@ +--- +page_title: "Migration Guide: FLex Cluster to Dedicated Cluster" +--- + +# Migration Guide: Flex Cluster to Dedicated Cluster + +**Objective**: This guide explains how to replace the `mongodbatlas_flex_cluster` resource with the `mongodbatlas_advanced_cluster` resource. + +Currently, the only method to migrate your Flex cluster to a Dedicated cluster is via the Atlas UI. + + + +## Best Practices Before Migrating +Before doing any migration, create a backup of your [Terraform state file](https://developer.hashicorp.com/terraform/cli/commands/state). + +### Procedure + + +See [Modify a Cluster](https://www.mongodb.com/docs/atlas/scale-cluster/) for how to migrate via the Atlas UI. + +The following resolves the configuration drift in Terraform and will not affect the underlying cluster infrastructure: + +1. Find the import IDs of the new Dedicated cluster your Flex cluster has migrated to: `{PROJECT_ID}-{CLUSTER_NAME}`, such as `664619d870c247237f4b86a6-clusterName` +2. Add an import block to on of your `.tf` files: + ```terraform + import { + to = mongodbatlas_advanced_cluster.this + id = "664619d870c247237f4b86a6-clusterName" # from step 1 + } + ``` + 3. Run `terraform plan -generate-config-out=adv_cluster.tf`. This should generate a `adv_cluster.tf` file. + 4. Run `terraform apply`. You should see the resource imported: `Apply complete! Resources: 1 imported, 0 added, 0 changed, 0 destroyed.` + 5. Remove the "default" fields. Many fields of this resource are optional. Look for fields with a `null` or `0` value or blocks you didn't specify before, for example: + - `advanced_configuration` + - `connection_strings` + - `cluster_id` + - `bi_connector_config` + 6. Re-use existing [Terraform expressions](https://developer.hashicorp.com/terraform/language/expressions). All fields in the generated configuration have static values. Look in your previous configuration for: + - variables, for example: `var.project_id` + - Terraform keywords, for example: `for_each`, `count`, and `depends_on` + 7. Re-run `terraform apply` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` + 8. Update the references from your previous cluster resource: `mongodbatlas_flex_cluster.this.XXX` to the new `mongodbatlas_advanced_cluster.this.XXX`. + 9. Update any data source blocks to refer to `mongodbatlas_advanced_cluster`. + 10. Replace your existing clusters with the ones from `adv_cluster.tf` and run `terraform state rm mongodbatlas_flex_cluster.this`. Without this step, Terraform creates a plan to delete your existing cluster. + 11. Remove the import block created in step 2. + 12. Re-run `terraform apply` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` From dd6fcbc8eca248c7360e8b8b22d4208461bf1b35 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Thu, 7 Nov 2024 10:29:16 +0000 Subject: [PATCH 14/17] fix typo --- docs/data-sources/flex_clusters.md | 2 +- templates/data-sources/flex_clusters.md.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/data-sources/flex_clusters.md b/docs/data-sources/flex_clusters.md index a3512af6f6..4471d1980d 100644 --- a/docs/data-sources/flex_clusters.md +++ b/docs/data-sources/flex_clusters.md @@ -97,4 +97,4 @@ Read-Only: - `provider_name` (String) Human-readable label that identifies the cloud service provider. - `region_name` (String) Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/). -For more information see: [MongoDB Atlas API - Stream Processor](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. +For more information see: [MongoDB Atlas API - Flex Clusters](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. diff --git a/templates/data-sources/flex_clusters.md.tmpl b/templates/data-sources/flex_clusters.md.tmpl index 10543edf60..311f62a646 100644 --- a/templates/data-sources/flex_clusters.md.tmpl +++ b/templates/data-sources/flex_clusters.md.tmpl @@ -11,4 +11,4 @@ {{ .SchemaMarkdown | trimspace }} -For more information see: [MongoDB Atlas API - Stream Processor](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. +For more information see: [MongoDB Atlas API - Flex Clusters](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. From d377273d3080a159dd52f8012fabedb0e0f4300e Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Fri, 8 Nov 2024 10:06:09 +0000 Subject: [PATCH 15/17] Implementing feedback and improving flex-dedicated migratoin guide --- docs/data-sources/flex_cluster.md | 14 +++--- docs/data-sources/flex_clusters.md | 14 +++--- ...ter-to-dedicated-cluster-migraton-guide.md | 43 +++++++++++++------ docs/resources/flex_cluster.md | 16 +++---- examples/mongodbatlas_flex_cluster/main.tf | 10 ++--- templates/data-sources/flex_cluster.md.tmpl | 4 -- templates/data-sources/flex_clusters.md.tmpl | 4 -- templates/resources/flex_cluster.md.tmpl | 6 +-- 8 files changed, 53 insertions(+), 58 deletions(-) diff --git a/docs/data-sources/flex_cluster.md b/docs/data-sources/flex_cluster.md index 69e28c2b1f..ec0d030997 100644 --- a/docs/data-sources/flex_cluster.md +++ b/docs/data-sources/flex_cluster.md @@ -2,13 +2,9 @@ `mongodbatlas_flex_cluster` describes a flex cluster. --> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: -1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). -2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. - ## Example Usages ```terraform -resource "mongodbatlas_flex_cluster" "flex_cluster" { +resource "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id name = var.cluster_name provider_settings = { @@ -18,21 +14,21 @@ resource "mongodbatlas_flex_cluster" "flex_cluster" { termination_protection_enabled = true } -data "mongodbatlas_flex_cluster" "flex_cluster" { +data "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id name = mongodbatlas_flex_cluster.flex_cluster.name } -data "mongodbatlas_flex_clusters" "flex_clusters" { +data "mongodbatlas_flex_clusters" "example-clusters" { project_id = var.project_id } output "mongodbatlas_flex_cluster" { - value = data.mongodbatlas_flex_cluster.flex_cluster.name + value = data.mongodbatlas_flex_cluster.example-cluster.name } output "mongodbatlas_flex_clusters_names" { - value = [for cluster in data.mongodbatlas_flex_clusters.flex_clusters.results : cluster.name] + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] } ``` diff --git a/docs/data-sources/flex_clusters.md b/docs/data-sources/flex_clusters.md index 4471d1980d..d0a7bf31f0 100644 --- a/docs/data-sources/flex_clusters.md +++ b/docs/data-sources/flex_clusters.md @@ -2,13 +2,9 @@ `mongodbatlas_flex_clusters` returns all flex clusters in a project. --> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: -1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). -2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. - ## Example Usages ```terraform -resource "mongodbatlas_flex_cluster" "flex_cluster" { +resource "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id name = var.cluster_name provider_settings = { @@ -18,21 +14,21 @@ resource "mongodbatlas_flex_cluster" "flex_cluster" { termination_protection_enabled = true } -data "mongodbatlas_flex_cluster" "flex_cluster" { +data "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id name = mongodbatlas_flex_cluster.flex_cluster.name } -data "mongodbatlas_flex_clusters" "flex_clusters" { +data "mongodbatlas_flex_clusters" "example-clusters" { project_id = var.project_id } output "mongodbatlas_flex_cluster" { - value = data.mongodbatlas_flex_cluster.flex_cluster.name + value = data.mongodbatlas_flex_cluster.example-cluster.name } output "mongodbatlas_flex_clusters_names" { - value = [for cluster in data.mongodbatlas_flex_clusters.flex_clusters.results : cluster.name] + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] } ``` diff --git a/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md b/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md index 99c6ace9ed..466eb03107 100644 --- a/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md +++ b/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md @@ -1,5 +1,5 @@ --- -page_title: "Migration Guide: FLex Cluster to Dedicated Cluster" +page_title: "Migration Guide: Flex Cluster to Dedicated Cluster" --- # Migration Guide: Flex Cluster to Dedicated Cluster @@ -18,10 +18,10 @@ Before doing any migration, create a backup of your [Terraform state file](https See [Modify a Cluster](https://www.mongodb.com/docs/atlas/scale-cluster/) for how to migrate via the Atlas UI. -The following resolves the configuration drift in Terraform and will not affect the underlying cluster infrastructure: +Complete the following procedure to resolves the configuration drift in Terraform. This does not affect the underlying cluster infrastructure. 1. Find the import IDs of the new Dedicated cluster your Flex cluster has migrated to: `{PROJECT_ID}-{CLUSTER_NAME}`, such as `664619d870c247237f4b86a6-clusterName` -2. Add an import block to on of your `.tf` files: +2. Add an import block to one of your `.tf` files: ```terraform import { to = mongodbatlas_advanced_cluster.this @@ -30,16 +30,35 @@ The following resolves the configuration drift in Terraform and will not affect ``` 3. Run `terraform plan -generate-config-out=adv_cluster.tf`. This should generate a `adv_cluster.tf` file. 4. Run `terraform apply`. You should see the resource imported: `Apply complete! Resources: 1 imported, 0 added, 0 changed, 0 destroyed.` - 5. Remove the "default" fields. Many fields of this resource are optional. Look for fields with a `null` or `0` value or blocks you didn't specify before, for example: - - `advanced_configuration` - - `connection_strings` - - `cluster_id` - - `bi_connector_config` - 6. Re-use existing [Terraform expressions](https://developer.hashicorp.com/terraform/language/expressions). All fields in the generated configuration have static values. Look in your previous configuration for: - - variables, for example: `var.project_id` - - Terraform keywords, for example: `for_each`, `count`, and `depends_on` + 5. Remove the "default" fields. Many fields of this resource are optional. Look for fields with a `null` or `0` value or blocks you didn't specify before. Required fields have been outlined in the below example resource block: + ``` terraform + resource "mongodbatlas_advanced_cluster" "this" { + cluster_type = "REPLICASET" + name = "clusterName" + project_id = "664619d870c247237f4b86a6" + replication_specs { + zone_name = "Zone 1" + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_1" + analytics_specs { + instance_size = "M10" + node_count = 0 + } + electable_specs { + instance_size = "M10" + node_count = 3 + } + } + } + } + ``` + 6. Re-use existing [Terraform expressions](https://developer.hashicorp.com/terraform/language/expressions). All fields in the generated configuration have static values. Look in your previous configuration for: + - variables, for example: `var.project_id` + - Terraform keywords, for example: `for_each`, `count`, and `depends_on` 7. Re-run `terraform apply` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` - 8. Update the references from your previous cluster resource: `mongodbatlas_flex_cluster.this.XXX` to the new `mongodbatlas_advanced_cluster.this.XXX`. + 8. Update the references from your previous cluster resource: `mongodbatlas_flex_cluster.this.X` to the new `mongodbatlas_advanced_cluster.this.X`. 9. Update any data source blocks to refer to `mongodbatlas_advanced_cluster`. 10. Replace your existing clusters with the ones from `adv_cluster.tf` and run `terraform state rm mongodbatlas_flex_cluster.this`. Without this step, Terraform creates a plan to delete your existing cluster. 11. Remove the import block created in step 2. diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md index 64c88de29a..93c903e910 100644 --- a/docs/resources/flex_cluster.md +++ b/docs/resources/flex_cluster.md @@ -2,14 +2,10 @@ `mongodbatlas_flex_cluster` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster. --> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: -1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). -2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. - ## Example Usages ```terraform -resource "mongodbatlas_flex_cluster" "flex_cluster" { +resource "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id name = var.cluster_name provider_settings = { @@ -19,21 +15,21 @@ resource "mongodbatlas_flex_cluster" "flex_cluster" { termination_protection_enabled = true } -data "mongodbatlas_flex_cluster" "flex_cluster" { +data "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id name = mongodbatlas_flex_cluster.flex_cluster.name } -data "mongodbatlas_flex_clusters" "flex_clusters" { +data "mongodbatlas_flex_clusters" "example-clusters" { project_id = var.project_id } output "mongodbatlas_flex_cluster" { - value = data.mongodbatlas_flex_cluster.flex_cluster.name + value = data.mongodbatlas_flex_cluster.example-cluster.name } output "mongodbatlas_flex_clusters_names" { - value = [for cluster in data.mongodbatlas_flex_clusters.flex_clusters.results : cluster.name] + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] } ``` @@ -93,7 +89,7 @@ Read-Only: - `standard_srv` (String) Public connection string that you can use to connect to this flex cluster. This connection string uses the `mongodb+srv://` protocol. # Import -Flex Cluster resource can be imported using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`, e.g. +You can import the Flex Cluster resource by using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`. For example: ``` $ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClusterName ``` diff --git a/examples/mongodbatlas_flex_cluster/main.tf b/examples/mongodbatlas_flex_cluster/main.tf index 755ef372ef..575de633ae 100644 --- a/examples/mongodbatlas_flex_cluster/main.tf +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -1,4 +1,4 @@ -resource "mongodbatlas_flex_cluster" "flex_cluster" { +resource "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id name = var.cluster_name provider_settings = { @@ -8,19 +8,19 @@ resource "mongodbatlas_flex_cluster" "flex_cluster" { termination_protection_enabled = true } -data "mongodbatlas_flex_cluster" "flex_cluster" { +data "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id name = mongodbatlas_flex_cluster.flex_cluster.name } -data "mongodbatlas_flex_clusters" "flex_clusters" { +data "mongodbatlas_flex_clusters" "example-clusters" { project_id = var.project_id } output "mongodbatlas_flex_cluster" { - value = data.mongodbatlas_flex_cluster.flex_cluster.name + value = data.mongodbatlas_flex_cluster.example-cluster.name } output "mongodbatlas_flex_clusters_names" { - value = [for cluster in data.mongodbatlas_flex_clusters.flex_clusters.results : cluster.name] + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] } diff --git a/templates/data-sources/flex_cluster.md.tmpl b/templates/data-sources/flex_cluster.md.tmpl index 05f82d490d..9e1051b71b 100644 --- a/templates/data-sources/flex_cluster.md.tmpl +++ b/templates/data-sources/flex_cluster.md.tmpl @@ -2,10 +2,6 @@ `{{.Name}}` describes a flex cluster. --> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: -1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). -2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. - ## Example Usages {{ tffile (printf "examples/%s/main.tf" .Name )}} diff --git a/templates/data-sources/flex_clusters.md.tmpl b/templates/data-sources/flex_clusters.md.tmpl index 311f62a646..7d0e6f430b 100644 --- a/templates/data-sources/flex_clusters.md.tmpl +++ b/templates/data-sources/flex_clusters.md.tmpl @@ -2,10 +2,6 @@ `{{.Name}}` returns all flex clusters in a project. --> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: -1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). -2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. - ## Example Usages {{ tffile (printf "examples/mongodbatlas_flex_cluster/main.tf" )}} diff --git a/templates/resources/flex_cluster.md.tmpl b/templates/resources/flex_cluster.md.tmpl index 50b013172f..0b4542e691 100644 --- a/templates/resources/flex_cluster.md.tmpl +++ b/templates/resources/flex_cluster.md.tmpl @@ -2,10 +2,6 @@ `{{.Name}}` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster. --> **NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: -1. Enable the `Atlas Uss Enabled` Preview Feature in your project (contact [MongoDB Support](https://www.mongodb.com/services/support)). -2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. - ## Example Usages {{ tffile (printf "examples/%s/main.tf" .Name )}} @@ -13,7 +9,7 @@ {{ .SchemaMarkdown | trimspace }} # Import -Flex Cluster resource can be imported using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`, e.g. +You can import the Flex Cluster resource by using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`. For example: ``` $ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClusterName ``` From 2ae358d7aa42b1a928e5d386365c68fe975f95b8 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Fri, 8 Nov 2024 10:09:34 +0000 Subject: [PATCH 16/17] adjust flex example README.md --- examples/mongodbatlas_flex_cluster/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/mongodbatlas_flex_cluster/README.md b/examples/mongodbatlas_flex_cluster/README.md index 72271945f2..bdf65398b8 100644 --- a/examples/mongodbatlas_flex_cluster/README.md +++ b/examples/mongodbatlas_flex_cluster/README.md @@ -1,11 +1,6 @@ # MongoDB Atlas Provider -- Atlas Flex Cluster This example creates one flex cluster in a project. -**NOTE**: Flex Clusters are currently in Preview. To use this feature, you must take the following actions: -1. Enable the `Atlas USS` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). -2. Enable the [Preview Features](../../README.md#preview-features) when running `terraform` commands. - - Variables Required to be set: - `public_key`: Atlas public key - `private_key`: Atlas private key From e641428f504ea87cfa3edd44df47644d649e8464 Mon Sep 17 00:00:00 2001 From: Melanija Cvetic Date: Fri, 8 Nov 2024 11:27:52 +0000 Subject: [PATCH 17/17] fix to example --- docs/data-sources/flex_cluster.md | 2 +- docs/data-sources/flex_clusters.md | 2 +- docs/resources/flex_cluster.md | 2 +- examples/mongodbatlas_flex_cluster/main.tf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/data-sources/flex_cluster.md b/docs/data-sources/flex_cluster.md index ec0d030997..4e973c9505 100644 --- a/docs/data-sources/flex_cluster.md +++ b/docs/data-sources/flex_cluster.md @@ -16,7 +16,7 @@ resource "mongodbatlas_flex_cluster" "example-cluster" { data "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id - name = mongodbatlas_flex_cluster.flex_cluster.name + name = mongodbatlas_flex_cluster.example-cluster.name } data "mongodbatlas_flex_clusters" "example-clusters" { diff --git a/docs/data-sources/flex_clusters.md b/docs/data-sources/flex_clusters.md index d0a7bf31f0..f7e4d912d8 100644 --- a/docs/data-sources/flex_clusters.md +++ b/docs/data-sources/flex_clusters.md @@ -16,7 +16,7 @@ resource "mongodbatlas_flex_cluster" "example-cluster" { data "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id - name = mongodbatlas_flex_cluster.flex_cluster.name + name = mongodbatlas_flex_cluster.example-cluster.name } data "mongodbatlas_flex_clusters" "example-clusters" { diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md index 93c903e910..01aab188bd 100644 --- a/docs/resources/flex_cluster.md +++ b/docs/resources/flex_cluster.md @@ -17,7 +17,7 @@ resource "mongodbatlas_flex_cluster" "example-cluster" { data "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id - name = mongodbatlas_flex_cluster.flex_cluster.name + name = mongodbatlas_flex_cluster.example-cluster.name } data "mongodbatlas_flex_clusters" "example-clusters" { diff --git a/examples/mongodbatlas_flex_cluster/main.tf b/examples/mongodbatlas_flex_cluster/main.tf index 575de633ae..a08df1eaf3 100644 --- a/examples/mongodbatlas_flex_cluster/main.tf +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -10,7 +10,7 @@ resource "mongodbatlas_flex_cluster" "example-cluster" { data "mongodbatlas_flex_cluster" "example-cluster" { project_id = var.project_id - name = mongodbatlas_flex_cluster.flex_cluster.name + name = mongodbatlas_flex_cluster.example-cluster.name } data "mongodbatlas_flex_clusters" "example-clusters" {