---
subcategory: "Clusters"
---
# Resource: mongodbatlas_flex_cluster
`mongodbatlas_flex_cluster` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster.
**RECOMMENDATION:** We recommend using the `mongodbatlas_advanced_cluster` resource instead of the `mongodbatlas_flex_cluster` resource to create and manage Flex clusters. The `mongodbatlas_advanced_cluster` resource not only supports Flex clusters, but also supports tenant and dedicated clusters, providing easier migration between different cluster types. For more information, see the [Advanced Cluster](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/advanced_cluster) resource.
## 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]
}
```
### Further Examples
- [Flex Cluster](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.20.1/examples/mongodbatlas_flex_cluster)
## 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
- `delete_on_create_timeout` (Boolean) Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`.
- `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.
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
### 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://www.mongodb.com/docs/atlas/reference/amazon-aws/), [GCP](https://www.mongodb.com/docs/atlas/reference/google-gcp/), and [Azure](https://www.mongodb.com/docs/atlas/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 `timeouts`
Optional:
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), and "h" (hours). Default: `3h`.
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), and "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs. Default: `3h`.
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), and "h" (hours). Default: `3h`.
### Nested Schema for `backup_settings`
Read-Only:
- `enabled` (Boolean) Flag that indicates whether backups are performed for this flex cluster. Backup uses [flex cluster backups](https://www.mongodb.com/docs/atlas/backup/cloud-backup/flex-cluster-backup/).
### 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.