When you use IAP for the first time, there are misunderstandings
CAUTION
The 2 last solutions work as-is if your compute engine doesn't have public IP. In the other case:
- Through the console, and the ssh button, you can't!
- With the gcloud command, force gcloud to use the IAP tunnel by adding the
--tunnel-through-iap
param like this
gcloud compute ssh <INSTANCE NAME> --tunnel-through-iap
EDIT
On the IAP page, and on the ssh and http tab you can see a yellow warning sign because your firewall rule is not compliant.
Actually, IAP checks if the firewall rule for IAP allows ALL the tcp port. If not, you have a warning.
At the end, it's not a problem, if you only need to use IAP for the port 22 and 3389 (for example) you can only allows these port and the IAP tunnel will work only for these 2 ports. You will continue to have the warning, but don't care of it, it works on what you want!!