Skip to content

Commit 204b118

Browse files
committed
doc
1 parent 06b3f32 commit 204b118

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ENHANCEMENTS:
44

5-
* Supports `dynamic` block for `tags`, `labels` and `regions_config`
5+
* Supports `dynamic` blocks for `tags`, `labels`, `regions_config` and `replication_specs`
66

77
## 1.0.0 (Mar 6, 2025)
88

README.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,51 @@ dynamic "tags" {
7878
You can use `dynamic` blocks for `regions_config`. The plugin assumes that `for_each` has an expression which is evaluated to a `list` or `set` of objects.
7979
This is an example of how to use dynamic blocks in `regions_config`:
8080
```hcl
81-
replication_specs {
82-
num_shards = var.replication_specs.num_shards
83-
zone_name = var.replication_specs.zone_name # only needed if you're using zones
81+
replication_specs {
82+
num_shards = var.replication_specs.num_shards
83+
zone_name = var.replication_specs.zone_name # only needed if you're using zones
84+
dynamic "regions_config" {
85+
for_each = var.replication_specs.regions_config
86+
content {
87+
priority = regions_config.value.priority
88+
region_name = regions_config.value.region_name
89+
electable_nodes = regions_config.value.electable_nodes
90+
read_only_nodes = regions_config.value.read_only_nodes
91+
}
92+
}
93+
}
94+
```
95+
Dynamic block and individual blocks for `regions_config` are not supported at the same time. If you need this use case, please send us [feedback](https://github.com/mongodb-labs/atlas-cli-plugin-terraform/issues). There are currently two main approaches to handle this:
96+
- (Recommended) Remove the individual `regions_config` blocks and add their information to the variable you're using in the `for_each` expression, e.g. using [concat](https://developer.hashicorp.com/terraform/language/functions/concat) if you're using a list or [setunion](https://developer.hashicorp.com/terraform/language/functions/setunion) for sets. In this way, you don't need to change the generated `mongodb_advanced_cluster` configuration.
97+
- Change the generated `mongodb_advanced_cluster` configuration to join the individual blocks to the code generated for the `dynamic` block. This approach is more error-prone.
98+
99+
#### Dynamic blocks in replication_specs
100+
101+
You can use `dynamic` blocks for `replication_specs`. The plugin assumes that `for_each` has an expression which is evaluated to a `list` of objects.
102+
This is an example of how to use dynamic blocks in `replication_specs`:
103+
```hcl
104+
dynamic "replication_specs" {
105+
for_each = var.replication_specs
106+
content {
107+
num_shards = replication_specs.value.num_shards
108+
zone_name = replication_specs.value.zone_name # only needed if you're using zones
84109
dynamic "regions_config" {
85-
for_each = var.replication_specs.regions_config
110+
for_each = replication_specs.value.regions_config
86111
content {
87-
priority = regions_config.value.priority
88-
region_name = regions_config.value.region_name
89112
electable_nodes = regions_config.value.electable_nodes
113+
priority = regions_config.value.priority
90114
read_only_nodes = regions_config.value.read_only_nodes
115+
region_name = regions_config.value.region_name
91116
}
92117
}
93118
}
94-
```
95-
Dynamic block and individual blocks for `regions_config` are not supported at the same time. If you need this use case, please send us [feedback](https://github.com/mongodb-labs/atlas-cli-plugin-terraform/issues). There are currently two main approaches to handle this:
96-
- (Recommended) Remove the individual `regions_config` blocks and add their information to the variable you're using in the `for_each` expression, e.g. using [concat](https://developer.hashicorp.com/terraform/language/functions/concat) if you're using a list or [setunion](https://developer.hashicorp.com/terraform/language/functions/setunion) for sets. In this way, you don't need to change the generated `mongodb_advanced_cluster` configuration.
97-
- Change the generated `mongodb_advanced_cluster` configuration to join the individual blocks to the code generated for the `dynamic` block. This approach is more error-prone.
119+
}
120+
Dynamic block and individual blocks for `replication_specs` are not supported at the same time. If you need this use case, please send us [feedback](https://github.com/mongodb-labs/atlas-cli-plugin-terraform/issues). You can handle this following the same approaches as for [`regions_config`](#dynamic-blocks-in-regions_config).
98121
99122
### Limitations
100123
101124
- [`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`. This limitation doesn't apply if you're using `dynamic` blocks in `regions_config` or `replication_specs`.
102-
- `dynamic` blocks are currently supported only for `tags`, `labels` and `regions_config`. See limitations for `regions_config` support in [its section](#dynamic-blocks-in-regions_config) above. **Coming soon**: support for `replication_specs`.
125+
- `dynamic` blocks are supported for `tags`, `labels`, `regions_config` and `replication_specs`. See limitations for [`regions_config`](#dynamic-blocks-in-regions_config) and [`replication_specs`](#dynamic-blocks-in-replication_specs) in their sections above.
103126
104127
## Feedback
105128

0 commit comments

Comments
 (0)