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.52k stars 4.6k forks source link

provider.azurerm does not support data source "azurerm_backup_container_storage_account" #13872

Open Sum123it opened 2 years ago

Sum123it commented 2 years ago

Terraform (and AzureRM Provider) Version

2.70.0

Affected Resource(s)

azurerm_backup_container_storage_account

data source for below - azurerm_backup_container_storage_account

Terraform Configuration Files

provider "azurerm" {
  version         = "~> 2.70.0"
  alias           = "azurerm282"

  features {}
}

data "azurerm_resource_group" "rg" {
  name  = "xxx" #var.resource_group_name
}
data "azurerm_storage_account" "sa" {
  #for_each            = var.function_apps
  name                =  "xxxxxx" #each.value.storage_account_name
  resource_group_name = data.azurerm_resource_group.rg.name #var.resource_group_name

}

data "azurerm_storage_share" "share1" {   #not a resource only data
  name                 = "xxxx"
  storage_account_name = data.azurerm_storage_account.sa.name
}

data "azurerm_recovery_services_vault" "vault" {
  resource_group_name = data.azurerm_resource_group.rg.name
  name                = "xxxx" #var.azurerm_recovery_services_vault
}

data "azurerm_backup_container_storage_account" "container" {  #not a resource
  resource_group_name = data.azurerm_resource_group.rg.name
  recovery_vault_name = data.azurerm_recovery_services_vault.vault.name
  storage_account_id  = data.azurerm_storage_account.sa.id
  provider            = azurerm.azurerm282
}

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

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

  retention_daily {
    count = 10
  }
}
resource "azurerm_backup_protected_file_share" "share1" {
  resource_group_name       = data.azurerm_resource_group.rg.name
  recovery_vault_name       = data.azurerm_recovery_services_vault.vault.name
  source_storage_account_id = data.azurerm_backup_container_storage_account.container.storage_account_id                                                             #resource.azurerm_backup_container_storage_account.container.storage_account_id
  source_file_share_name    = data.azurerm_storage_share.share1.name 
                              #resource.azurerm_storage_share.fileshare.name
  backup_policy_id          = azurerm_backup_policy_file_share.example.id

Debug Output

Panic Output

Error: Invalid data source

  on var-filesharebkuppolicy.tf line 37, in data "azurerm_backup_container_storage_account" "container":
  37: data "azurerm_backup_container_storage_account" "container" {  #not a resource

The provider provider.azurerm.azurerm282 does not support data source
"azurerm_backup_container_storage_account".

Expected Behaviour

Need to know which azure rm provider should I use to use all above data/resources

Actual Behaviour

Steps to Reproduce

  1. terraform apply

Important Factoids

References

aristosvo commented 2 years ago

Hi @Sum123it!

Is there a specific reason you'd like to have a data source?

You could use the ID of the storage account to specify your source_storage_account_id:

source_storage_account_id  = data.azurerm_storage_account.sa.id
Sum123it commented 2 years ago

@aristosvo - Thanks! that will do.

But still the question is which provider supports data "azurerm_backup_container_storage_account" not sure

aristosvo commented 2 years ago

@Sum123it I'm not sure if I understand your question, but at the moment azurerm_backup_container_storage_account is not supported as a data source. I cannot predict if it ever will or what the timeline will be.

Sum123it commented 2 years ago

Thanks @aristosvo . Can we request this as a feature? If not- we can close this thread.