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

Since: v3.96: azurerm_storage_share_file - status 400 received with no body #25353

Closed
1 task done
JasBonker opened this issue Mar 21, 2024 · 6 comments · Fixed by #25404
Closed
1 task done

Since: v3.96: azurerm_storage_share_file - status 400 received with no body #25353

JasBonker opened this issue Mar 21, 2024 · 6 comments · Fixed by #25404

Comments

@JasBonker
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

v1.7.5

AzureRM Provider Version

v3.96.0

Affected Resource(s)/Data Source(s)

azurerm_storage_share_file

Terraform Configuration Files

# --------------------------
# File share storage
# --------------------------
resource "azurerm_storage_share" "xxxxxxxxxxxx" {
  name                 = "xxxxxxxxxxxx"
  storage_account_name = data.terraform_remote_state.foundation.outputs.xxxxxxxxxxxx.name
  quota                = 50
}

resource "azurerm_backup_protected_file_share" "xxxxxxxxxxxx" {
  resource_group_name       = data.terraform_remote_state.foundation.outputs.azurerm_resource_group_backup.name
  source_storage_account_id = data.terraform_remote_state.backup.outputs.azurerm_backup_container_storage_account.storage_account_id
  recovery_vault_name       = data.terraform_remote_state.backup.outputs.azurerm_recovery_services_vault.name
  backup_policy_id          = data.terraform_remote_state.backup.outputs.azurerm_backup_policy_file_share.id
  source_file_share_name    = azurerm_storage_share.xxxxxxxxxxxxv.name
}

resource "local_file" "xxxxxxxxxxxx" {
  content = templatefile("${path.module}/../../../templates/xxxxxxxxxxxxxxxx.xml",
    {
      xxxxxx = var.xxxxxx
  })
  filename = "xxxxx.xml"
}

resource "azurerm_storage_share_directory" "xxxxxxxxxxxx" {
  name                 = "data"
  share_name           = azurerm_storage_share.xxxxxxxxxxxx.name
  storage_account_name = data.terraform_remote_state.foundation.outputs.azurerm_storage_account_mmc.name

}

resource "azurerm_storage_share_directory" "xxxxxxxxxxxx" {
  name                 = "data/xxxxxxxxxxxx"
  share_name           = azurerm_storage_share.xxxxxxxxxxxx.name
  storage_account_name = data.terraform_remote_state.foundation.outputs.azurerm_storage_account_mmc.name

  depends_on = [
    azurerm_storage_share_directory.data
  ]
}

resource "azurerm_storage_share_directory" "xxxxxxxxxxxx" {
  name                 = "data/xxxxxxxxxxxx/xxxxxxxxxxxx"
  share_name           = azurerm_storage_share.xxxxxxxxxxxx.name
  storage_account_name = data.terraform_remote_state.foundation.outputs.azurerm_storage_account_mmc.name

  depends_on = [
    azurerm_storage_share_directory.xxxxxxxxxxxx
  ]
}

resource "azurerm_storage_share_directory" "install" {
  name                 = "data/xxxxxxxxxxxx/xxxxxxxxxxxx/install"
  share_name           = azurerm_storage_share.xxxxxxxxxxxx.name
  storage_account_name = data.terraform_remote_state.foundation.outputs.azurerm_storage_account_mmc.name

  depends_on = [
    azurerm_storage_share_directory.mmc
  ]
}

resource "azurerm_storage_share_directory" "resources" {
  name                 = "data/xxxxxxxxxxxx/xxxxxxxxxxxx/install/resources"
  share_name           = azurerm_storage_share.xxxxxxxxxxxx.name
  storage_account_name = data.terraform_remote_state.foundation.outputs.azurerm_storage_account_mmc.name

  depends_on = [
    azurerm_storage_share_directory.install
  ]
}

