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

Update azurerm_site_recovery_replication_recovery_plan does correctly update recovery groups #22649

Closed
1 task done
viewegchris opened this issue Jul 24, 2023 · 2 comments · Fixed by #22687
Closed
1 task done

Comments

@viewegchris
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.4.4

AzureRM Provider Version

3.66.0

Affected Resource(s)/Data Source(s)

azurerm_site_recovery_replication_recovery_plan

Terraform Configuration Files

## Create Plan

resource "azurerm_site_recovery_replication_recovery_plan" "test_recovery_plan" {
  name                      = "test-recovery-plan"
  recovery_vault_id         = data.azurerm_recovery_services_vault.asr-vault.id
  source_recovery_fabric_id = data.azurerm_site_recovery_fabric.asr-recovery-fabric.id
  target_recovery_fabric_id = data.azurerm_site_recovery_fabric.asr-recovery-fabric.id

  shutdown_recovery_group {
    pre_action {
      name            = "pre-action"
      type            = "AutomationRunbookActionDetails"
      fabric_location = "Primary"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      runbook_id = module.dr-runbooks.automation-runbook-free-up-crg-id
    }

    pre_action {
      name = "approval-gate"
      type = "ManualActionDetails"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      manual_action_instruction = "Please check if all scrips run successfully"
    }
  }

  failover_recovery_group {
  }

  boot_recovery_group {

    replicated_protected_items = local.replication_protected_db_items

    post_action {
      name            = "post-action"
      type            = "AutomationRunbookActionDetails"
      fabric_location = "Primary"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      runbook_id = azurerm_automation_runbook.test.id
    }

    post_action {
      name = "final-approval-gate"
      type = "ManualActionDetails"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      manual_action_instruction = "Please check your application"
    }
  }

  azure_to_azure_settings {
    primary_zone  = local.source_zone
    recovery_zone = local.target_zone
  }
}
## Updated plan
resource "azurerm_site_recovery_replication_recovery_plan" "test_recovery_plan" {
  name                      = "test-recovery-plan"
  recovery_vault_id         = data.azurerm_recovery_services_vault.asr-vault.id
  source_recovery_fabric_id = data.azurerm_site_recovery_fabric.asr-recovery-fabric.id
  target_recovery_fabric_id = data.azurerm_site_recovery_fabric.asr-recovery-fabric.id

  shutdown_recovery_group {
    pre_action {
      name            = "pre-action-updated"
      type            = "AutomationRunbookActionDetails"
      fabric_location = "Primary"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      runbook_id = module.dr-runbooks.automation-runbook-free-up-crg-id
    }

    pre_action {
      name = "approval-gate-new"
      type = "ManualActionDetails"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      manual_action_instruction = "Please check if all scrips run successfully"
    }
  }

  failover_recovery_group {
  }

  boot_recovery_group {

    replicated_protected_items = local.replication_protected_db_items

    post_action {
      name            = "post-action"
      type            = "AutomationRunbookActionDetails"
      fabric_location = "Primary"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      runbook_id = azurerm_automation_runbook.test.id
    }
  }

  boot_recovery_group {

    replicated_protected_items = local.replication_protected_db_items

    post_action {
      name            = "post-action-group-2"
      type            = "AutomationRunbookActionDetails"
      fabric_location = "Primary"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      runbook_id = azurerm_automation_runbook.test.id
    }

    post_action {
      name = "final-approval-gate-updated"
      type = "ManualActionDetails"

      fail_over_directions = [
        "PrimaryToRecovery", "RecoveryToPrimary"
      ]
      fail_over_types = [
        "TestFailover", "PlannedFailover", "UnplannedFailover"
      ]
      manual_action_instruction = "Updated instructions"
    }
  }

  azure_to_azure_settings {
    primary_zone  = local.source_zone
    recovery_zone = local.target_zone
  }
}

Debug Output/Panic Output

## Create

