Packer attempts to connect to the private ip when using spot on AWS

Hi.

So I have a perfectly working Packer json file I was using for some time now. In recent days I explored AWS spot instances more and decided to put in the spot options in my Packer json as well. Straightforward, no so much on the config side to go wrong… At least that’s what I think.

Now the spot request fires, comes back successfully BUT then Packer tries to connect to the private ip instead of the public ip. Needless to say that Waiting for SSH to become available... times out:

==> lb: Interpolating tags for spot instance...
lb: Adding tag: "Name": "Packer Builder"
lb: Loading User Data File...
lb: Creating Spot Fleet launch template...
lb: Sending spot request ()...
lb: Instance ID: i-0a6f4jibberish79fd
==> lb: Using ssh communicator to connect: 172.33.25.70

So really the delta to my working config without spot is:

"associate_public_ip_address": true,
"spot_price": "0.004",
"instance_type": "t3.micro",

Initially I thought the "associate_public_ip_address": true has to be set in order for this to work, but no luck with or without this. This behaviour shows on Packer v1.5.5 as well as on the recently released v1.5.6.

Any hint is appreciated.

Cheers
Ralph

Hi,
I had the same issue on MacOS with packer 1.7.2
Adding the line:
“associate_public_ip_address”: true,
fixed the issue.

AAber

Thanks for letting me know @AAber! I had that line in my config, but at that time it had no effect. Could have been a bug that was solved in the meantime for all I know. I haven’t looked at spot instances Packer-wise since, but I’ll give it another shot!

Cheers

I have the same issue, but again only with spot. I tried explicitly activating associate_public_ip_address, but it still takes the private one. It does have a public one, and if it is not spot, it takes the public one. I don’t understand what those two things have to do with each other.