-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Supports dynamic blocks in regions_config #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
c7857b0
doc assumption for dynamic blocks in tags and labels
lantoli 72a2fbc
dynamic_regions_config example
lantoli 26d2183
range for priorities
lantoli cf5e3f7
allow dynamic block in regions_config
lantoli 771845c
doc
lantoli 5dfbede
update comment
lantoli 17a6444
minimum implementation to have test failing because difference in gol…
lantoli 0f10bb9
export enclose funcs
lantoli 44a4bc7
create EncloseNewLines and remove SetAttrExpr
lantoli 130009b
root replication_specs
lantoli b1dc050
remove priority checks about numerical literal
lantoli c5e6d5f
reuse getRegionConfig from dynamic block logic
lantoli ae8471b
only sort by priority if all priorities are numerical literals
lantoli 3f93627
remove limitations for priority and electable_nodes
lantoli ff3fc22
use config in dynamic blocks from individual
lantoli 87bf0fc
passing test
lantoli b4db307
add auto_scaling example
lantoli 969da96
fix region_configs name replacement
lantoli 55b93fd
refactor isDynamicBlock
lantoli 6186dcd
go back to unexported tokenNewLine
lantoli 1883ff0
add analytics specs
lantoli 032c072
Merge branch 'main' into CLOUDP-303941_regions_config
lantoli 4684c7c
example in readme
lantoli 861a6c4
clarify num_shards limitation
lantoli 165256e
feedback section
lantoli 11314b5
getDynamicBlockRegionConfigsRegionArray
lantoli b2c3161
refactor fillRegionConfigsDynamicBlock
lantoli 8f6e967
EncloseBracketsNewLines
lantoli 0f2dfeb
fillRegionConfigsDynamicBlock doc
lantoli 876b6eb
move shards closer to where it's used
lantoli 4ab2d3a
add comment for priority loop
lantoli 32ca654
add dynamic block doc
lantoli 0d61fe7
small doc adjustment
lantoli 5fa1cb7
rename to fillReplicationSpecsWithDynamicRegionConfigs
lantoli b8258ae
Update README.md
lantoli f90d5a2
link to limitations
lantoli 2bec1f9
how to handle limitation
lantoli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
internal/convert/testdata/clu2adv/dynamic_regions_config.in.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
resource "mongodbatlas_cluster" "dynamic_regions_config" { | ||
project_id = var.project_id | ||
name = "cluster" | ||
cluster_type = "SHARDED" | ||
provider_name = "AWS" | ||
provider_instance_size_name = "M10" | ||
replication_specs { | ||
num_shards = var.replication_specs.num_shards | ||
dynamic "regions_config" { | ||
for_each = var.replication_specs.regions_config | ||
content { | ||
region_name = regions_config.value.region_name | ||
electable_nodes = regions_config.value.electable_nodes | ||
priority = regions_config.value.priority | ||
read_only_nodes = regions_config.value.read_only_nodes | ||
} | ||
} | ||
} | ||
} | ||
|
||
# example of variable for demostration purposes, not used in the conversion | ||
variable "replication_specs" { | ||
type = object({ | ||
num_shards = number | ||
regions_config = set(object({ | ||
region_name = string | ||
electable_nodes = number | ||
priority = number | ||
read_only_nodes = number | ||
})) | ||
}) | ||
default = { | ||
num_shards = 3 | ||
regions_config = [ | ||
{ | ||
region_name = "US_EAST_1" | ||
electable_nodes = 3 | ||
priority = 7 | ||
read_only_nodes = 0 | ||
}, | ||
{ | ||
region_name = "US_WEST_2" | ||
electable_nodes = 2 | ||
priority = 6 | ||
read_only_nodes = 1 | ||
} | ||
] | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
internal/convert/testdata/clu2adv/dynamic_regions_config.out.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
resource "mongodbatlas_advanced_cluster" "dynamic_regions_config" { | ||
project_id = var.project_id | ||
name = "cluster" | ||
cluster_type = "SHARDED" | ||
replication_specs = [ | ||
for i in range(var.replication_specs.num_shards) : { | ||
region_configs = flatten([ | ||
for priority in range(7, 0, -1) : [ | ||
for region in var.replication_specs.regions_config : { | ||
provider_name = "AWS" | ||
region_name = region.region_name | ||
priority = region.priority | ||
electable_specs = region.electable_nodes > 0 ? { | ||
node_count = region.electable_nodes | ||
instance_size = "M10" | ||
} : null | ||
read_only_specs = region.read_only_nodes > 0 ? { | ||
node_count = region.read_only_nodes | ||
instance_size = "M10" | ||
} : null | ||
} if region.priority == priority | ||
] | ||
]) | ||
} | ||
] | ||
|
||
# Generated by atlas-cli-plugin-terraform. | ||
# Please review the changes and confirm that references to this resource are updated. | ||
} | ||
|
||
# example of variable for demostration purposes, not used in the conversion | ||
variable "replication_specs" { | ||
type = object({ | ||
num_shards = number | ||
regions_config = set(object({ | ||
region_name = string | ||
electable_nodes = number | ||
priority = number | ||
read_only_nodes = number | ||
})) | ||
}) | ||
default = { | ||
num_shards = 3 | ||
regions_config = [ | ||
{ | ||
region_name = "US_EAST_1" | ||
electable_nodes = 3 | ||
priority = 7 | ||
read_only_nodes = 0 | ||
}, | ||
{ | ||
region_name = "US_WEST_2" | ||
electable_nodes = 2 | ||
priority = 6 | ||
read_only_nodes = 1 | ||
} | ||
] | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.