{"properties":{"failoverDeploymentModel":"ResourceManager","groups":[{"endGroupActions":[],"groupType":"Shutdown","startGroupActions":[{"actionName":"pre-action","customDetails":{"fabricLocation":"Primary","instanceType":"AutomationRunbookActionDetails","runbookId":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Automation/automationAccounts/zacha9999pr01ns1asr01/runbooks/Free-Up-CRG"},"failoverDirections":["PrimaryToRecovery","RecoveryToPrimary"],"failoverTypes":["UnplannedFailover","TestFailover","PlannedFailover"]},{"actionName":"approval-gate","customDetails":{"description":"Please check if all scrips run successfully","instanceType":"ManualActionDetails"},"failoverDirections":["PrimaryToRecovery","RecoveryToPrimary"],"failoverTypes":["UnplannedFailover","TestFailover","PlannedFailover"]}]},{"endGroupActions":[{"actionName":"post-action","customDetails":{"fabricLocation":"Primary","instanceType":"AutomationRunbookActionDetails","runbookId":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Automation/automationAccounts/zacha9999pr01ns1asr01/runbooks/test"},"failoverDirections":["PrimaryToRecovery","RecoveryToPrimary"],"failoverTypes":["UnplannedFailover","TestFailover","PlannedFailover"]},{"actionName":"final-approval-gate","customDetails":{"description":"Please check your application","instanceType":"ManualActionDetails"},"failoverDirections":["PrimaryToRecovery","RecoveryToPrimary"],"failoverTypes":["UnplannedFailover","TestFailover","PlannedFailover"]}],"groupType":"Boot","replicationProtectedItems":[{"id":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationFabrics/primary-fabric/replicationProtectionContainers/primary-protection-container/replicationProtectedItems/zachadevtestpr01008"}],"startGroupActions":[]}],"primaryFabricId":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationFabrics/primary-fabric","providerSpecificInput":[{"instanceType":"A2A","primaryZone":"1","recoveryZone":"2"}],"recoveryFabricId":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationFabrics/primary-fabric"}}: timestamp=2023-07-24T07:34:24.392Z
2023-07-24T07:34:25.194Z [DEBUG] provider.terraform-provider-azurerm_v3.66.0_x5: AzureRM Response for https://management.azure.com/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationRecoveryPlans/test-recovery-plan?api-version=2022-10-01:
HTTP/2.0 202 Accepted
Content-Length: 0
Azure-Asyncoperation: https://management.azure.com/Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationOperationStatus/4ab45f3a-d6dc-435d-a588-867d29f1b97a?api-version=2022-10-01
Cache-Control: no-cache
Date: Mon, 24 Jul 2023 07:34:24 GMT
Expires: -1
Location: https://management.azure.com/Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationRecoveryPlans/test-recovery-plan/operationresults/4ab45f3a-d6dc-435d-a588-867d29f1b97a?api-version=2022-10-01
Pragma: no-cache
Retry-After: 30
Server: Kestrel
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Client-Request-Id: 4012fdac-c3c5-4a76-819c-bf9c899f3b4b
X-Ms-Correlation-Request-Id: a7a48352-2b2a-6c36-7ec0-781b44d83a7d
X-Ms-Ratelimit-Remaining-Subscription-Writes: 1199
X-Ms-Request-Id: /Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationJobs/4ab45f3a-d6dc-435d-a588-867d29f1b97a
X-Ms-Request-Id: /Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationJobs/4ab45f3a-d6dc-435d-a588-867d29f1b97a
X-Ms-Routing-Request-Id: SWITZERLANDNORTH:20230724T073425Z:1b2eb89c-b2e6-4c24-9f15-deb1517ef124: timestamp=2023-07-24T07:34:25.194Z
2023-07-24T07:34:55.222Z [DEBUG] provider.terraform-provider-azurerm_v3.66.0_x5: AzureRM Request:
GET /Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationOperationStatus/4ab45f3a-d6dc-435d-a588-867d29f1b97a?api-version=2022-10-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.20.5 (amd64-linux) go-autorest/v14.2.1 hashicorp/go-azure-sdk/replicationrecoveryplans/2022-10-01 HashiCorp Terraform/1.4.4 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/3.66.0
X-Ms-Correlation-Request-Id: a7a48352-2b2a-6c36-7ec0-781b44d83a7d
Accept-Encoding: gzip: timestamp=2023-07-24T07:34:55.222Z
2023-07-24T07:34:55.298Z [DEBUG] provider.terraform-provider-azurerm_v3.66.0_x5: AzureRM Response for https://management.azure.com/Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationOperationStatus/4ab45f3a-d6dc-435d-a588-867d29f1b97a?api-version=2022-10-01:
HTTP/2.0 200 OK
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Mon, 24 Jul 2023 07:34:54 GMT
Expires: -1
Pragma: no-cache
Server: Kestrel
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Ms-Client-Request-Id: 9c4c966b-b601-4587-985b-17a4aa6dec09
X-Ms-Correlation-Request-Id: a7a48352-2b2a-6c36-7ec0-781b44d83a7d
X-Ms-Ratelimit-Remaining-Subscription-Reads: 11965
X-Ms-Request-Id: /Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationJobs/4ab45f3a-d6dc-435d-a588-867d29f1b97a
X-Ms-Routing-Request-Id: SWITZERLANDNORTH:20230724T073455Z:c5890258-c558-4b61-87f7-3262f545e81f



## Update of existing plan 

{"properties":{"groups":[{"endGroupActions":[],"groupType":"Failover","replicationProtectedItems":[],"startGroupActions":[]},{"endGroupActions":[{"actionName":"post-action","customDetails":{"fabricLocation":"Primary","instanceType":"AutomationRunbookActionDetails","runbookId":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Automation/automationAccounts/zacha9999pr01ns1asr01/runbooks/test"},"failoverDirections":["PrimaryToRecovery","RecoveryToPrimary"],"failoverTypes":["UnplannedFailover","TestFailover","PlannedFailover"]},{"actionName":"final-approval-gate","customDetails":{"description":"Please check your application","instanceType":"ManualActionDetails"},"failoverDirections":["PrimaryToRecovery","RecoveryToPrimary"],"failoverTypes":["UnplannedFailover","TestFailover","PlannedFailover"]}],"groupType":"Boot","replicationProtectedItems":[{"id":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationFabrics/primary-fabric/replicationProtectionContainers/primary-protection-container/replicationProtectedItems/zachadevtestpr01008"}],"startGroupActions":[]},{"endGroupActions":[],"groupType":"Shutdown","replicationProtectedItems":[],"startGroupActions":[{"actionName":"pre-action","customDetails":{"fabricLocation":"Primary","instanceType":"AutomationRunbookActionDetails","runbookId":"/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Automation/automationAccounts/zacha9999pr01ns1asr01/runbooks/Free-Up-CRG"},"failoverDirections":["PrimaryToRecovery","RecoveryToPrimary"],"failoverTypes":["UnplannedFailover","TestFailover","PlannedFailover"]},{"actionName":"approval-gate","customDetails":{"description":"Please check if all scrips run successfully","instanceType":"ManualActionDetails"},"failoverDirections":["PrimaryToRecovery","RecoveryToPrimary"],"failoverTypes":["UnplannedFailover","TestFailover","PlannedFailover"]}]}]}}: timestamp=2023-07-24T07:58:11.804Z
2023-07-24T07:58:12.808Z [DEBUG] provider.terraform-provider-azurerm_v3.66.0_x5: AzureRM Response for https://management.azure.com/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationRecoveryPlans/test-recovery-plan?api-version=2022-10-01:
HTTP/2.0 202 Accepted
Content-Length: 0
Azure-Asyncoperation: https://management.azure.com/Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationOperationStatus/c6de7473-c10b-4e73-9418-4787c7824f2f?api-version=2022-10-01
Cache-Control: no-cache
Date: Mon, 24 Jul 2023 07:58:12 GMT
Expires: -1
Location: https://management.azure.com/Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationRecoveryPlans/test-recovery-plan/operationresults/c6de7473-c10b-4e73-9418-4787c7824f2f?api-version=2022-10-01
Pragma: no-cache
Retry-After: 30
Server: Kestrel
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Client-Request-Id: 002ce609-cc75-4557-938f-0e755a1cb9ab
X-Ms-Correlation-Request-Id: e6d6b568-93a4-10d2-88ba-750c2f03ecc0
X-Ms-Ratelimit-Remaining-Subscription-Writes: 1199
X-Ms-Request-Id: /Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationJobs/c6de7473-c10b-4e73-9418-4787c7824f2f
X-Ms-Request-Id: /Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationJobs/c6de7473-c10b-4e73-9418-4787c7824f2f
X-Ms-Routing-Request-Id: SWITZERLANDWEST:20230724T075812Z:6fcb66dd-b83b-40f7-9041-8a73f2528636: timestamp=2023-07-24T07:58:12.808Z
2023-07-24T07:58:42.832Z [DEBUG] provider.terraform-provider-azurerm_v3.66.0_x5: AzureRM Request:
GET /Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationOperationStatus/c6de7473-c10b-4e73-9418-4787c7824f2f?api-version=2022-10-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.20.5 (amd64-linux) go-autorest/v14.2.1 hashicorp/go-azure-sdk/replicationrecoveryplans/2022-10-01 HashiCorp Terraform/1.4.4 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/3.66.0
X-Ms-Correlation-Request-Id: e6d6b568-93a4-10d2-88ba-750c2f03ecc0
Accept-Encoding: gzip: timestamp=2023-07-24T07:58:42.832Z
2023-07-24T07:58:42.970Z [DEBUG] provider.terraform-provider-azurerm_v3.66.0_x5: AzureRM Response for https://management.azure.com/Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationOperationStatus/c6de7473-c10b-4e73-9418-4787c7824f2f?api-version=2022-10-01:
HTTP/2.0 200 OK
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Mon, 24 Jul 2023 07:58:42 GMT
Expires: -1
Pragma: no-cache
Server: Kestrel
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Ms-Client-Request-Id: fde077c9-1dd6-42de-a9b7-ae6fb4351210
X-Ms-Correlation-Request-Id: e6d6b568-93a4-10d2-88ba-750c2f03ecc0
X-Ms-Ratelimit-Remaining-Subscription-Reads: 11921
X-Ms-Request-Id: /Subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationJobs/c6de7473-c10b-4e73-9418-4787c7824f2f
X-Ms-Routing-Request-Id: SWITZERLANDWEST:20230724T075842Z:fdfe0cae-d206-40e8-b429-1af42f4f13e9

Expected Behaviour

Changes on azurerm_site_recovery_replication_recovery_plan should update existing azure resource

Actual Behaviour

Changes on azurerm_site_recovery_replication_recovery_plan are detected in terraform plan but resulting ARM request does not maintain chanages

  ~ boot_recovery_group {
            # (1 unchanged attribute hidden)

          - post_action {
              - fail_over_directions      = [
                  - "PrimaryToRecovery",
                  - "RecoveryToPrimary",
                ] -> null
              - fail_over_types           = [
                  - "PlannedFailover",
                  - "TestFailover",
                  - "UnplannedFailover",
                ] -> null
              - manual_action_instruction = "Please check your application" -> null
              - name                      = "final-approval-gate" -> null
              - type                      = "ManualActionDetails" -> null
            }

            # (1 unchanged block hidden)
        }
      + boot_recovery_group {
          + replicated_protected_items = [
              + "/subscriptions/94850947-9bd7-4bc1-8e99-939c3131dd42/resourceGroups/z-ach-a9999-pr01-ns1-01-asr/providers/Microsoft.RecoveryServices/vaults/zacha9999pr01ns1rsv90/replicationFabrics/primary-fabric/replicationProtectionContainers/primary-protection-container/replicationProtectedItems/zachadevtestpr01008",
            ]

          + post_action {
              + fabric_location      = "Primary"
              + fail_over_directions = [
                  + "PrimaryToRecovery",
                  + "RecoveryToPrimary",
                ]
              + fail_over_types      = [
                  + "PlannedFailover",
                  + "TestFailover",
                  + "UnplannedFailover",
                ]
              + name                 = "post-action-group-2"
              + runbook_id           = "/subscriptions/94850947-9bd7-4bc1-8e99-939c3131dd42/resourceGroups/z-ach-a9999-pr01-ns1-01-asr/providers/Microsoft.Automation/automationAccounts/zacha9999pr01ns1asr01/runbooks/test"
              + type                 = "AutomationRunbookActionDetails"
            }
          + post_action {
              + fail_over_directions      = [
                  + "PrimaryToRecovery",
                  + "RecoveryToPrimary",
                ]
              + fail_over_types           = [
                  + "PlannedFailover",
                  + "TestFailover",
                  + "UnplannedFailover",
                ]
              + manual_action_instruction = "Updated instructions"
              + name                      = "final-approval-gate-updated"
              + type                      = "ManualActionDetails"
            }
        }

      ~ shutdown_recovery_group {
          ~ pre_action {
              ~ name                 = "pre-action" -> "pre-action-updated"
                # (5 unchanged attributes hidden)
            }
          ~ pre_action {
              ~ name                      = "approval-gate" -> "approval-gate-new"
                # (4 unchanged attributes hidden)
            }
        }

        # (5 unchanged blocks hidden)
    }

Steps to Reproduce

terraform apply

Important Factoids

No response

References

Fixing create was part of #22323

@ziyeqf
Copy link
Contributor

ziyeqf commented Jul 26, 2023

Hi @viewegchris, thanks for reporting.

Have submitted a PR(#22687) for it, once it merged & released it should be fixed. sorry for the inconvince.

Thanks.

@rcskosir rcskosir added the bug label Jul 26, 2023
catriona-m pushed a commit that referenced this issue Jul 28, 2023
…ot_recovery_group`,`failover_recovery_group` and `shutdown_recovery_group` (#22687)

* fix #22649

Signed-off-by: ziyeqf <[email protected]>

* update code

Signed-off-by: ziyeqf <[email protected]>

* update per comments

Signed-off-by: ziyeqf <[email protected]>

* update code

Signed-off-by: ziyeqf <[email protected]>

---------

Signed-off-by: ziyeqf <[email protected]>
@github-actions github-actions bot added this to the v3.68.0 milestone Jul 28, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, 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 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.