diff --git a/docs/data-sources/flex_cluster.md b/docs/data-sources/flex_cluster.md new file mode 100644 index 0000000000..4e973c9505 --- /dev/null +++ b/docs/data-sources/flex_cluster.md @@ -0,0 +1,86 @@ +# Data Source: mongodbatlas_flex_cluster + +`mongodbatlas_flex_cluster` describes a flex cluster. + +## Example Usages +```terraform +resource "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = var.cluster_name + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.example-cluster.name +} + +data "mongodbatlas_flex_clusters" "example-clusters" { + project_id = var.project_id +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.example-cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : 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..f7e4d912d8 --- /dev/null +++ b/docs/data-sources/flex_clusters.md @@ -0,0 +1,96 @@ +# Data Source: mongodbatlas_flex_clusters + +`mongodbatlas_flex_clusters` returns all flex clusters in a project. + +## Example Usages +```terraform +resource "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = var.cluster_name + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.example-cluster.name +} + +data "mongodbatlas_flex_clusters" "example-clusters" { + project_id = var.project_id +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.example-cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : 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 - Flex Clusters](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. 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..466eb03107 --- /dev/null +++ b/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md @@ -0,0 +1,65 @@ +--- +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. + +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 one 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. 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.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. + 12. Re-run `terraform apply` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md new file mode 100644 index 0000000000..01aab188bd --- /dev/null +++ b/docs/resources/flex_cluster.md @@ -0,0 +1,97 @@ +# Resource: mongodbatlas_flex_cluster + +`mongodbatlas_flex_cluster` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster. + +## Example Usages + +```terraform +resource "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = var.cluster_name + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.example-cluster.name +} + +data "mongodbatlas_flex_clusters" "example-clusters" { + project_id = var.project_id +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.example-cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] +} +``` + + +## 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 +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 +``` + +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..bdf65398b8 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/README.md @@ -0,0 +1,8 @@ +# MongoDB Atlas Provider -- Atlas Flex Cluster +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 +- `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 new file mode 100644 index 0000000000..a08df1eaf3 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -0,0 +1,26 @@ +resource "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = var.cluster_name + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.example-cluster.name +} + +data "mongodbatlas_flex_clusters" "example-clusters" { + project_id = var.project_id +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.example-cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] +} 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..5dbb16a6af --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/variables.tf @@ -0,0 +1,17 @@ +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 +} +variable "cluster_name" { + description = "Atlas cluster name" + type = string + default = "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..3faf38df1a --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + mongodbatlas = { + source = "mongodb/mongodbatlas" + version = "~> 1.21.3" + } + } + required_version = ">= 1.0" +} diff --git a/templates/data-sources/flex_cluster.md.tmpl b/templates/data-sources/flex_cluster.md.tmpl new file mode 100644 index 0000000000..9e1051b71b --- /dev/null +++ b/templates/data-sources/flex_cluster.md.tmpl @@ -0,0 +1,10 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` describes a flex cluster. + +## 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..7d0e6f430b --- /dev/null +++ b/templates/data-sources/flex_clusters.md.tmpl @@ -0,0 +1,10 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` returns all flex clusters in a project. + +## Example Usages +{{ tffile (printf "examples/mongodbatlas_flex_cluster/main.tf" )}} + +{{ .SchemaMarkdown | trimspace }} + +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/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..0b4542e691 --- /dev/null +++ b/templates/resources/flex_cluster.md.tmpl @@ -0,0 +1,17 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster. + +## Example Usages + +{{ tffile (printf "examples/%s/main.tf" .Name )}} + +{{ .SchemaMarkdown | trimspace }} + +# Import +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 +``` + +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.