doc: Adds collection restore job examples and documentation - #4670
doc: Adds collection restore job examples and documentation#4670EspenAlbert wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Terraform Registry documentation templates, generated docs, and runnable example configurations for Atlas Cloud Backup collection/database-level restore jobs, including snapshot discovery, snapshot-based restores, PIT restores, and restore job inspection workflows.
Changes:
- Adds tfplugindocs templates for the collection restore job resource and related data sources.
- Adds new example roots under
examples/mongodbatlas_cloud_backup_collection_restore_job/for snapshot discovery/restore, PIT restore, and job inspection. - Adds generated Registry docs for the new resource and data sources.
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/resources/cloud_backup_collection_restore_job.md.tmpl | New tfplugindocs template for the collection restore job resource docs. |
| templates/data-sources/cloud_backup_snapshot_databases.md.tmpl | New tfplugindocs template for snapshot database discovery data source docs. |
| templates/data-sources/cloud_backup_snapshot_database_collections.md.tmpl | New tfplugindocs template for snapshot database collections discovery data source docs. |
| templates/data-sources/cloud_backup_collection_restore_jobs.md.tmpl | New tfplugindocs template for plural restore jobs data source docs. |
| templates/data-sources/cloud_backup_collection_restore_job.md.tmpl | New tfplugindocs template for singular restore job data source docs. |
| templates/data-sources/cloud_backup_collection_restore_job_collections.md.tmpl | New tfplugindocs template for plural per-collection job state data source docs. |
| templates/data-sources/cloud_backup_collection_restore_job_collection.md.tmpl | New tfplugindocs template for singular per-collection job state data source docs. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_restore/versions.tf | Adds Terraform/provider requirements for snapshot-restore example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_restore/variables.tf | Defines inputs (IDs, strategies, namespace selection/rename options) for snapshot-restore example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_restore/README.md | Documents how to run the snapshot-based restore example and its defaults. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_restore/providers.tf | Adds provider block for snapshot-restore example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_restore/main.tf | Implements snapshot-based restore job + outputs and per-collection inspection data source. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_discovery/versions.tf | Adds Terraform/provider requirements for snapshot discovery example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_discovery/variables.tf | Defines inputs for snapshot selection/discovery example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_discovery/README.md | Documents how to list snapshots and discover namespaces before restore. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_discovery/providers.tf | Adds provider block for snapshot discovery example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_discovery/main.tf | Implements snapshot listing + database/collection discovery data sources and outputs. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/restore_job_inspection/versions.tf | Adds Terraform/provider requirements for restore job inspection example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/restore_job_inspection/variables.tf | Defines inputs for job/namespace selection when inspecting restore jobs. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/restore_job_inspection/restore_job.tf | Reads plural jobs and resolves a job_id, then reads singular job details. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/restore_job_inspection/restore_job_collections.tf | Reads per-collection state for a job and resolves a single collection to inspect. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/restore_job_inspection/README.md | Documents restore job inspection workflow and defaults. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/restore_job_inspection/providers.tf | Adds provider block for restore job inspection example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/README.md | Adds top-level README describing the sibling example roots and recommended flow. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/pit_restore/versions.tf | Adds Terraform/provider requirements for PIT restore example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/pit_restore/variables.tf | Defines PIT restore inputs (time selection + namespace selection/rename options). |
| examples/mongodbatlas_cloud_backup_collection_restore_job/pit_restore/README.md | Documents PIT restore time selection (epoch vs oplog timestamp) and usage. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/pit_restore/providers.tf | Adds provider block for PIT restore example. |
| examples/mongodbatlas_cloud_backup_collection_restore_job/pit_restore/main.tf | Implements PIT-based restore job + outputs and per-collection inspection data source. |
| docs/resources/cloud_backup_collection_restore_job.md | Adds generated Registry doc page for the collection restore job resource. |
| docs/data-sources/cloud_backup_snapshot_databases.md | Adds generated Registry doc page for snapshot databases data source. |
| docs/data-sources/cloud_backup_snapshot_database_collections.md | Adds generated Registry doc page for snapshot database collections data source. |
| docs/data-sources/cloud_backup_collection_restore_jobs.md | Adds generated Registry doc page for plural restore jobs data source. |
| docs/data-sources/cloud_backup_collection_restore_job.md | Adds generated Registry doc page for singular restore job data source. |
| docs/data-sources/cloud_backup_collection_restore_job_collections.md | Adds generated Registry doc page for plural per-collection job state data source. |
| docs/data-sources/cloud_backup_collection_restore_job_collection.md | Adds generated Registry doc page for singular per-collection job state data source. |
Suppressed comments (2)
docs/data-sources/cloud_backup_snapshot_databases.md:23
- The Example Usage snippet uses
max([ ... ])to pick the latest snapshot bycreated_at, butcreated_atis an ISO-8601 string andmax()only accepts numbers (and doesn’t accept a list argument). As written, this example will fail in Terraform. Use lexicographic sorting of the ISO-8601 strings instead (as done inexamples/.../snapshot_discovery/main.tf).
latest_snapshot_created_at = length(local.completed_snapshots) > 0 ? max([
for snapshot in local.completed_snapshots : snapshot.created_at
]) : null
docs/data-sources/cloud_backup_snapshot_database_collections.md:23
- The Example Usage snippet uses
max([ ... ])to pick the latest snapshot bycreated_at, butcreated_atis an ISO-8601 string andmax()only accepts numbers (and doesn’t accept a list argument). As written, this example will fail in Terraform. Use lexicographic sorting of the ISO-8601 strings instead.
latest_snapshot_created_at = length(local.completed_snapshots) > 0 ? max([
for snapshot in local.completed_snapshots : snapshot.created_at
]) : null
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ### Further Examples | ||
| - [Snapshot restore](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_restore) | ||
| - [Point-in-time restore](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples/mongodbatlas_cloud_backup_collection_restore_job/pit_restore) | ||
| - [Snapshot discovery](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_discovery) |
There was a problem hiding this comment.
Leaving tree/master Further Examples links. They 404 until this merges; after merge they will work. Pointing at v2.16.0 would also 404 because this example dir is not on that tag.
4a40996 to
7e3141c
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
4a828f0 to
39cc838
Compare
|
APIx bot: a message has been sent to Docs Slack channel |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 36 changed files in this pull request and generated 3 comments.
Suppressed comments (1)
templates/resources/cloud_backup_collection_restore_job.md.tmpl:32
- The resource doc’s “Further Examples” list omits the
restore_job_inspectionexample directory that this PR adds and that is referenced by the data source docs. Adding it here makes it easier for users to find the read-only inspection workflow after running a restore.
| locals { | ||
| job_id = coalesce(var.job_id, data.mongodbatlas_cloud_backup_collection_restore_jobs.this.results[length(data.mongodbatlas_cloud_backup_collection_restore_jobs.this.results) - 1].job_id) | ||
| } |
| available_snapshots_all = [ | ||
| for snapshot in data.mongodbatlas_cloud_backup_snapshots.this.results : { | ||
| id = snapshot.id | ||
| created_at = snapshot.created_at | ||
| status = snapshot.status | ||
| snapshot_type = snapshot.snapshot_type | ||
| } | ||
| ] | ||
| available_snapshots_newest = [ | ||
| for created_at in slice( | ||
| reverse(sort([for s in local.available_snapshots_all : s.created_at])), | ||
| 0, | ||
| min(var.available_snapshots_limit, length(local.available_snapshots_all)), | ||
| ) : [ | ||
| for s in local.available_snapshots_all : s if s.created_at == created_at | ||
| ][0] | ||
| ] |
| locals { | ||
| source_namespace = coalesce(var.source_namespace, data.mongodbatlas_cloud_backup_collection_restore_job_collections.this.results[length(data.mongodbatlas_cloud_backup_collection_restore_job_collections.this.results) - 1].source_namespace) | ||
| } |
🤖 Augment PR SummarySummary: Adds documentation and runnable Terraform examples for collection-level Cloud Backup restores.
🤖 Was this summary useful? React with 👍 or 👎 |
| ] | ||
| available_snapshots_newest = [ | ||
| for created_at in slice( | ||
| reverse(sort([for s in local.available_snapshots_all : s.created_at])), |
There was a problem hiding this comment.
examples/mongodbatlas_cloud_backup_collection_restore_job/snapshot_discovery/main.tf:31: This list is built from every snapshot status, so available_snapshots can include IN_PROGRESS or failed snapshots despite its documented “newest completed snapshots” contract. That also makes this output disagree with the separately resolved snapshot_id, which is restricted to completed snapshots.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Description
Adds tfplugindocs templates, generated registry docs, and examples for collection/database-level Cloud Backup restores. Examples are split into sibling roots:
snapshot_discovery,snapshot_restore,pit_restore, andrestore_job_inspection.Link to any related issue(s): CLOUDP-435981
Type of change:
Required Checklist:
Further comments
Snapshot vs PIT are mutually exclusive inputs on one resource; examples keep those paths in separate directories. Target naming uses per-key rename maps and global suffixes as separate variables.