Locate temporary key pair during packer build

Hi

I’m new to packer and currently working on an automation tool. So, here in packer when the instance is getting ready I require two things i.e private_ip and Temporary key_pair path of the server. I found a way to get the IP and download it in my local and also there is an attribute defined which helps to get the key_pair as well. However, my actual requirement is to get the path of the key_pair.
Is there any possible way, how I can achieve that.

Many Thanks…!

You can use the build variables to get the SSHPublicKey and SSHPrivateKey. Here both ways you can use them in JSON or HCL2:
JSON engine: https://www.packer.io/docs/templates/engine#build
HCL2 contextual variables: https://www.packer.io/docs/from-1.5/contextual-variables#build-variables

1 Like