hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

Cannot create azurerm_data_protection_backup_vault with SnapshotStore as the datastore type. It works with VaultStore okay. #18826

Open zanoni23 opened 2 years ago

zanoni23 commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.2 linux_amd64

AzureRM Provider Version

3.27.0

Affected Resource(s)/Data Source(s)

azurerm_data_protection_backup_vault

Terraform Configuration Files

resource "azurerm_data_protection_backup_vault" "disk-backup-vault" {
#    datastore_type      = "VaultStore"  # this works
    datastore_type      = "SnapshotStore"
    location            = "australiaeast"
    name                = "sft-disk-backups-md-aue-01-bv"
    redundancy          = "LocallyRedundant"
    resource_group_name = "sft-backup-ts-aue-01-rg"
    tags                = {}
}

Debug Output/Panic Output

https://gist.github.com/zanoni23/cfaef2fefd627b94502b9bfbe50a8f76

Expected Behaviour

azurerm_data_protection_backup_vault.disk-backup-vault: Creating... azurerm_data_protection_backup_vault.disk-backup-vault: Still creating... [10s elapsed] azurerm_data_protection_backup_vault.disk-backup-vault: Creation complete after 12s

Actual Behaviour

azurerm_data_protection_backup_vault.disk-backup-vault: Creating... ╷ │ Error: creating DataProtection BackupVault ("Backup Vault (Subscription: \"XXXXXXX-a36e-4e90-b621-d6348168280b\"\nResource Group Name: \"sft-backup-ts-aue-01-rg\"\nVault Name: \"sft-disk-backups-md-aue-01-bv\")"): performing CreateOrUpdate: backupvaults.BackupVaultsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="BMSUserErrorInvalidInput" Message="Input provided for the call is invalid" AdditionalInfo=[{"info":{"code":"BMSUserErrorInvalidInput","details":null,"innerError":null,"isRetryable":false,"isUserError":false,"message":"Input provided for the call is invalid","properties":{"ActivityId":"9a6d916e-688c-47c0-a92e-e5a7bd731360"},"recommendedAction":["Please check the required inputs"],"target":""},"type":"UserFacingError"}] │ │ with azurerm_data_protection_backup_vault.disk-backup-vault, │ on main.tf line 1, in resource "azurerm_data_protection_backup_vault" "disk-backup-vault": │ 1: resource "azurerm_data_protection_backup_vault" "disk-backup-vault" {

This worked earlier in the year within the same subscription/region. I'm trying to deploy a test instance and it fails.

Perhaps related, I tried to import a Vault into TF state, using the resource id copied from the Azure Portal and got an error:

Error: parsing Resource ID "/subscriptions/96ae2c26-a36e-4e90-b621-d6348168280b/resourcegroups/sft-backup-ts-aue-01-rg/providers/Microsoft.DataProtection/BackupVaults/sft-disk-backups-ts-aue-01-bv": ID was missing the `backupVaults` element

In the resource path I changed the BackupVaults to backupVaults and it then imported okay.

Steps to Reproduce

terraform apply

Important Factoids

No response

References

Terraform docs: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_protection_backup_vault MS API docs: https://learn.microsoft.com/en-us/rest/api/dataprotection/backup-vaults/create-or-update?tabs=HTTP#storagesettingstoretypes

sinbai commented 2 years ago

@zanoni23 thanks for opening this issue. It seems that this is an Azure API issue. I have filed an API issue for it. Could you follow it for more update?

fardarter commented 2 years ago

Not to hijack this issue but can someone tell me what the difference between them is? I've made resources with all of them and can't seem to figure out the difference.

jannickk commented 1 year ago

Having the same problem:

Terraform Version 1.2.8

AzureRM Provider Version 3.35.0

Affected Resource

azurerm_data_protection_backup_vault

Configured ressource:

resource azurerm_data_protection_backup_vault "backup_vault" {

name = "${var.environment.alias}-bv-vaultstore-${local.hub_location_alias}" resource_group_name = azurerm_resource_group.rg["rg_backup"].name location = azurerm_resource_group.rg["rg_backup"].location datastore_type = "SnapshotStore" redundancy = "LocallyRedundant" }

It fails with Message="Input provided for the call is invalid"

I tried to set all different values for redundancy to no avail as the terraform validate command only allows GeoRedundant and LocallyRedudant.

jannickk commented 1 year ago

It appears the bug in the Azure API is fixed as the related issue is closed and the merge is completed. @sinbai : When can we expect the concordant pull request on Terraform and its release to happen?

aparker-cityworks commented 1 year ago

The datastore_type should allow for OperationalStore now rather than SnapshotStore. Can we get this fixed?