Packer fatal error: runtime: out of memory

I am getting fatal error out of memory during build of Window server image. The last log message I can see if aws cli installing. I was able to login to the VM and can see the CLI components being written out and it looks it’s all there but the next message from the packer outout is a bunch of go errors like below. Packer version is 1.6.1 running on on AWS Linux 2. Which I know is old. 2025684 K total memory

fatal error: runtime: out of memory

runtime stack:
runtime.throw(0x4ba7041, 0x16)
/usr/local/go/src/runtime/panic.go:774 +0x72
runtime.sysMap(0xc050000000, 0x4000000, 0x822fe78)
/usr/local/go/src/runtime/mem_linux.go:169 +0xc5
runtime.(*mheap).sysAlloc(0x8209500, 0x2000, 0x2000, 0xc0000a3ed8)
/usr/local/go/src/runtime/malloc.go:701 +0x1cd
runtime.(*mheap).grow(0x8209500, 0x1, 0xffffffff)
/usr/local/go/src/runtime/mheap.go:1255 +0xa3
runtime.(*mheap).allocSpanLocked(0x8209500, 0x1, 0x822fe88, 0xc0002f6300)
/usr/local/go/src/runtime/mheap.go:1170 +0x266
runtime.(*mheap).alloc_m(0x8209500, 0x1, 0x45000c, 0x3)
/usr/local/go/src/runtime/mheap.go:1022 +0xc2
runtime.(*mheap).alloc.func1()
/usr/local/go/src/runtime/mheap.go:1093 +0x4c
runtime.systemstack(0x45b961)
/usr/local/go/src/runtime/asm_amd64.s:370 +0x66
runtime.mstart()
/usr/local/go/src/runtime/proc.go:1146