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

azurerm_backup_policy_file_share add weekly, monthly, and yearly retention #10733

Merged
merged 6 commits into from
Apr 29, 2021
Merged

azurerm_backup_policy_file_share add weekly, monthly, and yearly retention #10733

merged 6 commits into from
Apr 29, 2021

Conversation

IanMoroney
Copy link
Contributor

Fixes #10732

Features

  • Adds weekly, monthly, and yearly retention
  • Fixes validation and enforces Azure maximums for daily, weekly, monthly, and annual retention values
  • Aligns code to match format of azurerm_backup_policy_vm
  • Added tests for new scenarios
  • Updated documentation

Potential Terraform Configuration

resource "azurerm_backup_policy_file_share" "policy" {
  name                = "tfex-recovery-vault-policy"
  resource_group_name = azurerm_resource_group.example.name
  recovery_vault_name = azurerm_recovery_services_vault.vault.name

  timezone = "UTC"

  backup {
    frequency = "Daily"
    time      = "23:00"
  }

  retention_daily {
    count = 10
  }

  retention_weekly {
    count    = 7
    weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"]
  }

  retention_monthly {
    count    = 7
    weekdays = ["Sunday", "Wednesday"]
    weeks    = ["First", "Last"]
  }

  retention_yearly {
    count    = 7
    weekdays = ["Sunday"]
    weeks    = ["Last"]
    months   = ["January"]
  }
}

Test Results

=== RUN   TestAccBackupProtectionPolicyFileShare_basicDaily
=== PAUSE TestAccBackupProtectionPolicyFileShare_basicDaily
=== CONT  TestAccBackupProtectionPolicyFileShare_basicDaily
--- PASS: TestAccBackupProtectionPolicyFileShare_basicDaily (137.30s)
=== RUN   TestAccBackupProtectionPolicyFileShare_requiresImport
=== PAUSE TestAccBackupProtectionPolicyFileShare_requiresImport
=== CONT  TestAccBackupProtectionPolicyFileShare_requiresImport
--- PASS: TestAccBackupProtectionPolicyFileShare_requiresImport (148.44s)
=== RUN   TestAccBackupProtectionPolicyFileShare_completeDaily
=== PAUSE TestAccBackupProtectionPolicyFileShare_completeDaily
=== CONT  TestAccBackupProtectionPolicyFileShare_completeDaily
--- PASS: TestAccBackupProtectionPolicyFileShare_completeDaily (135.70s)

@IanMoroney
Copy link
Contributor Author

@WodansSon , could this be a candidate for v2.49.0 ?

@IanMoroney
Copy link
Contributor Author

@tombuildsstuff , would you be able to review this PR as this functionality is needed for a project I'm working on at the moment?
Many thanks!

paulomarquesc added a commit to paulomarquesc/terraform-provider-azurerm that referenced this pull request Mar 3, 2021
@IanMoroney
Copy link
Contributor Author

@jackofallops or @katbyte , would you be able to review and assign a milestone?
I don't have the ability to request a review from the Azure Providers group.

@IanMoroney
Copy link
Contributor Author

Can someone review?

@IanMoroney
Copy link
Contributor Author

@manicminer would you be able to review this PR? I'm desperately trying to find someone who can review it..

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 for the PR @IanMoroney - overall it looks good but i see a couple test failures:

------- Stdout: -------
=== RUN   TestAccBackupProtectionPolicyFileShare_updateDaily
=== PAUSE TestAccBackupProtectionPolicyFileShare_updateDaily
=== CONT  TestAccBackupProtectionPolicyFileShare_updateDaily
    testing.go:620: Step 2/3 error: Check failed: 1 error occurred:
        	* Check 6/13 error: azurerm_backup_policy_file_share.test: Attribute 'retention_weekly.0.weekdays.#' expected "2", got "3"
        
--- FAIL: TestAccBackupProtectionPolicyFileShare_updateDaily (188.60s)
FAIL

------- Stderr: -------
2021/03/30 23:03:26 [DEBUG] not using binary driver name, it's no longer needed
2021/03/30 23:03:26 [DEBUG] not using binary driver name, it's no longer needed

