-
Notifications
You must be signed in to change notification settings - Fork 203
INTMDB-781: [Terraform] Parameter Add: retainBackups in Cluster and Advanced_Cluster #1210
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
94c179b
fix: microsoft_teams_webhook_url keeps updating on every apply (#1148)
maastha 6a1b0c1
INTMDB-783: Point in Time Restore is not enabled when should_copy_opl…
andreaangiolillo 8078fe5
Merge remote-tracking branch 'origin/release-staging-v.1.10.0' into r…
andreaangiolillo 9609c1f
Merge remote-tracking branch 'origin/release-staging-v.1.10.0' into r…
andreaangiolillo 32d36a3
Merge remote-tracking branch 'origin/release-staging-v.1.10.0' into r…
andreaangiolillo 8786618
Merge remote-tracking branch 'origin/release-staging-v.1.10.0' into r…
andreaangiolillo 2f63740
Merge remote-tracking branch 'origin/release-staging-v.1.10.0' into r…
andreaangiolillo 5ebabce
Merge remote-tracking branch 'origin/release-staging-v.1.10.0' into r…
andreaangiolillo 684afb7
INTMDB-781: [Terraform] Parameter Add: retainBackups in Cluster and A…
andreaangiolillo 64ad9d2
Added documentations + updated tests
andreaangiolillo 997b261
Update versions.tf
andreaangiolillo 9bae5c2
Update versions.tf
andreaangiolillo f2a683e
Added example
andreaangiolillo 2ee1917
Update main.tf
andreaangiolillo 0d51ae1
Update examples/atlas-backup-snapshot-restore-job/point-in-time-advan…
andreaangiolillo 64cae2b
Update examples/atlas-backup-snapshot-restore-job/point-in-time-advan…
andreaangiolillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
examples/atlas-backup-snapshot-restore-job/point-in-time-advance-cluster/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# MongoDB Atlas Provider -- Cloud Backup Snapshot | ||
This example creates a project, advanced cluster, cloud provider snapshot, and a restore job for said snapshot. The cluster is configured to use cloud backup and point in time restore. | ||
|
||
Variables Required: | ||
- `org_id`: ID of atlas organization | ||
- `project_name`: Name of the project | ||
- `cluster_name`: Name of the cluster | ||
- `point_in_time_utc_seconds`: Point in time to restore to, a number of seconds since unix epoch. | ||
- `retain_backups_enabled`: Flag that indicates whether to retain backup snapshots for the deleted dedicated cluster. | ||
|
||
In order to utilize the backup restore job via point in time, fist you need a backup with which to restore. | ||
This example has been configured to only create the backup restore if `point_in_time_utc_seconds` is a non-zero number. | ||
As such, utilize the following example `terraform.tfvars` and pseudo-code to execute a working example: | ||
|
||
Example `terraform.tfvars` | ||
``` | ||
org_id = "627a9687f7f7f7f774de306f14" | ||
project_name = "cloud_backup_snapshot_v110" | ||
cluster_name = "v110-cluster" | ||
point_in_time_utc_seconds = 0 | ||
retain_backups_enabled = true | ||
``` | ||
|
||
- Run `terraform apply` | ||
- Update `point_in_time_utc_seconds` to the [current epoch time](https://www.epoch101.com/) | ||
- Run `terraform apply` | ||
|
||
You'll now have a project, cluster, backup snapshot, and restore job pointing to specific point in time which to restore. |
52 changes: 52 additions & 0 deletions
52
examples/atlas-backup-snapshot-restore-job/point-in-time-advance-cluster/main.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This will Create a Project, Cluster, cloud backup snapshot and restore job | ||
|
||
resource "mongodbatlas_project" "project_test" { | ||
name = var.project_name | ||
org_id = var.org_id | ||
} | ||
|
||
resource "mongodbatlas_advanced_cluster" "advanced_cluster_test" { | ||
project_id = mongodbatlas_project.project_test.id | ||
name = var.cluster_name | ||
cluster_type = "REPLICASET" | ||
|
||
replication_specs { | ||
num_shards = 1 | ||
|
||
region_configs { | ||
electable_specs { | ||
instance_size = "M10" | ||
node_count = 3 | ||
} | ||
|
||
provider_name = "AWS" | ||
region_name = "US_EAST_1" | ||
priority = 7 | ||
} | ||
} | ||
|
||
backup_enabled = true # enable cloud backup snapshots | ||
pit_enabled = true # Flag that indicates whether the cluster uses continuous cloud backups | ||
retain_backups_enabled = var.retain_backups_enabled # keep the backup snapshots once the cluster is deleted | ||
} | ||
|
||
resource "mongodbatlas_cloud_backup_snapshot" "test" { | ||
project_id = mongodbatlas_advanced_cluster.advanced_cluster_test.project_id | ||
cluster_name = mongodbatlas_advanced_cluster.advanced_cluster_test.name | ||
description = "My description" | ||
retention_in_days = "1" | ||
} | ||
|
||
resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" { | ||
count = (var.point_in_time_utc_seconds == 0 ? 0 : 1) | ||
project_id = mongodbatlas_cloud_backup_snapshot.test.project_id | ||
cluster_name = mongodbatlas_cloud_backup_snapshot.test.cluster_name | ||
snapshot_id = mongodbatlas_cloud_backup_snapshot.test.id | ||
|
||
delivery_type_config { | ||
point_in_time = true | ||
target_cluster_name = mongodbatlas_advanced_cluster.advanced_cluster_test.name | ||
target_project_id = mongodbatlas_advanced_cluster.advanced_cluster_test.project_id | ||
point_in_time_utc_seconds = var.point_in_time_utc_seconds | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
examples/atlas-backup-snapshot-restore-job/point-in-time-advance-cluster/variables.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
variable "project_name" { | ||
description = "Atlas project name" | ||
default = "ProjectTest0" | ||
} | ||
variable "org_id" { | ||
description = "The organization ID" | ||
} | ||
variable "cluster_name" { | ||
description = "Cluster name" | ||
default = "ClusterTest0" | ||
} | ||
variable "point_in_time_utc_seconds" { | ||
description = "Point in time timestamp for snapshot_restore_job" | ||
default = 0 | ||
} | ||
|
||
variable "retain_backups_enabled" { | ||
description = "Flag that indicates whether to retain backup snapshots for the deleted dedicated cluster" | ||
default = true | ||
} |
8 changes: 8 additions & 0 deletions
8
examples/atlas-backup-snapshot-restore-job/point-in-time-advance-cluster/versions.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
examples/atlas-backup-snapshot-restore-job/point-in-time/versions.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
version = "~> 1.4.6" | ||
source = "mongodb/mongodbatlas" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great fix @andreaangiolillo, in future for all examples we should just default to pulling latest version of Terraform Atlas Provider