resource "azurerm_storage_share_file" "xxxxxxxxxxxx" {
  name             = "xxxxxxxxxxxxs.xml"
  storage_share_id = azurerm_storage_share.xxxxxxxxxxxx.id
  path             = "data\\xxxxxxxxxxxx\\xxxxxxxxxxxx\\install\\resources"
  source           = "xxxxxxxxxxxx.xml"

  depends_on = [
    azurerm_storage_share_directory.resources
  ]
}

Debug Output/Panic Output

│ Error: checking for existing File "xxxxxxxxxxxx.xml" (Directory Path "data\\xxxxxxxxxxxx\\xxxxxxxxxxxx\\install\\resources" / Share Name "xxxxxxxxxxxx" / Account "Account \"xxxxxxxxxxxx\" (IsEdgeZone false / ZoneName \"\" / Subdomain Type \"file\" / DomainSuffix \"core.windows.net\")"): executing request: unexpected status 400 received with no body
│
│   with azurerm_storage_share_file.xxxxxxxxxxxx,
│   on main.tf line 131, in resource "azurerm_storage_share_file" "xxxxxxxxxxxx":
│  131: resource "azurerm_storage_share_file" "xxxxxxxxxxxxv" {

Expected Behaviour

Ideally:
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Or otherwise:
│ Error: A resource with the ID "https://xxxxxxxxxxxx.file.core.windows.net/xxxxxxxxxxxx/data\\xxxxxxxxxxxx\\xxxxxxxxxxxx\\install\\resources/xxxxxxxxxxxx.xml" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_storage_share_file" for more information.

│ with azurerm_storage_share_file.xxxxxxxxxxxx,
│ on main.tf line 131, in resource "azurerm_storage_share_file" "xxxxxxxxxxxx":
│ 131: resource "azurerm_storage_share_file" "xxxxxxxxxxxx" {

Actual Behaviour

│ Error: checking for existing File "xxxxxxxxxxxx.xml" (Directory Path "data\xxxxxxxxxxxx\xxxxxxxxxxxx\install\resources" / Share Name "xxxxxxxxxxxx" / Account "Account "xxxxxxxxxxxx" (IsEdgeZone false / ZoneName "" / Subdomain Type "file" / DomainSuffix "core.windows.net")"): executing request: unexpected status 400 received with no body

│ with azurerm_storage_share_file.xxxxxxxxxxxx,
│ on main.tf line 131, in resource "azurerm_storage_share_file" "xxxxxxxxxxxx":
│ 131: resource "azurerm_storage_share_file" "xxxxxxxxxxxxv" {

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

@JasBonker
Copy link
Author

Additional info, I tested with v3.95 and TF 1.6.x and with TF 1.7.x and both works fine.
Once the Azure RM provider is set to v3.96 (and either TF 1.6.x or with TF 1.7.x) it breaks.

@manicminer manicminer added this to the v3.97.0 milestone Mar 21, 2024
@manicminer manicminer self-assigned this Mar 21, 2024
@manicminer
Copy link
Contributor

@JasBonker Thanks for reporting this bug. I suspected a possible issue with handling backslash-delimited paths in the name, but in testing I was unable to reproduce this.

Would you be able to provide a debug log (i.e. by setting the TF_LOG=DEBUG environment variable) to assist with tracking down the issue? Thanks!

@tombuildsstuff
Copy link
Contributor

@JasBonker would you be able to upgrade to v3.97.1 and confirm if this is still happening for you?

@JasBonker
Copy link
Author

JasBonker commented Mar 22, 2024

Hi @tombuildsstuff and @manicminer,
Thanks for the quick replies!
With 3.97.1 the issue sadly still persists. Here is the log file:
issue25353.log

@manicminer
Copy link
Contributor

manicminer commented Mar 26, 2024

Thanks for the additional info @JasBonker! I've identified some bugs in path handling, along with some gaps in our test coverage that allowed this to slip by unnoticed. I've opened tombuildsstuff/giovanni#113 to address these bugs, and #25404 for the test coverage.

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 Apr 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.