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

Remote state issue: Status=413 Code="RequestBodyTooLarge" #36135

Open
madejusz opened this issue Nov 29, 2024 · 2 comments · May be fixed by #36230
Open

Remote state issue: Status=413 Code="RequestBodyTooLarge" #36135

madejusz opened this issue Nov 29, 2024 · 2 comments · May be fixed by #36230
Labels
backend/azure bug new new issue not yet triaged

Comments

@madejusz
Copy link

madejusz commented Nov 29, 2024

Terraform Version

Terraform v1.9.8
on darwin_arm64
+ provider registry.terraform.io/hashicorp/azurerm v4.12.0
+ provider registry.terraform.io/hashicorp/local v2.5.2
+ provider registry.terraform.io/hashicorp/random v3.6.3

Terraform Configuration Files

provider "azurerm" {

  features {
    resource_group {
      prevent_deletion_if_contains_resources = false
    }
    key_vault {
      purge_soft_delete_on_destroy    = true
      recover_soft_deleted_key_vaults = true
    }
  }
  skip_provider_registration = true
}
terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      #version >~ "3.0"
    }
    random = {
      source  = "hashicorp/random"
      version = "~> 3.0"
    }
  }
  backend "azurerm" {
container_name="big-stat"
key="big_state_test"
resource_group_name="my-dev-tf"
storage_account_name="mydevsatf"
}
}

Debug Output

https://gist.github.com/madejusz/048078a9f2725186c30f6157d36f5fb9

Expected Behavior

Stage file bigger then 250MB should work with remote state AzureRM (storage account)

Actual Behavior

Error: Failed to save state

│ Error saving state: blobs.Client#PutBlockBlob: Failure responding to request: StatusCode=413 -- Original Error: autorest/azure: Service returned an error. Status=413 Code="RequestBodyTooLarge" Message="The request body is too large and exceeds the maximum permissible
│ limit.\nRequestId:c3a3d901-901e-002f-4957-42b6f2000000\nTime:2024-11-29T12:06:10.0500344Z"


│ Error: Failed to persist state to backend

│ The error shown above has prevented Terraform from writing the updated state to the configured backend. To allow for recovery, the state has been written to the file "errored.tfstate" in the current working directory.

│ Running "terraform apply" again at this point will create a forked state, making it harder to recover.

│ To retry writing this state, use the following command:
│     terraform state push errored.tfstate

Steps to Reproduce

  1. Create a file with size 1MB:
    yes "This is some meaningful content for encoding." | head -c 750000 | base64 | head -c 1048576 > file.txt

  2. Use file as input for:

resource "local_file" "foo" {
  for_each = { for i in range(1, 300) : format("foo%03d", i) => i }

  content  = file("${path.module}/file.txt")
  filename = "${path.module}/foo/${each.key}.bar"
}
  1. setup remote backend pointing to Azure Storage Account blob container.
  2. $ terraform apply -auto-approve

Additional Context

No response

References

No response

@madejusz madejusz added bug new new issue not yet triaged labels Nov 29, 2024
@bschaatsbergen
Copy link
Member

bschaatsbergen commented Nov 30, 2024

Hey @madejusz,

Thank you for reporting this! The azurerm backend is managed by the Azure Provider team at HashiCorp, and this issue has been added to their triage queue. Thanks again!

@magodo
Copy link
Contributor

magodo commented Dec 18, 2024

Thank you @madejusz for the great repro steps! With #36230, the above steps can proceed successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend/azure bug new new issue not yet triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants