Problem
On a Windows platform, when running a terraform plan from the command line it fails resulting in memory errors similar to:
c:\terraform plan
Running plan in the remote backend. Output will stream here. Pressing Ctrl-C
will stop streaming the logs, but will not stop the plan running remotely.
Preparing the remote plan...
The remote workspace is configured to work with configuration at c:\<
relative to the target repository.
Terraform will upload the contents of the following directory,
excluding files or directories as defined by a .terraformignore file
at c:\<the terraform code directory>/.terraformignore(if it is present),
in order to capture the filesystem context the remote workspace expects:
c:\<the terraform code directory>/
runtime: out of memory: cannot allocate xxxxxxxxxx-byte block (xxxxxxxxxx in use)
fatal error: out of memory
goroutine 52 [running]:
runtime.throw({0x33ce057, 0xd})
<directory>/1.21.8/x64/src/runtime/panic.go:1077 +0x4d fp=0xef06fc0 sp=0xef06fac pc=0x6bd52d
runtime.(*mcache).allocLarge(0x58f0778, 0x40000000, 0x1)
<directory>/1.21.8/x64/src/runtime/mcache.go:236 +0x1c5 fp=0xef06fec sp=0xef06fc0 pc=0x698125
runtime.mallocgc(0x40000000, 0x0, 0x0)
Prerequisites
- Windows 64 bit OS based platform
Cause
- Depending on your OS architecture, it is necessary to download the correct bit version of the terraform binary from https://releases.hashicorp.com/terraform/
- Each release comes in a 32 bit or 64 bit version
- Running a 32 bit terraform binary on a 64 bit OS may result in out of memory runtime errors
Solution
Download the desired 64 bit terraform version from https://releases.hashicorp.com/terraform/ and rerun the terraform plan. It should execute without the memory errors since the terraform binary 64 bit will match the OS 64 bit Architecture.
Additional Information
For additional assistance please contact HashiCorp Support to request additional assistance