The Ubuntu image created with Packer not able to ssh into the VM (GCP)

Packer Installation on Local machine:

Packer version :

packer --version

Packer 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”: “asia-south1-a”,

“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:

  1. Increased the SSH timeout to 10 minutes, but still getting the same error.
  2. Added the network tag in the Packer template to enable SSH, but it didn’t resolve the issue.
  3. Tried to SSH using the IAP tunnel, but it still didn’t work.
  4. 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.

Please provide input to ssh into internal ip vm using packer