You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Convert mongodbatlas_cluster to mongodbatlas_advanced_cluster (preview provider v2)
19
+
## Convert mongodbatlas_cluster to mongodbatlas_advanced_cluster (preview provider 2.0.0)
20
20
21
21
### Usage
22
22
23
-
**Note**: In order to use the **Preview for MongoDB Atlas Provider v2** of `mongodbatlas_advanced_cluster`, you need to set the environment variable `MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER` to `true`.
23
+
**Note**: In order to use the **Preview for MongoDB Atlas Provider 2.0.0** of `mongodbatlas_advanced_cluster`, you need to set the environment variable `MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER` to `true`.
24
24
25
25
If you want to convert a Terraform configuration from `mongodbatlas_cluster` to `mongodbatlas_advanced_cluster`, use the following command:
26
26
```bash
@@ -38,12 +38,34 @@ If you want to overwrite the output file if it exists, or even use the same outp
38
38
39
39
You can use the `--watch` or the `-w` flag to keep the plugin running and watching for changes in the input file. You can have input and output files open in an editor and see easily how changes to the input file affect the output file.
40
40
41
+
### Dynamic blocks
42
+
43
+
`dynamic` blocks are used to generate multiple nested blocks based on a set of values.
44
+
Given the different ways of using dynamic blocks, we recommend reviewing the output and making sure it fits your needs.
45
+
46
+
#### Dynamic blocks in tags and labels
47
+
48
+
You can use `dynamic` blocks for `tags` and `labels`. You can also combine the use of dynamic blocks in `tags` and `labels` with individual blocks in the same cluster definition, e.g.:
49
+
```hcl
50
+
tags {
51
+
key = "environment"
52
+
value = var.environment
53
+
}
54
+
dynamic "tags" {
55
+
for_each = var.tags
56
+
content {
57
+
key = tags.key
58
+
value = replace(tags.value, "/", "_")
59
+
}
60
+
}
61
+
```
62
+
41
63
### Limitations
42
64
43
65
- The plugin doesn't support `regions_config` without `electable_nodes` as there can be some issues with `priority` when they only have `analytics_nodes` and/or `electable_nodes`.
44
66
-[`priority`](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/cluster#priority-1) is required in `regions_config` and must be a numeric [literal expression](https://developer.hashicorp.com/nomad/docs/job-specification/hcl2/expressions#literal-expressions) between 7 and 1, e.g. `var.priority` is not supported. This is to allow reordering them by descending priority as this is expected in `mongodbatlas_advanced_cluster`.
45
67
-[`num_shards`](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/cluster#num_shards-2) in `replication_specs` must be a numeric [literal expression](https://developer.hashicorp.com/nomad/docs/job-specification/hcl2/expressions#literal-expressions), e.g. `var.num_shards` is not supported. This is to allow creating a `replication_specs` element per shard in `mongodbatlas_advanced_cluster`.
46
-
-`dynamic` blocks to generate `replication_specs`, `regions_config`, etc. are not supported.
68
+
-`dynamic` blocks are currently supported only for `tags` and `labels`. **Coming soon**: support for `replication_specs` and `regions_config`.
0 commit comments