digitalocean / packer-plugin-digitalocean

Packer plugin for DigitalOcean Builder
https://developer.hashicorp.com/packer/integrations/digitalocean/digitalocean
Mozilla Public License 2.0
22 stars 13 forks source link

ssh_key_id does not work with ssh_private_key_file in v1.2.0 #113

Closed pragnesh closed 9 months ago

pragnesh commented 11 months ago

Overview of the Issue

I am trying to use exisiting ssh key in account. if i specify ssh_key_id and ssh_private_key_file. I am getting following error when i try to create image.

digitalocean.example: output will be in this color.

==> digitalocean.example: Using existing SSH private key
==> digitalocean.example: Importing SSH public key...
==> digitalocean.example: Error creating temporary SSH key: POST https://api.digitalocean.com/v2/account/keys: 422 (request "3099ae6d-a836-44ab-9449-c41ccf192f45") SSH Key is already in use on your account
Build 'digitalocean.example' errored after 1 second 304 milliseconds: Error creating temporary SSH key: POST https://api.digitalocean.com/v2/account/keys: 422 (request "3099ae6d-a836-44ab-9449-c41ccf192f45") SSH Key is already in use on your account

==> Wait completed after 1 second 304 milliseconds

==> Some builds didn't complete successfully and had errors:
--> digitalocean.example: Error creating temporary SSH key: POST https://api.digitalocean.com/v2/account/keys: 422 (request "3099ae6d-a836-44ab-9449-c41ccf192f45") SSH Key is already in use on your account

==> Builds finished but no artifacts were created.

Reproduction Steps

Steps to reproduce this issue

Plugin and Packer version

From packer version

Packer v1.9.4

Simplified Packer Buildfile

packer {
  required_plugins {
    digitalocean = {
      version = ">= 1.0.0"
      source  = "github.com/digitalocean/digitalocean"
    }
  }
}

source "digitalocean" "example" {
  api_token            = "api_token"
  image                = "ubuntu-23-04-x64"
  region               = "nyc3"
  size                 = "s-1vcpu-1gb"
  ssh_username         = "root"
  ssh_key_id           = key_id
  ssh_private_key_file = "key_path"
}

build {
  sources = ["source.digitalocean.example"]
}

Operating system and Environment details

ubuntu 22.04