------- Stdout: -------
=== RUN   TestAccBackupProtectionPolicyFileShare_updateDailyToPartial
=== PAUSE TestAccBackupProtectionPolicyFileShare_updateDailyToPartial
=== CONT  TestAccBackupProtectionPolicyFileShare_updateDailyToPartial
    testing.go:620: Step 3/4 error: Error running pre-apply refresh: 
        Error: "retention_daily": required field is not set
        
          on config428031155/terraform_plugin_test.tf line 22, in resource "azurerm_backup_policy_file_share" "test":
          22: resource "azurerm_backup_policy_file_share" "test" {
        
        
    testing_new.go:21: WARNING: destroy failed, so remote objects may still exist and be subject to billing
    testing_new.go:21: failed to destroy: 
        Error: "retention_daily": required field is not set
        
          on config428031155/terraform_plugin_test.tf line 22, in resource "azurerm_backup_policy_file_share" "test":
          22: resource "azurerm_backup_policy_file_share" "test" {
        
        
        
--- FAIL: TestAccBackupProtectionPolicyFileShare_updateDailyToPartial (88.01s)
FAIL

------- Stderr: -------
2021/03/30 23:03:26 [DEBUG] not using binary driver name, it's no longer needed

could we ensure each timescale is represented in tests? daily, monthly, yearly, then going from daily->monthly->yearly->daily,

thanks

@IanMoroney IanMoroney requested a review from katbyte April 26, 2021 14:40
@IanMoroney
Copy link
Contributor Author

hi @katbyte , test have been corrected and should pass now.
I also resolved the merge conflict due to the stale fork.

@ghost ghost removed the waiting-response label Apr 26, 2021
Copy link
Member

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@IanMoroney Thanks for the updates, this is looking good and the tests are passing. Could you add a test with 4 steps plus imports as per @katbyte's review, with configuration starting at daily, then changing to monthly, yearly and back to daily? Once that's in and passing this should be good to merge, thanks!

@ghost ghost added size/XXL and removed size/XL labels Apr 29, 2021
@IanMoroney
Copy link
Contributor Author

As discussed, I added more tests.

make acctests SERVICE='recoveryservices' TESTARGS='-run=TestAccBackupProtectionPolicyFileShare_' TESTTIMEOUT='120m'

--- PASS: TestAccBackupProtectionPolicyFileShare_YearlyRetention (137.26s)
--- PASS: TestAccBackupProtectionPolicyFileShare_WeeklyRetentionImport (174.27s)
--- PASS: TestAccBackupProtectionPolicyFileShare_requiresImport (176.90s)
--- PASS: TestAccBackupProtectionPolicyFileShare_WeeklyRetention (182.93s)
--- PASS: TestAccBackupProtectionPolicyFileShare_completeDaily (183.83s)
--- PASS: TestAccBackupProtectionPolicyFileShare_MonthlyRetention (185.26s)
--- PASS: TestAccBackupProtectionPolicyFileShare_updateDailyRetentionToWeekly (193.01s)
--- PASS: TestAccBackupProtectionPolicyFileShare_YearlyRetentionImport (218.09s)
--- PASS: TestAccBackupProtectionPolicyFileShare_updateDailyToPartial (226.15s)
--- PASS: TestAccBackupProtectionPolicyFileShare_basicDaily (226.86s)
--- PASS: TestAccBackupProtectionPolicyFileShare_MonthlyRetentionImport (228.94s)
--- PASS: TestAccBackupProtectionPolicyFileShare_updateYearlyRetentionToDaily (231.48s)
--- PASS: TestAccBackupProtectionPolicyFileShare_updateWeeklyRetentionToMonthly (243.96s)
--- PASS: TestAccBackupProtectionPolicyFileShare_updateDaily (259.03s)
--- PASS: TestAccBackupProtectionPolicyFileShare_updateMonthlyRetentionToYearly (275.84s)

@ghost ghost removed the waiting-response label Apr 29, 2021
@katbyte katbyte added this to the v2.57.0 milestone Apr 29, 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 @IanMoroney - LGTM 👍

katbyte added a commit that referenced this pull request Apr 29, 2021
@katbyte katbyte merged commit d3d32d1 into hashicorp:master Apr 29, 2021
alvintang pushed a commit to alvintang/terraform-provider-azurerm that referenced this pull request Apr 29, 2021
alvintang pushed a commit to alvintang/terraform-provider-azurerm that referenced this pull request Apr 29, 2021
…ntion (hashicorp#10733)

Co-authored-by: ian.moroney <ian.moroney@demica.com>
Fixes hashicorp#10732

Features
Adds weekly, monthly, and yearly retention
Fixes validation and enforces Azure maximums for daily, weekly, monthly, and annual retention values
Aligns code to match format of azurerm_backup_policy_vm
Added tests for new scenarios
Updated documentation
@ghost
Copy link

ghost commented Apr 30, 2021

This has been released in version 2.57.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.57.0"
}
# ... other configuration ...

@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 May 30, 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.

Support for azurerm_backup_policy_file_share to support weekly/monthly/yearly retention
3 participants