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
Copy file name to clipboardExpand all lines: README.md
+38-4Lines changed: 38 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
This repository contains the Atlas CLI plugin for [Terraform's MongoDB Atlas Provider](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs).
6
6
7
7
It has the following commands to help with your Terraform configurations:
8
-
-**clusterToAdvancedCluster**: Convert a `mongodbatlas_cluster` Terraform configuration to `mongodbatlas_advanced_cluster` (preview provider v2).
8
+
-**clusterToAdvancedCluster**: Convert a `mongodbatlas_cluster` Terraform configuration to `mongodbatlas_advanced_cluster` (preview provider 2.0.0).
9
9
10
10
## Installation
11
11
@@ -15,12 +15,22 @@ Install the plugin by running:
If you want to see the list of installed plugins or check if this plugin is installed, run:
25
+
```bash
26
+
atlas plugin list
27
+
```
18
28
19
-
## Convert mongodbatlas_cluster to mongodbatlas_advanced_cluster (preview provider v2)
29
+
## Convert mongodbatlas_cluster to mongodbatlas_advanced_cluster (preview provider 2.0.0)
20
30
21
31
### Usage
22
32
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`.
33
+
**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
34
25
35
If you want to convert a Terraform configuration from `mongodbatlas_cluster` to `mongodbatlas_advanced_cluster`, use the following command:
26
36
```bash
@@ -38,12 +48,36 @@ If you want to overwrite the output file if it exists, or even use the same outp
38
48
39
49
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
50
51
+
You can find [here](https://github.com/mongodb-labs/atlas-cli-plugin-terraform/tree/main/internal/convert/testdata/clu2adv) some examples of input files (suffix .in.tf) and the corresponding output files (suffix .out.tf).
52
+
53
+
### Dynamic blocks
54
+
55
+
`dynamic` blocks are used to generate multiple nested blocks based on a set of values.
56
+
Given the different ways of using dynamic blocks, we recommend reviewing the output and making sure it fits your needs.
57
+
58
+
#### Dynamic blocks in tags and labels
59
+
60
+
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.:
61
+
```hcl
62
+
tags {
63
+
key = "environment"
64
+
value = var.environment
65
+
}
66
+
dynamic "tags" {
67
+
for_each = var.tags
68
+
content {
69
+
key = tags.key
70
+
value = replace(tags.value, "/", "_")
71
+
}
72
+
}
73
+
```
74
+
41
75
### Limitations
42
76
43
77
- 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
78
-[`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
79
-[`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.
80
+
-`dynamic` blocks are currently supported only for `tags` and `labels`. **Coming soon**: support for `replication_specs` and `regions_config`.
0 commit comments