Skip to content

Commit 4d43ef9

Browse files
authored
Release staging v1.4.5 (#817)
* INTMDB-369: Updated validation logic for cloud_backup_snapshot_restore_job (#813) * Updated validation logic for cloud_backup_snapshot_restore_job * Fixed lint errors * Updated serverless documentation around alert configurations (#819) * Updated changelog for v1.4.5 * Added back t he fixed header for v1.4.4 changelog * Fixed merge request referenced in chaneglog
1 parent 0ccb7b3 commit 4d43ef9

10 files changed

+93
-73
lines changed

CHANGELOG.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
# Changelog
1+
## [v1.4.5-pre.1](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/HEAD)
2+
3+
[Full Changelog](https://github.com/mongodb/terraform-provider-mongodbatlas/compare/v1.4.4...HEAD)
4+
5+
**Fixed**
6+
7+
- INTMDB-369: Fix parsing of `delivery_type_config` when using `point_in_time` for `cloud_backup_snapshot_restore_job`, in [\#813](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/813)
8+
- INTMDB-322: Validated serverless alert_configurations and improved documentation on usage, addressing issue [\#722](https://github.com/mongodb/terraform-provider-mongodbatlas/issues/722) in [\#819](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/819)
9+
210
## [v1.4.4](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v1.4.4) (2022-08-18)
311

412
[Full Changelog](https://github.com/mongodb/terraform-provider-mongodbatlas/compare/v1.4.3...v1.4.4)
513

6-
**Fixed:**
14+
**Fixed**
715

816
- INTMDB320 - Fix Global Cluster import documentation, in [\#796](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/796)
917
- INTMDB-331 - Update GCP documentation, issue [\#753](https://github.com/mongodb/terraform-provider-mongodbatlas/issues/753), in [\#793](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/793)

mongodbatlas/resource_mongodbatlas_cloud_backup_snapshot_restore_job.go

+54-48
Original file line numberDiff line numberDiff line change
@@ -409,60 +409,66 @@ func splitSnapshotRestoreJobImportID(id string) (projectID, clusterName, snapsho
409409
return
410410
}
411411

412-
func validateDeliveryType(d []interface{}) error {
413-
if len(d) != 0 {
414-
v := d[0].(map[string]interface{})
415-
key := "delivery_type_config"
416-
417-
_, automated := v["automated"]
418-
_, download := v["download"]
419-
_, pointInTime := v["point_in_time"]
420-
421-
if (v["automated"] == true && v["download"] == true && v["point_in_time"] == true) ||
422-
(v["automated"] == false && v["download"] == false && v["point_in_time"] == false) ||
423-
(!automated && !download && !pointInTime) {
424-
return fmt.Errorf("%q you can only submit one type of restore job: automated, download or point_in_time", key)
412+
func validateDeliveryType(dt []interface{}) error {
413+
if len(dt) == 0 {
414+
return nil
415+
}
416+
417+
v := dt[0].(map[string]interface{})
418+
key := "delivery_type_config"
419+
420+
a, aOk := v["automated"]
421+
automated := aOk && a != nil && a.(bool)
422+
d, dOk := v["download"]
423+
download := dOk && d != nil && d.(bool)
424+
p, pOk := v["point_in_time"]
425+
pointInTime := pOk && p != nil && p.(bool)
426+
427+
hasDeliveryType := automated || download || pointInTime
428+
429+
if !hasDeliveryType ||
430+
(automated && download) ||
431+
(automated && pointInTime) ||
432+
(download && pointInTime) {
433+
return fmt.Errorf("%q you must submit exactly one type of restore job: automated, download or point_in_time", key)
434+
}
435+
436+
if automated || pointInTime {
437+
if targetClusterName, ok := v["target_cluster_name"]; !ok || targetClusterName == "" {
438+
return fmt.Errorf("%q target_cluster_name must be set", key)
425439
}
426-
if v["automated"] == true && (v["download"] == false || !download) {
427-
if targetClusterName, ok := v["target_cluster_name"]; !ok || targetClusterName == "" {
428-
return fmt.Errorf("%q target_cluster_name must be set", key)
429-
}
430-
if targetGroupID, ok := v["target_project_id"]; !ok || targetGroupID == "" {
431-
return fmt.Errorf("%q target_project_id must be set", key)
432-
}
440+
441+
if targetProjectID, ok := v["target_project_id"]; !ok || targetProjectID == "" {
442+
return fmt.Errorf("%q target_project_id must be set", key)
433443
}
434-
if v["download"] == true && (v["automated"] == false || !automated) &&
435-
(v["point_in_time"] == false || !pointInTime) {
436-
if targetClusterName, ok := v["target_cluster_name"]; ok && targetClusterName != "" {
437-
return fmt.Errorf("%q it's not necessary implement target_cluster_name when you are using download delivery type", key)
438-
}
439-
if targetGroupID, ok := v["target_project_id"]; ok && targetGroupID != "" {
440-
return fmt.Errorf("%q it's not necessary implement target_project_id when you are using download delivery type", key)
441-
}
444+
} else {
445+
if targetClusterName, ok := v["target_cluster_name"]; ok && len(targetClusterName.(string)) > 0 {
446+
return fmt.Errorf("%q it's not necessary implement target_cluster_name when you are using download delivery type", key)
442447
}
443-
if v["point_in_time"] == true && (v["download"] == false || !download) &&
444-
(v["automated"] == false || !automated) {
445-
_, oplogTS := v["oplog_ts"]
446-
_, pointTimeUTC := v["point_in_time_utc_seconds"]
447-
_, oplogInc := v["oplog_inc"]
448-
if targetClusterName, ok := v["target_cluster_name"]; !ok || targetClusterName == "" {
449-
return fmt.Errorf("%q target_cluster_name must be set", key)
450-
}
451-
if targetGroupID, ok := v["target_project_id"]; !ok || targetGroupID == "" {
452-
return fmt.Errorf("%q target_project_id must be set", key)
453-
}
454-
if !pointTimeUTC && !oplogTS && !oplogInc {
455-
return fmt.Errorf("%q point_in_time_utc_seconds or oplog_ts and oplog_inc must be set", key)
456-
}
457-
if (oplogTS && !oplogInc) || (!oplogTS && oplogInc) {
458-
return fmt.Errorf("%q if oplog_ts or oplog_inc is provided, oplog_inc and oplog_ts must be set", key)
459-
}
460-
if pointTimeUTC && (oplogTS || oplogInc) {
461-
return fmt.Errorf("%q you can't use both point_in_time_utc_seconds and oplog_ts or oplog_inc", key)
462-
}
448+
449+
if targetProjectID, ok := v["target_project_id"]; ok && len(targetProjectID.(string)) > 0 {
450+
return fmt.Errorf("%q it's not necessary implement target_project_id when you are using download delivery type", key)
463451
}
464452
}
465453

454+
if automated || download {
455+
return nil
456+
}
457+
458+
pointTimeUTC, pointTimeUTCOk := v["point_in_time_utc_seconds"]
459+
isPITSet := pointTimeUTCOk && pointTimeUTC != nil && (pointTimeUTC.(int) > 0)
460+
oplogTS, oplogTSOk := v["oplog_ts"]
461+
isOpTSSet := oplogTSOk && oplogTS != nil && (oplogTS.(int) > 0)
462+
oplogInc, oplogIncOk := v["oplog_inc"]
463+
isOpIncSet := oplogIncOk && oplogInc != nil && (oplogInc.(int) > 0)
464+
465+
if !isPITSet && !(isOpTSSet && isOpIncSet) {
466+
return fmt.Errorf("%q point_in_time_utc_seconds or oplog_ts and oplog_inc must be set", key)
467+
}
468+
if isPITSet && (isOpTSSet || isOpIncSet) {
469+
return fmt.Errorf("%q you can't use both point_in_time_utc_seconds and oplog_ts or oplog_inc", key)
470+
}
471+
466472
return nil
467473
}
468474

website/docs/d/alert_configuration.html.markdown

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ In addition to all arguments above, the following attributes are exported:
104104

105105
-> ***IMPORTANT:*** Event Type has many possible values. All current options at available at https://docs.atlas.mongodb.com/reference/api/alert-configurations-create-config/ Details for both conditional and metric based alerts can be found by selecting the tabs on the [alert config page](https://docs.atlas.mongodb.com/reference/api/alert-configurations-create-config/) and checking the latest eventTypeName options.
106106

107-
-> **NOTE:** If `event_type` is set to OUTSIDE_METRIC_THRESHOLD, the metricThreshold field must also be set.
107+
-> **NOTE:** If `event_type` is set to `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`, the `metric_threshold_config` field must also be configured.
108108

109109
### Matchers
110110
Rules to apply when matching an object against this alert configuration. Only entities that match all these rules are checked for an alert condition. You can filter using the matchers array only when the eventTypeName specifies an event for a host, replica set, or sharded cluster.
@@ -143,10 +143,10 @@ Rules to apply when matching an object against this alert configuration. Only en
143143
- `CONFIG`
144144
- `MONGOS`
145145

146-
### Metric Threshold Config
147-
The threshold that causes an alert to be triggered. Required if `event_type_name` : "OUTSIDE_METRIC_THRESHOLD".
146+
### Metric Threshold Config (`metric_threshold_config`)
147+
The threshold that causes an alert to be triggered. Required if `event_type_name` : `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`.
148148

149-
* `metric_name` - Name of the metric to check. The full list of current options is available [here](https://docs.atlas.mongodb.com/reference/alert-host-metrics/#measurement-types)
149+
* `metric_name` - Name of the metric to check. The full list being quite large, please refer to atlas docs [here for general metrics](https://docs.atlas.mongodb.com/reference/alert-host-metrics/#measurement-types) and [here for serverless metrics](https://www.mongodb.com/docs/atlas/reference/api/alert-configurations-create-config/#serverless-measurements)
150150

151151
* `operator` - Operator to apply when checking the current metric value against the threshold value.
152152
Accepted values are:
@@ -175,7 +175,7 @@ The threshold that causes an alert to be triggered. Required if `event_type_name
175175

176176
* `mode` - This must be set to AVERAGE. Atlas computes the current metric value as an average.
177177

178-
### Threshold Config
178+
### Threshold Config (`threshold_config`)
179179
* `operator` - Operator to apply when checking the current metric value against the threshold value.
180180
Accepted values are:
181181
- `GREATER_THAN`

website/docs/d/cloud_backup_snapshot_restore_job.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ In addition to all arguments above, the following attributes are exported:
6060
* `finished_at` - UTC ISO 8601 formatted point in time when the restore job completed.
6161
* `id` - The unique identifier of the restore job.
6262
* `snapshot_id` - Unique identifier of the source snapshot ID of the restore job.
63-
* `target_group_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
63+
* `target_project_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
6464
* `target_cluster_name` - Name of the target Atlas cluster to which the restore job restores the snapshot. Only visible if deliveryType is automated.
6565
* `timestamp` - Timestamp in ISO 8601 date and time format in UTC when the snapshot associated to snapshotId was taken.
6666
* `oplogTs` - Timestamp in the number of seconds that have elapsed since the UNIX epoch.

website/docs/d/cloud_backup_snapshot_restore_jobs.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ In addition to all arguments above, the following attributes are exported:
6767
* `finished_at` - UTC ISO 8601 formatted point in time when the restore job completed.
6868
* `id` - The unique identifier of the restore job.
6969
* `snapshot_id` - Unique identifier of the source snapshot ID of the restore job.
70-
* `target_group_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
70+
* `target_project_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
7171
* `target_cluster_name` - Name of the target Atlas cluster to which the restore job restores the snapshot. Only visible if deliveryType is automated.
7272
* `timestamp` - Timestamp in ISO 8601 date and time format in UTC when the snapshot associated to snapshotId was taken.
7373
* `oplogTs` - Timestamp in the number of seconds that have elapsed since the UNIX epoch.

website/docs/d/cloud_provider_snapshot_restore_job.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ In addition to all arguments above, the following attributes are exported:
6262
* `finished_at` - UTC ISO 8601 formatted point in time when the restore job completed.
6363
* `id` - The unique identifier of the restore job.
6464
* `snapshot_id` - Unique identifier of the source snapshot ID of the restore job.
65-
* `target_group_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
65+
* `target_project_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
6666
* `target_cluster_name` - Name of the target Atlas cluster to which the restore job restores the snapshot. Only visible if deliveryType is automated.
6767
* `timestamp` - Timestamp in ISO 8601 date and time format in UTC when the snapshot associated to snapshotId was taken.
6868
* `oplogTs` - Timestamp in the number of seconds that have elapsed since the UNIX epoch.

website/docs/d/cloud_provider_snapshot_restore_jobs.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ In addition to all arguments above, the following attributes are exported:
6969
* `finished_at` - UTC ISO 8601 formatted point in time when the restore job completed.
7070
* `id` - The unique identifier of the restore job.
7171
* `snapshot_id` - Unique identifier of the source snapshot ID of the restore job.
72-
* `target_group_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
72+
* `target_project_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
7373
* `target_cluster_name` - Name of the target Atlas cluster to which the restore job restores the snapshot. Only visible if deliveryType is automated.
7474
* `timestamp` - Timestamp in ISO 8601 date and time format in UTC when the snapshot associated to snapshotId was taken.
7575
* `oplogTs` - Timestamp in the number of seconds that have elapsed since the UNIX epoch.

website/docs/r/alert_configuration.html.markdown

+5-5
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ resource "mongodbatlas_alert_configuration" "test" {
127127

128128
-> ***IMPORTANT:*** Event Type has many possible values. All current options at available at https://docs.atlas.mongodb.com/reference/api/alert-configurations-create-config/ Details for both conditional and metric based alerts can be found by selecting the tabs on the [alert config page](https://docs.atlas.mongodb.com/reference/api/alert-configurations-create-config/) and checking the latest eventTypeName options.
129129

130-
-> **NOTE:** If `event_type` is set to OUTSIDE_METRIC_THRESHOLD, the metricThreshold field must also be set.
130+
-> **NOTE:** If `event_type` is set to `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`, the `metric_threshold_config` field must also be configured.
131131

132132
### Matchers
133133
Rules to apply when matching an object against this alert configuration. Only entities that match all these rules are checked for an alert condition. You can filter using the matchers array only when the eventTypeName specifies an event for a host, replica set, or sharded cluster.
@@ -167,10 +167,10 @@ Rules to apply when matching an object against this alert configuration. Only en
167167
- `CONFIG`
168168
- `MONGOS`
169169

170-
### Metric Threshold Config
171-
The threshold that causes an alert to be triggered. Required if `event_type_name` : "OUTSIDE_METRIC_THRESHOLD".
170+
### Metric Threshold Config (`metric_threshold_config`)
171+
The threshold that causes an alert to be triggered. Required if `event_type_name` : `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`
172172

173-
* `metric_name` - Name of the metric to check. The full list of current options is available [here](https://docs.atlas.mongodb.com/reference/alert-host-metrics/#measurement-types)
173+
* `metric_name` - Name of the metric to check. The full list being quite large, please refer to atlas docs [here for general metrics](https://docs.atlas.mongodb.com/reference/alert-host-metrics/#measurement-types) and [here for serverless metrics](https://www.mongodb.com/docs/atlas/reference/api/alert-configurations-create-config/#serverless-measurements)
174174
* `operator` - Operator to apply when checking the current metric value against the threshold value.
175175
Accepted values are:
176176
- `GREATER_THAN`
@@ -198,7 +198,7 @@ The threshold that causes an alert to be triggered. Required if `event_type_name
198198

199199
* `mode` - This must be set to AVERAGE. Atlas computes the current metric value as an average.
200200

201-
### Threshold Config
201+
### Threshold Config (`threshold_config`)
202202
* `operator` - Operator to apply when checking the current metric value against the threshold value.
203203
Accepted values are:
204204
- `GREATER_THAN`

website/docs/r/cloud_backup_snapshot_restore_job.html.markdown

+13-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: |-
88

99
# Resource: mongodbatlas_cloud_backup_snapshot_restore_job
1010

11-
`mongodbatlas_cloud_backup_snapshot_restore_job` provides a resource to create a new restore job from a cloud backup snapshot of a specified cluster. The restore job can be one of three types:
11+
`mongodbatlas_cloud_backup_snapshot_restore_job` provides a resource to create a new restore job from a cloud backup snapshot of a specified cluster. The restore job must define one of three delivery types:
1212
* **automated:** Atlas automatically restores the snapshot with snapshotId to the Atlas cluster with name targetClusterName in the Atlas project with targetGroupId.
1313

1414
* **download:** Atlas provides a URL to download a .tar.gz of the snapshot with snapshotId. The contents of the archive contain the data files for your Atlas cluster.
@@ -92,17 +92,23 @@ description: |-
9292
* `project_id` - (Required) The unique identifier of the project for the Atlas cluster whose snapshot you want to restore.
9393
* `cluster_name` - (Required) The name of the Atlas cluster whose snapshot you want to restore.
9494
* `snapshot_id` - (Required) Unique identifier of the snapshot to restore.
95-
* `delivery_type_config` - (Required) Type of restore job to create. Possible values are: **download** or **automated**, only one must be set it in ``true``.
95+
* `delivery_type_config` - (Required) Type of restore job to create. Possible configurations are: **download**, **automated**, or **pointInTime** only one must be set it in ``true``.
96+
* `delivery_type_config.automated` - Set to `true` to use the automated configuration.
97+
* `delivery_type_config.download` - Set to `true` to use the download configuration.
98+
* `delivery_type_config.pointInTime` - Set to `true` to use the pointInTime configuration.
99+
* `delivery_type_config.target_cluster_name` - Name of the target Atlas cluster to which the restore job restores the snapshot. Required for **automated** and **pointInTime**.
100+
* `delivery_type_config.target_project_id` - Name of the target Atlas cluster to which the restore job restores the snapshot. Required for **automated** and **pointInTime**.
101+
* `delivery_type_config.oplog_ts` - Optional setting for **pointInTime** configuration. Timestamp in the number of seconds that have elapsed since the UNIX epoch from which to you want to restore this snapshot. This is the first part of an Oplog timestamp.
102+
* `delivery_type_config.oplog_inc` - Optional setting for **pointInTime** configuration. Oplog operation number from which to you want to restore this snapshot. This is the second part of an Oplog timestamp. Used in conjunction with `oplog_ts`.
103+
* `delivery_type_config.point_in_time_utc_seconds` - Optional setting for **pointInTime** configuration. Timestamp in the number of seconds that have elapsed since the UNIX epoch from which you want to restore this snapshot. Used instead of oplog settings.
96104

97105
### Download
98106
Atlas provides a URL to download a .tar.gz of the snapshot with snapshotId.
99107

100108
### Automated
101-
Atlas automatically restores the snapshot with snapshotId to the Atlas cluster with name targetClusterName in the Atlas project with targetGroupId. if you want to use automated delivery type, you must to set the following arguments:
102-
103-
* `target_cluster_name` - (Required) Name of the target Atlas cluster to which the restore job restores the snapshot. Only required if deliveryType is automated.
104-
* `target_group_id` - (Required) Unique ID of the target Atlas project for the specified targetClusterName. Only required if deliveryType is automated.
109+
Atlas automatically restores the snapshot with snapshotId to the Atlas cluster with name targetClusterName in the Atlas project with targetProjectId. if you want to use automated delivery type, you must to set the arguments for the afformentioned properties.
105110

111+
### Point in time
106112

107113
## Attributes Reference
108114

@@ -119,7 +125,7 @@ In addition to all arguments above, the following attributes are exported:
119125
* `id` - The Terraform's unique identifier used internally for state management.
120126
* `links` - One or more links to sub-resources and/or related resources. The relations between URLs are explained in the Web Linking Specification.
121127
* `snapshot_id` - Unique identifier of the source snapshot ID of the restore job.
122-
* `target_group_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
128+
* `target_project_id` - Name of the target Atlas project of the restore job. Only visible if deliveryType is automated.
123129
* `target_cluster_name` - Name of the target Atlas cluster to which the restore job restores the snapshot. Only visible if deliveryType is automated.
124130
* `timestamp` - Timestamp in ISO 8601 date and time format in UTC when the snapshot associated to snapshotId was taken.
125131
* `oplogTs` - Timestamp in the number of seconds that have elapsed since the UNIX epoch from which to you want to restore this snapshot.

0 commit comments

Comments
 (0)