Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/convert/adv2v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func updateResource(resource *hclwrite.Block) (bool, error) {
if err := fillTagsLabelsOpt(resourceb, nLabels); err != nil {
return false, err
}
fillBlockOpt(resourceb, nAdvConf)
fillAdvConfigOpt(resourceb)
fillBlockOpt(resourceb, nBiConnector)
fillBlockOpt(resourceb, nPinnedFCV)
fillBlockOpt(resourceb, nTimeouts)
Expand Down Expand Up @@ -132,7 +132,7 @@ func hasExpectedBlocksAsAttributes(resourceb *hclwrite.Body) bool {
nRepSpecs,
nTags,
nLabels,
nAdvConf,
nAdvConfig,
nBiConnector,
nPinnedFCV,
nTimeouts,
Expand Down
17 changes: 15 additions & 2 deletions internal/convert/clu2adv.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func convertDataSource(block *hclwrite.Block) bool {
}
if newName, found := convertMap[getResourceName(block)]; found {
setResourceName(block, newName)
block.Body().SetAttributeValue(nUseRepSpecsPerShard, cty.True)
return true
}
return false
Expand Down Expand Up @@ -165,7 +164,7 @@ func fillCluster(resourceb *hclwrite.Body) error {
if err := fillTagsLabelsOpt(resourceb, nLabels); err != nil {
return err
}
fillBlockOpt(resourceb, nAdvConf)
fillAdvConfigOpt(resourceb)
fillBlockOpt(resourceb, nBiConnector)
fillBlockOpt(resourceb, nPinnedFCV)
fillBlockOpt(resourceb, nTimeouts)
Expand Down Expand Up @@ -304,6 +303,20 @@ func fillBlockOpt(resourceb *hclwrite.Body, name string) {
resourceb.SetAttributeRaw(name, hcl.TokensObject(block.Body()))
}

func fillAdvConfigOpt(resourceb *hclwrite.Body) {
block := resourceb.FirstMatchingBlock(nAdvConfig, nil)
if block == nil {
return
}
blockBody := block.Body()

// Remove deprecated attributes from advanced_configuration
blockBody.RemoveAttribute(nFailIndexKeyTooLong)
blockBody.RemoveAttribute(nDefaultReadConcern)

fillBlockOpt(resourceb, nAdvConfig)
}

// fillReplicationSpecsWithDynamicBlock used for dynamic blocks in replication_specs
func fillReplicationSpecsWithDynamicBlock(resourceb *hclwrite.Body, root attrVals) (dynamicBlock, error) {
dSpec, err := getDynamicBlock(resourceb, nRepSpecs)
Expand Down
5 changes: 3 additions & 2 deletions internal/convert/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
nTags = "tags"
nLabels = "labels"
nTimeouts = "timeouts"
nAdvConf = "advanced_configuration"
nAdvConfig = "advanced_configuration"
nPinnedFCV = "pinned_fcv"
nBiConnector = "bi_connector_config"
nElectableSpecs = "electable_specs"
Expand Down Expand Up @@ -70,7 +70,6 @@ const (
nZoneName = "zone_name"
nKey = "key"
nValue = "value"
nUseRepSpecsPerShard = "use_replication_spec_per_shard"
nMoved = "moved"
nFrom = "from"
nTo = "to"
Expand All @@ -79,4 +78,6 @@ const (
nContent = "content"
nRegion = "region"
nSpec = "spec"
nFailIndexKeyTooLong = "fail_index_key_too_long"
nDefaultReadConcern = "default_read_concern"
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ resource "mongodbatlas_advanced_cluster" "this" {

advanced_configuration {
# comments in advanced_configuration are kept
javascript_enabled = true
javascript_enabled = true
fail_index_key_too_long = false # deprecated so removed in output
default_read_concern = "available" # deprecated so removed in output
}

bi_connector_config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ resource "mongodbatlas_cluster" "this" {
provider_instance_size_name = var.instance_size
advanced_configuration {
# comments in advanced_configuration are kept
javascript_enabled = true
javascript_enabled = true
fail_index_key_too_long = false # deprecated so removed in output
default_read_concern = "available" # deprecated so removed in output
}
bi_connector_config {
# comments in bi_connector_config are kept
Expand Down
10 changes: 4 additions & 6 deletions internal/convert/testdata/clu2adv/data_sources.out.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
data "mongodbatlas_advanced_cluster" "singular" {
# data source content is kept - singular
project_id = mongodbatlas_advanced_cluster.example.project_id
name = mongodbatlas_advanced_cluster.example.name
depends_on = [mongodbatlas_privatelink_endpoint_service.example_endpoint]
use_replication_spec_per_shard = true
project_id = mongodbatlas_advanced_cluster.example.project_id
name = mongodbatlas_advanced_cluster.example.name
depends_on = [mongodbatlas_privatelink_endpoint_service.example_endpoint]

# Generated by atlas-cli-plugin-terraform.
# Please review the changes and confirm that references to this resource are updated.
}

data "mongodbatlas_advanced_clusters" "plural" {
# data source content is kept - plural
project_id = mongodbatlas_advanced_cluster.example.project_id
use_replication_spec_per_shard = true
project_id = mongodbatlas_advanced_cluster.example.project_id

# Generated by atlas-cli-plugin-terraform.
# Please review the changes and confirm that references to this resource are updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ resource "mongodbatlas_cluster" "cluster" {
}

advanced_configuration {
fail_index_key_too_long = false # deprecated so removed in output
default_read_concern = "available" # deprecated so removed in output
oplog_size_mb = var.oplog_size_mb
transaction_lifetime_limit_seconds = var.transaction_lifetime_limit_seconds
minimum_enabled_tls_protocol = "TLS1_2"
Expand Down