Skip to content

Commit 52d6f00

Browse files
authored
chore: Merges redaction log feature to master (#2634)
* feat: Supports `redact_client_log_data` in `mongodbatlas_advanced_cluster` (#2600) * use SDK Preview * add redact_client_log_data to schema * plural ds * resource * tests * changelog * feat: Supports `redact_client_log_data` in `mongodbatlas_cluster` (#2601) * doc * changelog * new atlas functions * data sources * resource * tests * rename CRUD functions * wait for cluster changes * apply feedback for changelog * use acc.CheckRSAndDS * fix ret * additional comment in cluster * Revert "additional comment in cluster" This reverts commit ce69fa1. * additional comment in cluster * refactor StateChangeConf * remove ResourceClusterRefreshFunc * attribute not necessary * fix update in cluster * fix plural ds tests
1 parent bc70a61 commit 52d6f00

18 files changed

+381
-179
lines changed

.changelog/2600.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```release-note:enhancement
2+
resource/mongodbatlas_advanced_cluster: Supports `redact_client_log_data` attribute
3+
```
4+
5+
```release-note:enhancement
6+
data-source/mongodbatlas_advanced_cluster: Supports `redact_client_log_data` attribute
7+
```
8+
9+
```release-note:enhancement
10+
data-source/mongodbatlas_advanced_clusters: Supports `redact_client_log_data` attribute
11+
```

.changelog/2601.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```release-note:enhancement
2+
resource/mongodbatlas_cluster: Supports `redact_client_log_data` attribute
3+
```
4+
5+
```release-note:enhancement
6+
data-source/mongodbatlas_cluster: Supports `redact_client_log_data` attribute
7+
```
8+
9+
```release-note:enhancement
10+
data-source/mongodbatlas_clusters: Supports `redact_client_log_data` attribute
11+
```

docs/data-sources/advanced_cluster.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ In addition to all arguments above, the following attributes are exported:
104104
* `advanced_configuration` - Get the advanced configuration options. See [Advanced Configuration](#advanced-configuration) below for more details.
105105
* `global_cluster_self_managed_sharding` - Flag that indicates if cluster uses Atlas-Managed Sharding (false) or Self-Managed Sharding (true).
106106
* `replica_set_scaling_strategy` - (Optional) Replica set scaling mode for your cluster.
107+
* `redact_client_log_data` - (Optional) Flag that enables or disables log redaction, see [param reference](https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.redactClientLogData) for more info.
107108

108109
### bi_connector_config
109110

docs/data-sources/advanced_clusters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ In addition to all arguments above, the following attributes are exported:
106106
* `advanced_configuration` - Get the advanced configuration options. See [Advanced Configuration](#advanced-configuration) below for more details.
107107
* `global_cluster_self_managed_sharding` - Flag that indicates if cluster uses Atlas-Managed Sharding (false) or Self-Managed Sharding (true).
108108
* `replica_set_scaling_strategy` - (Optional) Replica set scaling mode for your cluster.
109+
* `redact_client_log_data` - (Optional) Flag that enables or disables log redaction, see [param reference](https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.redactClientLogData) for more info.
109110

110111
### bi_connector_config
111112

docs/data-sources/cluster.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ In addition to all arguments above, the following attributes are exported:
128128

129129
* `advanced_configuration` - Get the advanced configuration options. See [Advanced Configuration](#advanced-configuration) below for more details.
130130

131+
* `redact_client_log_data` - (Optional) Flag that enables or disables log redaction, see [param reference](https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.redactClientLogData) for more info.
132+
131133
### BI Connector
132134

133135
Indicates BI Connector for Atlas configuration.

docs/data-sources/clusters.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ In addition to all arguments above, the following attributes are exported:
119119

120120
* `advanced_configuration` - Get the advanced configuration options. See [Advanced Configuration](#advanced-configuration) below for more details.
121121

122+
* `redact_client_log_data` - (Optional) Flag that enables or disables log redaction, see [param reference](https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.redactClientLogData) for more info.
123+
122124
### BI Connector
123125

124126
Indicates BI Connector for Atlas configuration.

docs/resources/advanced_cluster.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ This parameter defaults to false.
399399
* `accept_data_risks_and_force_replica_set_reconfig` - (Optional) If reconfiguration is necessary to regain a primary due to a regional outage, submit this field alongside your topology reconfiguration to request a new regional outage resistant topology. Forced reconfigurations during an outage of the majority of electable nodes carry a risk of data loss if replicated writes (even majority committed writes) have not been replicated to the new primary node. MongoDB Atlas docs contain more information. To proceed with an operation which carries that risk, set `accept_data_risks_and_force_replica_set_reconfig` to the current date. Learn more about Reconfiguring a Replica Set during a regional outage [here](https://dochub.mongodb.org/core/regional-outage-reconfigure-replica-set).
400400
* `global_cluster_self_managed_sharding` - (Optional) Flag that indicates if cluster uses Atlas-Managed Sharding (false, default) or Self-Managed Sharding (true). It can only be enabled for Global Clusters (`GEOSHARDED`). It cannot be changed once the cluster is created. Use this mode if you're an advanced user and the default configuration is too restrictive for your workload. If you select this option, you must manually configure the sharding strategy, more info [here](https://www.mongodb.com/docs/atlas/tutorial/create-global-cluster/#select-your-sharding-configuration).
401401
* `replica_set_scaling_strategy` - (Optional) Replica set scaling mode for your cluster. Valid values are `WORKLOAD_TYPE`, `SEQUENTIAL` and `NODE_TYPE`. By default, Atlas scales under `WORKLOAD_TYPE`. This mode allows Atlas to scale your analytics nodes in parallel to your operational nodes. When configured as `SEQUENTIAL`, Atlas scales all nodes sequentially. This mode is intended for steady-state workloads and applications performing latency-sensitive secondary reads. When configured as `NODE_TYPE`, Atlas scales your electable nodes in parallel with your read-only and analytics nodes. This mode is intended for large, dynamic workloads requiring frequent and timely cluster tier scaling. This is the fastest scaling strategy, but it might impact latency of workloads when performing extensive secondary reads. [Modify the Replica Set Scaling Mode](https://dochub.mongodb.org/core/scale-nodes)
402+
* `redact_client_log_data` - (Optional) Flag that enables or disables log redaction, see [param reference](https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.redactClientLogData) for more info.
402403

403404
### bi_connector_config
404405

docs/resources/cluster.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ But in order to explicitly change `provider_instance_size_name` comment the `lif
387387
- `LTS`: Atlas creates your cluster using the latest patch release of the MongoDB version that you specify in the mongoDBMajorVersion field. Atlas automatically updates your cluster to subsequent patch releases of this MongoDB version. Atlas doesn't update your cluster to newer rapid or major MongoDB releases as they become available.
388388
* `timeouts`- (Optional) The duration of time to wait for Cluster to be created, updated, or deleted. The timeout value is defined by a signed sequence of decimal numbers with an time unit suffix such as: `1h45m`, `300s`, `10m`, .... The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. The default timeout for Cluster create & delete is `3h`. Learn more about timeouts [here](https://www.terraform.io/plugin/sdkv2/resources/retries-and-customizable-timeouts).
389389
* `accept_data_risks_and_force_replica_set_reconfig`- (Optional) If reconfiguration is necessary to regain a primary due to a regional outage, submit this field alongside your topology reconfiguration to request a new regional outage resistant topology. Forced reconfigurations during an outage of the majority of electable nodes carry a risk of data loss if replicated writes (even majority committed writes) have not been replicated to the new primary node. MongoDB Atlas docs contain more information. To proceed with an operation which carries that risk, set `accept_data_risks_and_force_replica_set_reconfig` to the current date. Learn more about Reconfiguring a Replica Set during a regional outage [here](https://dochub.mongodb.org/core/regional-outage-reconfigure-replica-set).
390+
* `redact_client_log_data` - (Optional) Flag that enables or disables log redaction, see [param reference](https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.redactClientLogData) for more info. The log redaction field is updated via an Atlas API call after cluster creation. Consequently, there may be a brief period during resource creation when log redaction is not yet enabled. To ensure complete log redaction from the outset, use `mongodbatlas_advanced_cluster`.
390391

391392
### Multi-Region Cluster
392393

internal/service/advancedcluster/data_source_advanced_cluster.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ func DataSource() *schema.Resource {
250250
Type: schema.TypeString,
251251
Computed: true,
252252
},
253+
"redact_client_log_data": {
254+
Type: schema.TypeBool,
255+
Computed: true,
256+
},
253257
},
254258
}
255259
}
@@ -294,6 +298,9 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.
294298
if err := d.Set("replica_set_scaling_strategy", clusterDescNew.GetReplicaSetScalingStrategy()); err != nil {
295299
return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replica_set_scaling_strategy", clusterName, err))
296300
}
301+
if err := d.Set("redact_client_log_data", clusterDescNew.GetRedactClientLogData()); err != nil {
302+
return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "redact_client_log_data", clusterName, err))
303+
}
297304

298305
zoneNameToZoneIDs, err := getZoneIDsFromNewAPI(clusterDescNew)
299306
if err != nil {
@@ -327,6 +334,9 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.
327334
if err := d.Set("replica_set_scaling_strategy", clusterDescLatest.GetReplicaSetScalingStrategy()); err != nil {
328335
return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replica_set_scaling_strategy", clusterName, err))
329336
}
337+
if err := d.Set("redact_client_log_data", clusterDescLatest.GetRedactClientLogData()); err != nil {
338+
return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "redact_client_log_data", clusterName, err))
339+
}
330340

331341
zoneNameToOldReplicationSpecIDs, err := getReplicationSpecIDsFromOldAPI(ctx, projectID, clusterName, connV220240530)
332342
if err != nil {

internal/service/advancedcluster/data_source_advanced_clusters.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ func PluralDataSource() *schema.Resource {
263263
Type: schema.TypeString,
264264
Computed: true,
265265
},
266+
"redact_client_log_data": {
267+
Type: schema.TypeBool,
268+
Computed: true,
269+
},
266270
},
267271
},
268272
},
@@ -362,6 +366,7 @@ func flattenAdvancedClusters(ctx context.Context, connV220240530 *admin20240530.
362366
"version_release_system": cluster.GetVersionReleaseSystem(),
363367
"global_cluster_self_managed_sharding": cluster.GetGlobalClusterSelfManagedSharding(),
364368
"replica_set_scaling_strategy": cluster.GetReplicaSetScalingStrategy(),
369+
"redact_client_log_data": cluster.GetRedactClientLogData(),
365370
}
366371
results = append(results, result)
367372
}
@@ -418,6 +423,7 @@ func flattenAdvancedClustersOldSDK(ctx context.Context, connV20240530 *admin2024
418423
"version_release_system": cluster.GetVersionReleaseSystem(),
419424
"global_cluster_self_managed_sharding": cluster.GetGlobalClusterSelfManagedSharding(),
420425
"replica_set_scaling_strategy": clusterDescNew.GetReplicaSetScalingStrategy(),
426+
"redact_client_log_data": clusterDescNew.GetRedactClientLogData(),
421427
}
422428
results = append(results, result)
423429
}

0 commit comments

Comments
 (0)