Packer Installation on Local machine:
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install packer
Ref
Packer version :
packer --versionPacker v1.11.0
Packer Template:
{"builders": [ {"type": "googlecompute","project_id": "project_Id","source_image_project_id":"project_id","source_image": "image_name","disk_size": "200","communicator": "ssh","use_os_login": false,"tags":"ssh","use_iap": true,"ssh_timeout":"10m","iap_tunnel_launch_wait":"90","ssh_username": "packer","zone": "region","subnetwork": "subnet_selflink","omit_external_ip": true,"use_internal_ip": true } ],"provisioners": [ {"type": "file","source": "local_file_namet","destination": "destination_path" } ]}
The above packer template, is able to create a vm using the specified image, in the specified project, But it is failing to ssh into the created vm. It is showing connection timeout error.
Things tried:
- Increased the SSH timeout to 10 minutes, but still getting the same error.
- Added the network tag in the Packer template to enable SSH, but it didn't resolve the issue.
- Tried to SSH using the IAP tunnel, but it still didn't work.
- Executed the same Packer template by creating a VM and modified the template to create a VM in the same subnet as the VM, but still encountering a timeout error.
Have added the iap_tunnel_launch_wait to 90 but its not helping, referred the below article for the troubleshooting
https://github.com/hashicorp/packer/issues/12169
Please let me know if i am missing something here