Troubleshooting : Packer "Timeout waiting for SSH" on AWS

Problem: I recently ran into an SSH Timeout error while trying to execute a “packer build” for an AMI on AWS. This was very confusing to me because the files were tested successfully in a different AWS account.

Solution: The fix was to include values for vpc_id and subnet_id in the .pkr.hcl file.

Why : Networking needed to be investigated as the error was related to SSH. After checking “is it on?” then the next thing to check is “can I get there from here?”

It occurred to me that Packer tries to build the instance in the default VPC. The default VPC in the account where the build worked had a working gateway. I checked the gateway of the failing account, and sure enough, the default VPC had a gateway redirecting to a blackhole. By listing the VPC and Subnet_ID of a VPC with a public subnet, I was able to get the build to complete.