Adding hostnames in AWX with inventory sync

I am trying to add a source in inventory sync to fetch hostnames from the GCP console.
After fetching hostnames and running a job template, it is failing with an unreachable error, however, it works with IP.
How can I make a hostname to work with ssh while running the job?