Skip to content

doc: Adds collection restore job examples and documentation - #4670

Open
EspenAlbert wants to merge 2 commits into
CLOUDP-435981_collection-restore-autogenfrom
CLOUDP-435981_collection-restore-docs
Open

doc: Adds collection restore job examples and documentation#4670
EspenAlbert wants to merge 2 commits into
CLOUDP-435981_collection-restore-autogenfrom
CLOUDP-435981_collection-restore-docs

Conversation

@EspenAlbert

@EspenAlbert EspenAlbert commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

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, and restore_job_inspection.

Link to any related issue(s): CLOUDP-435981

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fix and verified my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 by created_at, but created_at is an ISO-8601 string and max() 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 in examples/.../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 by created_at, but created_at is an ISO-8601 string and max() 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.

Comment thread docs/data-sources/cloud_backup_snapshot_databases.md Outdated
Comment thread docs/data-sources/cloud_backup_snapshot_database_collections.md Outdated
Comment on lines +29 to +32
### 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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@EspenAlbert
EspenAlbert force-pushed the CLOUDP-435981_collection-restore-docs branch 2 times, most recently from 4a40996 to 7e3141c Compare August 24, 2026 09:23
EspenAlbert and others added 2 commits August 24, 2026 10:45
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@EspenAlbert
EspenAlbert force-pushed the CLOUDP-435981_collection-restore-docs branch from 4a828f0 to 39cc838 Compare August 24, 2026 09:45
@EspenAlbert
EspenAlbert marked this pull request as ready for review August 24, 2026 09:50
@EspenAlbert
EspenAlbert requested review from a team as code owners August 24, 2026 09:50
@EspenAlbert
EspenAlbert requested a lite review from Copilot August 24, 2026 09:50
@github-actions

Copy link
Copy Markdown
Contributor

APIx bot: a message has been sent to Docs Slack channel

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_inspection example 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.

Comment on lines +16 to +18
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)
}
Comment on lines +21 to +37
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]
]
Comment on lines +20 to +22
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)
}
@augmentcode

augmentcode Bot commented Aug 24, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Adds documentation and runnable Terraform examples for collection-level Cloud Backup restores.

  • Introduces Registry templates and generated docs for the collection restore job resource.
  • Documents singular and plural restore-job inspection data sources.
  • Documents snapshot database and collection discovery data sources.
  • Explains required Atlas roles, restore lifecycle, limitations, and import behavior.
  • Adds a snapshot-based restore example with configurable target projects and clusters.
  • Adds a point-in-time restore example supporting wall-clock and oplog timestamps.
  • Adds a snapshot-discovery example to choose snapshots and namespaces.
  • Adds a read-only restore-job inspection example for job and per-collection state.
  • Shows namespace rename maps, global suffixes, strategies, and create timeouts.
  • Links the sibling examples from the new docs and top-level README.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

]
available_snapshots_newest = [
for created_at in slice(
reverse(sort([for s in local.available_snapshots_all : s.created_at])),

@augmentcode augmentcode Bot Aug 24, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@jromo-mdb jromo-mdb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants