Skip to content
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

add resource "azurerm_data_protection_backup_policy_postgresql" #12072

Conversation

ms-henglu
Copy link
Contributor

The tests are listed as follows.

=== RUN   TestAccDataProtectionBackupPolicyPostgreSql_basic
=== PAUSE TestAccDataProtectionBackupPolicyPostgreSql_basic
=== CONT  TestAccDataProtectionBackupPolicyPostgreSql_basic
--- PASS: TestAccDataProtectionBackupPolicyPostgreSql_basic (242.95s)
=== RUN   TestAccDataProtectionBackupPolicyPostgreSql_requiresImport
=== PAUSE TestAccDataProtectionBackupPolicyPostgreSql_requiresImport
=== CONT  TestAccDataProtectionBackupPolicyPostgreSql_requiresImport
--- PASS: TestAccDataProtectionBackupPolicyPostgreSql_requiresImport (268.59s)
=== RUN   TestAccDataProtectionBackupPolicyPostgreSql_complete
=== PAUSE TestAccDataProtectionBackupPolicyPostgreSql_complete
=== CONT  TestAccDataProtectionBackupPolicyPostgreSql_complete
--- PASS: TestAccDataProtectionBackupPolicyPostgreSql_complete (248.65s)
=== RUN   TestAccDataProtectionBackupPolicyPostgreSql_update
=== PAUSE TestAccDataProtectionBackupPolicyPostgreSql_update
=== CONT  TestAccDataProtectionBackupPolicyPostgreSql_update
--- PASS: TestAccDataProtectionBackupPolicyPostgreSql_update (418.92s)

@ghost ghost added the size/XXL label Jun 5, 2021
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @ms-henglu, i've given this a review and i'm having a hard time understanding what some of these properties do/mean - like what tagging means wrt a backup retention, see my comments left inline

ForceNew: true,
},

"repeating_time_intervals": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"repeating_time_intervals": {
"duration": {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this is not duration, this defines when to run a backup

Copy link
Collaborator

Choose a reason for hiding this comment

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

so maybe this is best to pull it up one level into backup_repeating_time_intervals - rule makes little sense here

MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll remove this and use default name BackupWeekly which portal uses.

Copy link
Collaborator

Choose a reason for hiding this comment

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

backup weekly doesn't make sense if the user picks something other then weekly, so maybe just "BackupIntervals"

@ms-henglu
Copy link
Contributor Author

hi @katbyte , thank you so much for review this complicated PR. I added one commit according to your suggestions.

Here's an example and I'll explain what those properties mean.

resource "azurerm_data_protection_backup_policy_postgresql" "example" {
  name                = "example-backup-policy"
  resource_group_name = azurerm_resource_group.rg.name
  vault_name          = azurerm_data_protection_backup_vault.example.name

  backup_rule {
    repeating_time_intervals = ["R/2021-05-23T02:30:00+00:00/P1W"]               // when to do the backup 
  }

  default_retention_duration = "P4M"             // default retention duration, which is applied when no other retention rule

  retention_rule {
    name             = "weekly"
    duration         = "P6M"                       // retention duration
    tagging_priority = 20                           // if a backup matches more than 1 retention rule's criteria, it will be applied with the retention rule which has higher priority 
    tagging_criteria {                                 // which backup will be applied this retention rule
      absolute_criteria = "FirstOfWeek"   // first successful backup of the week/month/year
    }
  }

  retention_rule {
    name             = "thursday"
    duration         = "P1W"
    tagging_priority = 25
    tagging_criteria {
      days_of_week           = ["Thursday"]   // it means backup taken on Thursday
      scheduled_backup_times = ["2021-05-23T02:30:00Z"]
    }
  }

  retention_rule {
    name             = "monthly"
    duration         = "P1D"
    tagging_priority = 15
    tagging_criteria {
      weeks_of_month         = ["First", "Last"]           //combine the weeks_of_month and days_of_week, it means backup taken on first and last Tuesday of the month
      days_of_week           = ["Tuesday"]
      scheduled_backup_times = ["2021-05-23T02:30:00Z"]
    }
  }
}

@ms-henglu
Copy link
Contributor Author

@katbyte ,hi, I added one more commit to rename backup_rule to backup_repeating_time_intervals, could you please take another look? Thanks!


* `tagging_criteria` - (Required) A `tagging_criteria` block as defined below. Changing this forces a new Backup Policy PostgreSQL to be created.

* `tagging_priority` - (Required) Retention Tag priority. Changing this forces a new Backup Policy Postgre Sql to be created.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Retention Tag priority is not a full sentance

Comment on lines 96 to 98
* `tagging_criteria` - (Required) A `tagging_criteria` block as defined below. Changing this forces a new Backup Policy PostgreSQL to be created.

* `tagging_priority` - (Required) Retention Tag priority. Changing this forces a new Backup Policy Postgre Sql to be created.
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we really need tagging here? it makes little sense and is confusing how about:

Suggested change
* `tagging_criteria` - (Required) A `tagging_criteria` block as defined below. Changing this forces a new Backup Policy PostgreSQL to be created.
* `tagging_priority` - (Required) Retention Tag priority. Changing this forces a new Backup Policy Postgre Sql to be created.
* `criteria` - (Required) A `tagging_criteria` block as defined below. Changing this forces a new Backup Policy PostgreSQL to be created.
* `priority` - (Required) Retention Tag priority. Changing this forces a new Backup Policy Postgre Sql to be created.

so we get retention.criteria

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, I'll modify it.

@ms-henglu
Copy link
Contributor Author

ms-henglu commented Jun 15, 2021

@katbyte Hi, I added one more commit to rename tagging_prioriy and tagging_criteria to priority and criteria, please check again, thanks!

@ms-henglu ms-henglu requested a review from katbyte June 15, 2021 02:21
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@katbyte katbyte merged commit 6e1ce6f into hashicorp:master Jun 15, 2021
katbyte added a commit that referenced this pull request Jun 15, 2021
@github-actions
Copy link

This functionality has been released in v2.64.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants