Skip to content

Cloud Provider Snapshot Backup Policy #180

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 13 commits into from
Apr 14, 2020
Merged

Cloud Provider Snapshot Backup Policy #180

merged 13 commits into from
Apr 14, 2020

Conversation

PacoDw
Copy link
Contributor

@PacoDw PacoDw commented Mar 18, 2020

Added:

  • mongodbatlas_cloud_provider_snapshot_backup_policy resource.
  • mongodbatlas_cloud_provider_snapshot_backup_policy resource acceptance testing.
  • mongodbatlas_cloud_provider_snapshot_backup_policy resource website documentation.
  • mongodbatlas_cloud_provider_snapshot_backup_policy data source.
  • mongodbatlas_cloud_provider_snapshot_backup_policy data source acceptance testing.
  • mongodbatlas_cloud_provider_snapshot_backup_policy data source website documentation.

Example Usage

resource "mongodbatlas_cluster" "my_cluster" {
  project_id   = "<PROJECT-ID>"
  name         = "clusterTest"
  disk_size_gb = 5

  //Provider Settings "block"
  provider_name               = "AWS"
  provider_region_name        = "EU_CENTRAL_1"
  provider_instance_size_name = "M10"
  provider_backup_enabled     = true // enable cloud provider snapshots
  provider_disk_iops          = 100
  provider_encrypt_ebs_volume = false
}

resource "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" {
  project_id   = mongodbatlas_cluster.my_cluster.project_id
  cluster_name = mongodbatlas_cluster.my_cluster.name

  reference_hour_of_day    = 3
  reference_minute_of_hour = 45
  restore_window_days      = 4


  policies {
    id = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.id

    policy_item {
      id                 = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.0.id
      frequency_interval = 1
      frequency_type     = "hourly"
      retention_unit     = "days"
      retention_value    = 1
    }
    policy_item {
      id                 = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.1.id
      frequency_interval = 1
      frequency_type     = "daily"
      retention_unit     = "days"
      retention_value    = 2
    }
    policy_item {
      id                 = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.2.id
      frequency_interval = 4
      frequency_type     = "weekly"
      retention_unit     = "weeks"
      retention_value    = 3
    }
    policy_item {
      id                 = mongodbatlas_cluster.my_cluster.snapshot_backup_policy.0.policies.0.policy_item.3.id
      frequency_interval = 5
      frequency_type     = "monthly"
      retention_unit     = "months"
      retention_value    = 4
    }
  }
}

data "mongodbatlas_cloud_provider_snapshot_backup_policy" "test" {
  project_id   = mongodbatlas_cloud_provider_snapshot_backup_policy.test.project_id
  cluster_name = mongodbatlas_cloud_provider_snapshot_backup_policy.test.cluster_name
}

Also, we added a new parameter for the cluster resource and data sourcessnapshot_backup_policy, it represents the cloud provider snapshot backup policy for the created cluster. It's a computed attribute so to get all backup policies information the cluster must enable the provider_backup_enabled or backup_enabled depending on the mongo version.

Note the above configuration on how to get each policy item id to modify them.

@PacoDw PacoDw force-pushed the snapshotBackupPolicy branch from 56530a9 to 755e9f9 Compare March 18, 2020 17:45
@ghost ghost added the dependencies label Mar 18, 2020
@PacoDw PacoDw changed the title Cloud Provider Snapshot Backup Policy WIP:Cloud Provider Snapshot Backup Policy Mar 18, 2020
@PacoDw PacoDw changed the title WIP:Cloud Provider Snapshot Backup Policy Cloud Provider Snapshot Backup Policy Mar 18, 2020
Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

This is really cool in how it flows - made some comments in that this policy only applies for cloud provider snapshots so I think we need some logic not compute if provider_backup_enabled isn't true.

Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

Ugh hit wrong radio buttons - from the approve comment - This is really cool in how it flows - made some comments in that this policy only applies for cloud provider snapshots so I think we need some logic to not compute if provider_backup_enabled isn't true.

@PacoDw PacoDw requested a review from themantissa March 20, 2020 17:11
Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

Responded to a few of the questions. I think we are getting there!

@PacoDw PacoDw requested a review from themantissa March 20, 2020 20:50
Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

1 thing that got missed a few times.

@PacoDw PacoDw requested a review from themantissa March 20, 2020 21:06
Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

LGTM!! Thank you :D

Copy link
Contributor

@marinsalinas marinsalinas left a comment

Choose a reason for hiding this comment

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

LGTM!

@PacoDw PacoDw force-pushed the snapshotBackupPolicy branch from 47f761f to 37e0fb5 Compare April 14, 2020 14:28
@PacoDw PacoDw merged commit 86fd961 into master Apr 14, 2020
@PacoDw PacoDw deleted the snapshotBackupPolicy branch April 14, 2020 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants