From 28cf0b8d4a87092b5c9aec85405ad0d2048e0962 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Fri, 26 May 2023 08:21:05 +0800 Subject: [PATCH] New Resource: `azurerm_recovery_services_vault_resource_guard_association ` (#21712) --- .../recoveryservices/client/client.go | 6 + ...ult_resource_guard_association_resource.go | 181 ++++++++++++++++++ ...esource_guard_association_resource_test.go | 79 ++++++++ .../services/recoveryservices/registration.go | 1 + .../2023-02-01/resourceguardproxy/README.md | 94 +++++++++ .../2023-02-01/resourceguardproxy/client.go | 18 ++ .../id_backupresourceguardproxy.go | 140 ++++++++++++++ .../method_delete_autorest.go | 66 +++++++ .../resourceguardproxy/method_get_autorest.go | 68 +++++++ .../resourceguardproxy/method_put_autorest.go | 69 +++++++ .../method_unlockdelete_autorest.go | 70 +++++++ .../model_resourceguardoperationdetail.go | 9 + .../model_resourceguardproxybase.go | 11 ++ .../model_resourceguardproxybaseresource.go | 14 ++ .../model_unlockdeleterequest.go | 9 + .../model_unlockdeleteresponse.go | 8 + .../2023-02-01/resourceguardproxy/version.go | 12 ++ vendor/modules.txt | 1 + ...__resource_guard_association.html.markdown | 74 +++++++ 19 files changed, 930 insertions(+) create mode 100644 internal/services/recoveryservices/recovery_services_vault_resource_guard_association_resource.go create mode 100644 internal/services/recoveryservices/recovery_services_vault_resource_guard_association_resource_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/id_backupresourceguardproxy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_delete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_put_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_unlockdelete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardoperationdetail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardproxybase.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardproxybaseresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_unlockdeleterequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_unlockdeleteresponse.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/version.go create mode 100644 website/docs/r/recovery_services_vault__resource_guard_association.html.markdown diff --git a/internal/services/recoveryservices/client/client.go b/internal/services/recoveryservices/client/client.go index d497f73f91fa..59f3f065c0ee 100644 --- a/internal/services/recoveryservices/client/client.go +++ b/internal/services/recoveryservices/client/client.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/protectioncontainers" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/protectionpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationfabrics" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationnetworkmappings" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationnetworks" @@ -47,6 +48,7 @@ type Client struct { ReplicationProtectedItemsClient *replicationprotecteditems.ReplicationProtectedItemsClient ReplicationRecoveryPlansClient *replicationrecoveryplans.ReplicationRecoveryPlansClient ReplicationNetworksClient *replicationnetworks.ReplicationNetworksClient + ResourceGuardProxyClient *resourceguardproxy.ResourceGuardProxyClient } func NewClient(o *common.ClientOptions) *Client { @@ -113,6 +115,9 @@ func NewClient(o *common.ClientOptions) *Client { replicationNetworksClient := replicationnetworks.NewReplicationNetworksClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&replicationNetworksClient.Client, o.ResourceManagerAuthorizer) + resourceGuardProxyClient := resourceguardproxy.NewResourceGuardProxyClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&resourceGuardProxyClient.Client, o.ResourceManagerAuthorizer) + return &Client{ ProtectableItemsClient: &protectableItemsClient, ProtectedItemsClient: &protectedItemsClient, @@ -135,5 +140,6 @@ func NewClient(o *common.ClientOptions) *Client { ReplicationProtectedItemsClient: &replicationMigrationItemsClient, ReplicationRecoveryPlansClient: &replicationRecoveryPlanClient, ReplicationNetworksClient: &replicationNetworksClient, + ResourceGuardProxyClient: &resourceGuardProxyClient, } } diff --git a/internal/services/recoveryservices/recovery_services_vault_resource_guard_association_resource.go b/internal/services/recoveryservices/recovery_services_vault_resource_guard_association_resource.go new file mode 100644 index 000000000000..266d5f2b05fb --- /dev/null +++ b/internal/services/recoveryservices/recovery_services_vault_resource_guard_association_resource.go @@ -0,0 +1,181 @@ +package recoveryservices + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2022-04-01/resourceguards" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2022-10-01/vaults" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +const VaultGuardResourceType = "Microsoft.RecoveryServices/vaults/backupResourceGuardProxies" +const VaultGuardProxyDeleteRequestName = "default" // this name does not matter, this value comes from Portal. + +type VaultGuardProxyResource struct{} + +var _ sdk.Resource = VaultGuardProxyResource{} + +type VaultGuardProxyModel struct { + Name string `tfschema:"name"` + VaultId string `tfschema:"vault_id"` + ResourceGuardId string `tfschema:"resource_guard_id"` +} + +func (r VaultGuardProxyResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return resourceguardproxy.ValidateBackupResourceGuardProxyID +} + +func (r VaultGuardProxyResource) ModelObject() interface{} { + return &VaultGuardProxyModel{} +} + +func (r VaultGuardProxyResource) ResourceType() string { + return "azurerm_recovery_services_vault_resource_guard_association" +} + +func (r VaultGuardProxyResource) Arguments() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "vault_id": commonschema.ResourceIDReferenceRequiredForceNew(vaults.VaultId{}), + + "resource_guard_id": commonschema.ResourceIDReferenceRequiredForceNew(resourceguards.ResourceGuardId{}), + } +} + +func (r VaultGuardProxyResource) Attributes() map[string]*schema.Schema { + return map[string]*schema.Schema{} +} +func (r VaultGuardProxyResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var plan VaultGuardProxyModel + if err := metadata.Decode(&plan); err != nil { + return fmt.Errorf("decoding %w", err) + } + client := metadata.Client.RecoveryServices.ResourceGuardProxyClient + + vaultId, err := vaults.ParseVaultID(plan.VaultId) + if err != nil { + return fmt.Errorf("parsing vault id %w", err) + } + + id := resourceguardproxy.NewBackupResourceGuardProxyID(vaultId.SubscriptionId, vaultId.ResourceGroupName, vaultId.VaultName, plan.Name) + + existing, err := client.Get(ctx, id) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking presence of %s:%+v", id, err) + } + } + + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_recovery_services_vault_resource_guard_association", id.ID()) + } + + proxy := resourceguardproxy.ResourceGuardProxyBaseResource{ + Id: pointer.To(id.ID()), + Type: pointer.To(VaultGuardResourceType), + Properties: pointer.To(resourceguardproxy.ResourceGuardProxyBase{ + ResourceGuardResourceId: pointer.To(plan.ResourceGuardId), + }), + } + + if _, err = client.Put(ctx, id, proxy); err != nil { + return fmt.Errorf("creating %s:%w", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r VaultGuardProxyResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.RecoveryServices.ResourceGuardProxyClient + + id, err := resourceguardproxy.ParseBackupResourceGuardProxyID(metadata.ResourceData.Id()) + if err != nil { + return fmt.Errorf("parsing %q:%+v", metadata.ResourceData.Id(), err) + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + return fmt.Errorf("creating %s:%+v", id, err) + } + + vaultId := vaults.NewVaultID(id.SubscriptionId, id.ResourceGroupName, id.VaultName) + state := VaultGuardProxyModel{ + VaultId: vaultId.ID(), + Name: id.BackupResourceGuardProxyName, + } + + if resp.Model != nil && resp.Model.Properties != nil { + state.ResourceGuardId = pointer.From(resp.Model.Properties.ResourceGuardResourceId) + } + + return metadata.Encode(&state) + }, + } +} + +func (r VaultGuardProxyResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var plan VaultGuardProxyModel + if err := metadata.Decode(&plan); err != nil { + return fmt.Errorf("decoding %w", err) + } + client := metadata.Client.RecoveryServices.ResourceGuardProxyClient + + id, err := resourceguardproxy.ParseBackupResourceGuardProxyID(metadata.ResourceData.Id()) + if err != nil { + return fmt.Errorf("parsing %q:%+v", metadata.ResourceData.Id(), err) + } + + guardId, err := resourceguards.ParseResourceGuardID(plan.ResourceGuardId) + if err != nil { + return fmt.Errorf("parsing %q:%+v", plan.ResourceGuardId, err) + } + + requestId := resourceguards.NewDeleteResourceGuardProxyRequestID(guardId.SubscriptionId, guardId.ResourceGroupName, guardId.ResourceGuardName, VaultGuardProxyDeleteRequestName) + + unlock := resourceguardproxy.UnlockDeleteRequest{ + ResourceGuardOperationRequests: pointer.To([]string{requestId.ID()}), + } + + if _, err = client.UnlockDelete(ctx, *id, unlock); err != nil { + return fmt.Errorf("unlocking delete %s:%+v", id, err) + } + + if _, err = client.Delete(ctx, *id); err != nil { + return fmt.Errorf("deleting %s:%+v", id, err) + } + + return nil + }, + } +} diff --git a/internal/services/recoveryservices/recovery_services_vault_resource_guard_association_resource_test.go b/internal/services/recoveryservices/recovery_services_vault_resource_guard_association_resource_test.go new file mode 100644 index 000000000000..f8b88dc5d275 --- /dev/null +++ b/internal/services/recoveryservices/recovery_services_vault_resource_guard_association_resource_test.go @@ -0,0 +1,79 @@ +package recoveryservices_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type VaultResourceGuardAssociationResource struct{} + +func TestAccSiteRecoveryVaultResourceGuardAssociation_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_recovery_services_vault_resource_guard_association", "test") + r := VaultResourceGuardAssociationResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (VaultResourceGuardAssociationResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-recovery-%[1]d" + location = "%s" +} + +resource "azurerm_recovery_services_vault" "test" { + name = "acctest-vault-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard" + + soft_delete_enabled = false +} + +resource "azurerm_data_protection_resource_guard" "test" { + name = "acctest-dprg-%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_recovery_services_vault_resource_guard_association" "test" { + name = "tftest" + vault_id = azurerm_recovery_services_vault.test.id + resource_guard_id = azurerm_data_protection_resource_guard.test.id +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + +func (t VaultResourceGuardAssociationResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := resourceguardproxy.ParseBackupResourceGuardProxyID(state.ID) + if err != nil { + return nil, err + } + + resp, err := clients.RecoveryServices.ResourceGuardProxyClient.Get(ctx, *id) + if err != nil { + return nil, fmt.Errorf("reading %s: %+v", id.String(), err) + } + + return utils.Bool(resp.Model != nil), nil +} diff --git a/internal/services/recoveryservices/registration.go b/internal/services/recoveryservices/registration.go index 70462b4474e4..fb4a26bfd01f 100644 --- a/internal/services/recoveryservices/registration.go +++ b/internal/services/recoveryservices/registration.go @@ -32,6 +32,7 @@ func (r Registration) Resources() []sdk.Resource { HyperVNetworkMappingResource{}, VMWareReplicationPolicyResource{}, VMWareReplicationPolicyAssociationResource{}, + VaultGuardProxyResource{}, } } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/README.md new file mode 100644 index 000000000000..bf01ad9c85d1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/README.md @@ -0,0 +1,94 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy` Documentation + +The `resourceguardproxy` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2023-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy" +``` + + +### Client Initialization + +```go +client := resourceguardproxy.NewResourceGuardProxyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceGuardProxyClient.Delete` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardProxyClient.Get` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardProxyClient.Put` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + +payload := resourceguardproxy.ResourceGuardProxyBaseResource{ + // ... +} + + +read, err := client.Put(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardProxyClient.UnlockDelete` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + +payload := resourceguardproxy.UnlockDeleteRequest{ + // ... +} + + +read, err := client.UnlockDelete(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/client.go new file mode 100644 index 000000000000..d07fa6e5381d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/client.go @@ -0,0 +1,18 @@ +package resourceguardproxy + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyClient struct { + Client autorest.Client + baseUri string +} + +func NewResourceGuardProxyClientWithBaseURI(endpoint string) ResourceGuardProxyClient { + return ResourceGuardProxyClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/id_backupresourceguardproxy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/id_backupresourceguardproxy.go new file mode 100644 index 000000000000..a05bd4a2c999 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/id_backupresourceguardproxy.go @@ -0,0 +1,140 @@ +package resourceguardproxy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = BackupResourceGuardProxyId{} + +// BackupResourceGuardProxyId is a struct representing the Resource ID for a Backup Resource Guard Proxy +type BackupResourceGuardProxyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupResourceGuardProxyName string +} + +// NewBackupResourceGuardProxyID returns a new BackupResourceGuardProxyId struct +func NewBackupResourceGuardProxyID(subscriptionId string, resourceGroupName string, vaultName string, backupResourceGuardProxyName string) BackupResourceGuardProxyId { + return BackupResourceGuardProxyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupResourceGuardProxyName: backupResourceGuardProxyName, + } +} + +// ParseBackupResourceGuardProxyID parses 'input' into a BackupResourceGuardProxyId +func ParseBackupResourceGuardProxyID(input string) (*BackupResourceGuardProxyId, error) { + parser := resourceids.NewParserFromResourceIdType(BackupResourceGuardProxyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := BackupResourceGuardProxyId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "vaultName", *parsed) + } + + if id.BackupResourceGuardProxyName, ok = parsed.Parsed["backupResourceGuardProxyName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "backupResourceGuardProxyName", *parsed) + } + + return &id, nil +} + +// ParseBackupResourceGuardProxyIDInsensitively parses 'input' case-insensitively into a BackupResourceGuardProxyId +// note: this method should only be used for API response data and not user input +func ParseBackupResourceGuardProxyIDInsensitively(input string) (*BackupResourceGuardProxyId, error) { + parser := resourceids.NewParserFromResourceIdType(BackupResourceGuardProxyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := BackupResourceGuardProxyId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "vaultName", *parsed) + } + + if id.BackupResourceGuardProxyName, ok = parsed.Parsed["backupResourceGuardProxyName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "backupResourceGuardProxyName", *parsed) + } + + return &id, nil +} + +// ValidateBackupResourceGuardProxyID checks that 'input' can be parsed as a Backup Resource Guard Proxy ID +func ValidateBackupResourceGuardProxyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupResourceGuardProxyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupResourceGuardProxies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupResourceGuardProxyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupResourceGuardProxies", "backupResourceGuardProxies", "backupResourceGuardProxies"), + resourceids.UserSpecifiedSegment("backupResourceGuardProxyName", "backupResourceGuardProxyValue"), + } +} + +// String returns a human-readable description of this Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Resource Guard Proxy Name: %q", id.BackupResourceGuardProxyName), + } + return fmt.Sprintf("Backup Resource Guard Proxy (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_delete_autorest.go new file mode 100644 index 000000000000..5bc566a1459b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_delete_autorest.go @@ -0,0 +1,66 @@ +package resourceguardproxy + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c ResourceGuardProxyClient) Delete(ctx context.Context, id BackupResourceGuardProxyId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c ResourceGuardProxyClient) preparerForDelete(ctx context.Context, id BackupResourceGuardProxyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_get_autorest.go new file mode 100644 index 000000000000..34cbc308b05d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_get_autorest.go @@ -0,0 +1,68 @@ +package resourceguardproxy + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ResourceGuardProxyBaseResource +} + +// Get ... +func (c ResourceGuardProxyClient) Get(ctx context.Context, id BackupResourceGuardProxyId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ResourceGuardProxyClient) preparerForGet(ctx context.Context, id BackupResourceGuardProxyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_put_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_put_autorest.go new file mode 100644 index 000000000000..251f699920c4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_put_autorest.go @@ -0,0 +1,69 @@ +package resourceguardproxy + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutOperationResponse struct { + HttpResponse *http.Response + Model *ResourceGuardProxyBaseResource +} + +// Put ... +func (c ResourceGuardProxyClient) Put(ctx context.Context, id BackupResourceGuardProxyId, input ResourceGuardProxyBaseResource) (result PutOperationResponse, err error) { + req, err := c.preparerForPut(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPut(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForPut prepares the Put request. +func (c ResourceGuardProxyClient) preparerForPut(ctx context.Context, id BackupResourceGuardProxyId, input ResourceGuardProxyBaseResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPut handles the response to the Put request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_unlockdelete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_unlockdelete_autorest.go new file mode 100644 index 000000000000..4ddf4864869c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/method_unlockdelete_autorest.go @@ -0,0 +1,70 @@ +package resourceguardproxy + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteOperationResponse struct { + HttpResponse *http.Response + Model *UnlockDeleteResponse +} + +// UnlockDelete ... +func (c ResourceGuardProxyClient) UnlockDelete(ctx context.Context, id BackupResourceGuardProxyId, input UnlockDeleteRequest) (result UnlockDeleteOperationResponse, err error) { + req, err := c.preparerForUnlockDelete(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUnlockDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUnlockDelete prepares the UnlockDelete request. +func (c ResourceGuardProxyClient) preparerForUnlockDelete(ctx context.Context, id BackupResourceGuardProxyId, input UnlockDeleteRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/unlockDelete", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUnlockDelete handles the response to the UnlockDelete request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForUnlockDelete(resp *http.Response) (result UnlockDeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardoperationdetail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardoperationdetail.go new file mode 100644 index 000000000000..a211e1f34bbb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardoperationdetail.go @@ -0,0 +1,9 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardOperationDetail struct { + DefaultResourceRequest *string `json:"defaultResourceRequest,omitempty"` + VaultCriticalOperation *string `json:"vaultCriticalOperation,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardproxybase.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardproxybase.go new file mode 100644 index 000000000000..a9fa6c988f80 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardproxybase.go @@ -0,0 +1,11 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBase struct { + Description *string `json:"description,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + ResourceGuardOperationDetails *[]ResourceGuardOperationDetail `json:"resourceGuardOperationDetails,omitempty"` + ResourceGuardResourceId *string `json:"resourceGuardResourceId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardproxybaseresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardproxybaseresource.go new file mode 100644 index 000000000000..f68fdd803b7e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_resourceguardproxybaseresource.go @@ -0,0 +1,14 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceGuardProxyBase `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_unlockdeleterequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_unlockdeleterequest.go new file mode 100644 index 000000000000..5ed0ee6ebfee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_unlockdeleterequest.go @@ -0,0 +1,9 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteRequest struct { + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + ResourceToBeDeleted *string `json:"resourceToBeDeleted,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_unlockdeleteresponse.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_unlockdeleteresponse.go new file mode 100644 index 000000000000..6304a0fa5e6a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/model_unlockdeleteresponse.go @@ -0,0 +1,8 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteResponse struct { + UnlockDeleteExpiryTime *string `json:"unlockDeleteExpiryTime,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/version.go new file mode 100644 index 000000000000..c3087a3194ed --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy/version.go @@ -0,0 +1,12 @@ +package resourceguardproxy + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourceguardproxy/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index ca1940e95aca..6d1751e2cb4c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -517,6 +517,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-0 github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/protectioncontainers github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/protectionpolicies +github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2023-02-01/resourceguardproxy github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationfabrics github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationnetworkmappings github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationnetworks diff --git a/website/docs/r/recovery_services_vault__resource_guard_association.html.markdown b/website/docs/r/recovery_services_vault__resource_guard_association.html.markdown new file mode 100644 index 000000000000..1a1e91d3e1b2 --- /dev/null +++ b/website/docs/r/recovery_services_vault__resource_guard_association.html.markdown @@ -0,0 +1,74 @@ +--- +subcategory: "Recovery Services" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_recovery_services_vault_resource_guard_association" +description: |- + Manages an association of a Resource Guard and Recovery Services Vault. +--- + +# azurerm_recovery_services_vault_resource_guard_association + +Manages an association of a Resource Guard and Recovery Services Vault. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_data_protection_resource_guard" "example" { + name = "example-resourceguard" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location +} + +resource "azurerm_recovery_services_vault" "vault" { + name = "example-recovery-vault" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + sku = "Standard" + + soft_delete_enabled = true +} + +resource "azurerm_recovery_services_vault_resource_guard_association" "test" { + name = "example-guard-proxy" + vault_id = azurerm_recovery_services_vault.test.id + resource_guard_id = azurerm_data_protection_resource_guard.test.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Recovery Services Vault Resource Guard Association. Changing this forces a new resource to be created. + +* `vault_id` - (Required) ID of the Recovery Services Vault which should be associated with. Changing this forces a new resource to be created. + +* `resource_guard_id` - (Required) ID of the Resource Guard which should be associated with. Changing this forces a new resource to be created. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Resource Guard. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Resource Guard. +* `read` - (Defaults to 5 minutes) Used when retrieving the Resource Guard. +* `update` - (Defaults to 30 minutes) Used when updating the Resource Guard. +* `delete` - (Defaults to 30 minutes) Used when deleting the Resource Guard. + +## Import + +Resource Guards can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_recovery_services_vault_resource_guard_association.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.RecoveryServices/vaults/vault1/backupResourceGuardProxies/proxy1 +```