Skip to content

Commit 1b6cfba

Browse files
committed
readme
1 parent dbd46b6 commit 1b6cfba

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ Install the plugin by running:
1616
atlas plugin install github.com/mongodb-labs/atlas-cli-plugin-terraform
1717
```
1818

19-
## Convert mongodbatlas_cluster to mongodbatlas_advanced_cluster (preview provider v2)
19+
## Convert mongodbatlas_cluster to mongodbatlas_advanced_cluster (preview provider 2.0.0)
2020

2121
### Usage
2222

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`.
2424

2525
If you want to convert a Terraform configuration from `mongodbatlas_cluster` to `mongodbatlas_advanced_cluster`, use the following command:
2626
```bash
@@ -38,12 +38,34 @@ If you want to overwrite the output file if it exists, or even use the same outp
3838

3939
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.
4040

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+
4163
### Limitations
4264

4365
- 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`.
4466
- [`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`.
4567
- [`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`.
4769

4870
## Contributing
4971

0 commit comments

Comments
 (0)