builder/amazon: delete physical private key for debug mode [GH-1801]
This commit is contained in:
parent
3f636ef7f3
commit
edf3415c6e
|
@ -23,6 +23,8 @@ BUG FIXES:
|
|||
consistency. [GH-2129]
|
||||
* builder/amazon: If no AZ is specified, use AZ chosen automatically by
|
||||
AWS for spot instance. [GH-2017]
|
||||
* builder/amazon: Private key file (only available in debug mode)
|
||||
is deleted on cleanup. [GH-1801]
|
||||
* builder/amazon/chroot: Retry waiting for disk attachments [GH-2046]
|
||||
* builder/amazon/instance: Use `-i` in sudo commands so PATH is inherited. [GH-1930]
|
||||
* builder/digitalocean: Ignore invalid fields from the ever-changing v2 API
|
||||
|
|
|
@ -91,10 +91,19 @@ func (s *StepKeyPair) Cleanup(state multistep.StateBag) {
|
|||
ec2conn := state.Get("ec2").(*ec2.EC2)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
// Remove the keypair
|
||||
ui.Say("Deleting temporary keypair...")
|
||||
_, err := ec2conn.DeleteKeyPair(&ec2.DeleteKeyPairInput{KeyName: &s.keyName})
|
||||
if err != nil {
|
||||
ui.Error(fmt.Sprintf(
|
||||
"Error cleaning up keypair. Please delete the key manually: %s", s.keyName))
|
||||
}
|
||||
|
||||
// Also remove the physical key if we're debugging.
|
||||
if s.Debug {
|
||||
if err := os.Remove(s.DebugKeyPath); err != nil {
|
||||
ui.Error(fmt.Sprintf(
|
||||
"Error removing debug key '%s': %s", s.DebugKeyPath, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue