Skip to content
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

chore: Deprecates attributes associated to old mongodbatlas_advanced_cluster resource & data source schemas #2421

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
64 changes: 64 additions & 0 deletions .changelog/2420.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
```release-note:note
maastha marked this conversation as resolved.
Show resolved Hide resolved
resource/mongodbatlas_advanced_cluster: Deprecates `replication_specs.#.id` attribute
```

```release-note:note
resource/mongodbatlas_advanced_cluster: Deprecates `replication_specs.#.num_shards` attribute
```

```release-note:note
resource/mongodbatlas_advanced_cluster: Deprecates `disk_size_gb` attribute
```

```release-note:note
resource/mongodbatlas_advanced_cluster: Deprecates `advanced_configuration.0.default_read_concern` attribute
```

```release-note:note
resource/mongodbatlas_advanced_cluster: Deprecates `advanced_configuration.0.fail_index_key_too_long` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_cluster: Deprecates `replication_specs.#.id` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_cluster: Deprecates `replication_specs.#.num_shards` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_cluster: Deprecates `disk_size_gb` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_cluster: Deprecates `advanced_configuration.0.default_read_concern` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_cluster: Deprecates `advanced_configuration.0.fail_index_key_too_long` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_clusters: Deprecates `replication_specs.#.id` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_clusters: Deprecates `replication_specs.#.num_shards` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_clusters: Deprecates `disk_size_gb` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_clusters: Deprecates `advanced_configuration.0.default_read_concern` attribute
```

```release-note:note
data-source/mongodbatlas_advanced_clusters: Deprecates `advanced_configuration.0.fail_index_key_too_long` attribute
```





1 change: 1 addition & 0 deletions internal/common/constant/deprecation.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package constant

const (
DeprecationParam = "This parameter is deprecated."
maastha marked this conversation as resolved.
Show resolved Hide resolved
DeprecationParamByDate = "This parameter is deprecated and will be removed by %s."
DeprecationParamByDateWithReplacement = "This parameter is deprecated and will be removed by %s. Please transition to %s."
DeprecationParamByVersion = "This parameter is deprecated and will be removed in version %s."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
)

// replication_specs.id, num_shards, disk_size_gb, default_read_concern, and fail_index_key_too_long

func DataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceRead,
Expand Down Expand Up @@ -61,8 +63,9 @@ func DataSource() *schema.Resource {
Computed: true,
},
"disk_size_gb": {
Type: schema.TypeFloat,
Computed: true,
Type: schema.TypeFloat,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"encryption_at_rest_provider": {
Type: schema.TypeString,
Expand Down Expand Up @@ -113,8 +116,9 @@ func DataSource() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"zone_id": {
Type: schema.TypeString,
Expand All @@ -125,8 +129,9 @@ func DataSource() *schema.Resource {
Computed: true,
},
"num_shards": {
Type: schema.TypeInt,
Computed: true,
Type: schema.TypeInt,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"region_configs": {
Type: schema.TypeList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ func PluralDataSource() *schema.Resource {
Computed: true,
},
"disk_size_gb": {
Type: schema.TypeFloat,
Computed: true,
Type: schema.TypeFloat,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"encryption_at_rest_provider": {
Type: schema.TypeString,
Expand Down Expand Up @@ -116,12 +117,14 @@ func PluralDataSource() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"num_shards": {
Type: schema.TypeInt,
Computed: true,
Type: schema.TypeInt,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"region_configs": {
Type: schema.TypeList,
Expand Down
24 changes: 14 additions & 10 deletions internal/service/advancedcluster/model_advanced_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@ func SchemaAdvancedConfigDS() *schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"default_read_concern": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"default_write_concern": {
Type: schema.TypeString,
Computed: true,
},
"fail_index_key_too_long": {
Type: schema.TypeBool,
Computed: true,
Type: schema.TypeBool,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"javascript_enabled": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -191,19 +193,21 @@ func SchemaAdvancedConfig() *schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"default_read_concern": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"default_write_concern": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"fail_index_key_too_long": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Type: schema.TypeBool,
Optional: true,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"javascript_enabled": {
Type: schema.TypeBool,
Expand Down
17 changes: 11 additions & 6 deletions internal/service/advancedcluster/resource_advanced_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ const (
ErrorAdvancedClusterListStatus = "error awaiting MongoDB ClusterAdvanced List IDLE: %s"
ErrorOperationNotPermitted = "error operation not permitted"
ignoreLabel = "Infrastructure Tool"
DeprecationOldSchemaAction = "Please refer to our examples, documentation, and 1.18.0 migration guide for more details"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a link to somewhere here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps to the migration guide?

Copy link
Collaborator Author

@maastha maastha Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added link to migration guide

)

type acCtxKey string

var upgradeRequestCtxKey acCtxKey = "upgradeRequest"
var DeprecationMsgOldSchema = fmt.Sprintf("%s %s", constant.DeprecationParam, DeprecationOldSchemaAction)

func Resource() *schema.Resource {
return &schema.Resource{
Expand Down Expand Up @@ -113,9 +115,10 @@ func Resource() *schema.Resource {
Computed: true,
},
"disk_size_gb": {
Type: schema.TypeFloat,
Optional: true,
Computed: true,
Type: schema.TypeFloat,
Optional: true,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
},
"encryption_at_rest_provider": {
Type: schema.TypeString,
Expand Down Expand Up @@ -172,8 +175,9 @@ func Resource() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Deprecated: DeprecationMsgOldSchema,
maastha marked this conversation as resolved.
Show resolved Hide resolved
},
"zone_id": {
Type: schema.TypeString,
Expand All @@ -188,6 +192,7 @@ func Resource() *schema.Resource {
Optional: true,
Default: 1,
ValidateFunc: validation.IntBetween(1, 50),
Deprecated: DeprecationMsgOldSchema,
},
"region_configs": {
Type: schema.TypeList,
Expand Down Expand Up @@ -855,7 +860,7 @@ func isUpdateAllowed(d *schema.ResourceData) (bool, error) {
if specMap, ok := specRaw.(map[string]any); ok && specMap != nil {
numShards, _ := specMap["num_shards"].(int)
if numShards > 1 && isNewSchemaCompatible {
return false, fmt.Errorf("cannot increase num_shards to > 1 under the current configuration. New shards can be defined by adding new replication spec objects; please refer to our examples, documentation, and 1.18.0 migration guide for more details")
return false, fmt.Errorf("cannot increase num_shards to > 1 under the current configuration. New shards can be defined by adding new replication spec objects; %s", DeprecationOldSchemaAction)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions website/docs/d/advanced_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ In addition to all arguments above, the following attributes are exported:
* `id` - The cluster ID.
* `bi_connector_config` - Configuration settings applied to BI Connector for Atlas on this cluster. See [below](#bi_connector_config). **NOTE** Prior version of provider had parameter as `bi_connector`
* `cluster_type` - Type of the cluster that you want to create.
* `disk_size_gb` - Capacity, in gigabytes, of the host's root volume.
* `disk_size_gb` - **(DEPRECATED)** Capacity, in gigabytes, of the host's root volume.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention here "use the one under replication_spec"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, lmk WYT

* `encryption_at_rest_provider` - Possible values are AWS, GCP, AZURE or NONE.
* `tags` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags).
* `labels` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#labels). **DEPRECATED** Use `tags` instead.
Expand Down Expand Up @@ -98,7 +98,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le

### replication_specs

* `num_shards` - Provide this value if you set a `cluster_type` of SHARDED or GEOSHARDED.
* `num_shards` - **(DEPRECATED)** Provide this value if you set a `cluster_type` of SHARDED or GEOSHARDED.
* `region_configs` - Configuration for the hardware specifications for nodes set for a given regionEach `region_configs` object describes the region's priority in elections and the number and type of MongoDB nodes that Atlas deploys to the region. Each `region_configs` object must have either an `analytics_specs` object, `electable_specs` object, or `read_only_specs` object. See [below](#region_configs)
* `container_id` - A key-value map of the Network Peering Container ID(s) for the configuration specified in `region_configs`. The Container ID is the id of the container either created programmatically by the user before any clusters existed in a project or when the first cluster in the region (AWS/Azure) or project (GCP) was created. The syntax is `"providerName:regionName" = "containerId"`. Example `AWS:US_EAST_1" = "61e0797dde08fb498ca11a71`.
* `zone_name` - Name for the zone in a Global Cluster.
Expand Down Expand Up @@ -142,9 +142,9 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le
* `compute_max_instance_size` - Maximum instance size to which your cluster can automatically scale (such as M40).
#### Advanced Configuration

* `default_read_concern` - [Default level of acknowledgment requested from MongoDB for read operations](https://docs.mongodb.com/manual/reference/read-concern/) set for this cluster. MongoDB 4.4 clusters default to [available](https://docs.mongodb.com/manual/reference/read-concern-available/).
* `default_read_concern` - **(DEPRECATED)** [Default level of acknowledgment requested from MongoDB for read operations](https://docs.mongodb.com/manual/reference/read-concern/) set for this cluster. MongoDB 4.4 clusters default to [available](https://docs.mongodb.com/manual/reference/read-concern-available/).
* `default_write_concern` - [Default level of acknowledgment requested from MongoDB for write operations](https://docs.mongodb.com/manual/reference/write-concern/) set for this cluster. MongoDB 4.4 clusters default to [1](https://docs.mongodb.com/manual/reference/write-concern/).
* `fail_index_key_too_long` - When true, documents can only be updated or inserted if, for all indexed fields on the target collection, the corresponding index entries do not exceed 1024 bytes. When false, mongod writes documents that exceed the limit but does not index them.
* `fail_index_key_too_long` - **(DEPRECATED)** When true, documents can only be updated or inserted if, for all indexed fields on the target collection, the corresponding index entries do not exceed 1024 bytes. When false, mongod writes documents that exceed the limit but does not index them.
* `javascript_enabled` - When true, the cluster allows execution of operations that perform server-side executions of JavaScript. When false, the cluster disables execution of those operations.
* `minimum_enabled_tls_protocol` - Sets the minimum Transport Layer Security (TLS) version the cluster accepts for incoming connections.Valid values are:

Expand Down
8 changes: 4 additions & 4 deletions website/docs/d/advanced_clusters.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ In addition to all arguments above, the following attributes are exported:

* `bi_connector_config` - Configuration settings applied to BI Connector for Atlas on this cluster. See [below](#bi_connector_config). **NOTE** Prior version of provider had parameter as `bi_connector`
* `cluster_type` - Type of the cluster that you want to create.
* `disk_size_gb` - Capacity, in gigabytes, of the host's root volume.
* `disk_size_gb` - **(DEPRECATED)** Capacity, in gigabytes, of the host's root volume.
* `encryption_at_rest_provider` - Possible values are AWS, GCP, AZURE or NONE.
* `tags` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags).
* `labels` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#labels).
Expand Down Expand Up @@ -100,7 +100,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le

### replication_specs

* `num_shards` - Provide this value if you set a `cluster_type` of SHARDED or GEOSHARDED.
* `num_shards` - **(DEPRECATED)** Provide this value if you set a `cluster_type` of SHARDED or GEOSHARDED.
* `region_configs` - Configuration for the hardware specifications for nodes set for a given regionEach `region_configs` object describes the region's priority in elections and the number and type of MongoDB nodes that Atlas deploys to the region. Each `region_configs` object must have either an `analytics_specs` object, `electable_specs` object, or `read_only_specs` object. See [below](#region_configs)
* `container_id` - A key-value map of the Network Peering Container ID(s) for the configuration specified in `region_configs`. The Container ID is the id of the container either created programmatically by the user before any clusters existed in a project or when the first cluster in the region (AWS/Azure) or project (GCP) was created. The syntax is `"providerName:regionName" = "containerId"`. Example `AWS:US_EAST_1" = "61e0797dde08fb498ca11a71`.
* `zone_name` - Name for the zone in a Global Cluster.
Expand Down Expand Up @@ -145,9 +145,9 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le

#### Advanced Configuration

* `default_read_concern` - [Default level of acknowledgment requested from MongoDB for read operations](https://docs.mongodb.com/manual/reference/read-concern/) set for this cluster. MongoDB 4.4 clusters default to [available](https://docs.mongodb.com/manual/reference/read-concern-available/).
* `default_read_concern` - **(DEPRECATED)** [Default level of acknowledgment requested from MongoDB for read operations](https://docs.mongodb.com/manual/reference/read-concern/) set for this cluster. MongoDB 4.4 clusters default to [available](https://docs.mongodb.com/manual/reference/read-concern-available/).
* `default_write_concern` - [Default level of acknowledgment requested from MongoDB for write operations](https://docs.mongodb.com/manual/reference/write-concern/) set for this cluster. MongoDB 4.4 clusters default to [1](https://docs.mongodb.com/manual/reference/write-concern/).
* `fail_index_key_too_long` - When true, documents can only be updated or inserted if, for all indexed fields on the target collection, the corresponding index entries do not exceed 1024 bytes. When false, mongod writes documents that exceed the limit but does not index them.
* `fail_index_key_too_long` - **(DEPRECATED)** When true, documents can only be updated or inserted if, for all indexed fields on the target collection, the corresponding index entries do not exceed 1024 bytes. When false, mongod writes documents that exceed the limit but does not index them.
* `javascript_enabled` - When true, the cluster allows execution of operations that perform server-side executions of JavaScript. When false, the cluster disables execution of those operations.
* `minimum_enabled_tls_protocol` - Sets the minimum Transport Layer Security (TLS) version the cluster accepts for incoming connections.Valid values are:

Expand Down
Loading
Loading