hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.1k stars 9.47k forks source link

terraform crash #35476

Open prr19776 opened 1 month ago

prr19776 commented 1 month ago

Terraform Version

1.5.7

Terraform Configuration Files

...terraform config...

Na

Debug Output

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.
When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.
[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!

runtime error: invalid memory address or nil pointer dereference
goroutine 459 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.20.7/x64/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /opt/hostedtoolcache/go/1.20.7/x64/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        /home/runner/work/terraform/terraform/internal/logging/panic.go:58 +0x153
panic({0x24481c0, 0x412fe10})
        /opt/hostedtoolcache/go/1.20.7/x64/src/runtime/panic.go:890 +0x263
github.com/hashicorp/terraform/internal/backend/remote-state/azure.(*RemoteClient).Put(0xc0002505a0, {0xc0019bee00, 0x10dfe, 0x1200fe})
        /home/runner/work/terraform/terraform/internal/backend/remote-state/azure/client.go:91 +0x583
github.com/hashicorp/terraform/internal/states/remote.(*State).PersistState({0xc00066de0, 0x7f0b5ef8f807})
        /home/runner/work/terraform/terraform/internal/states/remote/state.go:213 +0x5c5
github.com/hashicorp/terraform/internal/backend/local.(*StateHook).PostStateUpdate({0xc000622000, 0x102})
        /home/runner/work/terraform/terraform/internal/backend/local/hook_state.go:82 +0x219
github.com/hashicorp/terraform/internal/terraform.updateStateHook.func1({0x2e087d0, 0xc000622000})
        /home/runner/work/terraform/terraform/internal/terraform/update_state_hook.go:19 +0x2e
github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).Hook({0x0355e230, 0xc0837f0699})
        /home/runner/work/terraform/terraform/internal/terraform/eval_context_builtin.go:99 +0x78
github.com/hashicorp/terraform/internal/terraform.updateStateHook({0x2e112d8, 0xc02441c0})
        /home [❶](code://python)

Expected Behavior

TF plan is successful. Apply must have gone through as well

Actual Behavior

Plan is successful but while apply terraform crashes but this is typically happening after 45 minutes or 1 hour

Steps to Reproduce

Tf plan and tf apply

Additional Context

This is happening while creating SQL managed instances on Azure

References

No response

crw commented 1 month ago

Thanks, I've relayed this request to the Azure Provider team at HashiCorp, who maintains the Azure backend.

prr19776 commented 1 month ago

Any updates?

crw commented 1 month ago

No, the Azure team has not addressed the backend in some time. There is an intention to revisit the backend in the medium-term future, but no commitments as of yet.

duzitong commented 1 week ago

I met the same issue when running in ADO. This is caused due to OIDC token expiration.

I tried to use ARM_OIDC_TOKEN_FILE_PATH env for backend authentication and added a job to refresh token in background. But azurerm provider doesn't pick the latest token from the file which makes terraform still crash.

I overcome this issue by adding a reverse proxy locally to pretend ADO OIDC endpoint as GitHub OIDC endpoint and set ACTIONS_ID_TOKEN_REQUEST_URL, ACTIONS_ID_TOKEN_REQUEST_TOKEN.