hashicorp / packer-plugin-googlecompute

Packer plugin for Google Compute Builder
https://www.packer.io/docs/builders/googlecompute
Mozilla Public License 2.0
23 stars 51 forks source link

Support ssh-key-expire-after #160

Open ralbertazzi opened 1 year ago

ralbertazzi commented 1 year ago

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request. If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

We are running several Packer builds on the same GCP project and using the same service account. VMs are accessed through OSLogin and IAP authentication. Sometimes jobs break with this error:

2023-05-03T16:09:00Z: ==> googlecompute.cos_image: Checking image does not exist...
2023-05-03T16:09:00Z: ==> googlecompute.cos_image: Creating temporary RSA SSH key for instance...
2023-05-03T16:09:01Z: ==> googlecompute.cos_image: no persistent disk to create
2023-05-03T16:09:01Z: ==> googlecompute.cos_image: Importing SSH public key for OSLogin...
2023-05-03T16:09:06Z: ==> googlecompute.cos_image: Error importing SSH public key for OSLogin: googleapi: Error 400: Login profile size exceeds 32 KiB. Delete profile values to make additional space.

The only way we can solve it is through this SO solution that encourages us cleaning up SSH keys. At the same time, the solution mentions the existence of a --ssh-key-expire-after parameter that would cleanup SSH keys automatically. It would be great it this Packer plugin would expose that parameter

Use Case(s)

Running several Packer builds using the same service account and OSLogin.

Potential configuration

Currently I am using

use_iap = true
use_os_login = true

I would like for source "googlecompute" to expose a ssh_key_expire_after parameter among the other many SSH configuration parameters.

Potential References