Merge pull request #4597 from mitchellh/fix4452

fix ssh agent authentication
This commit is contained in:
Matthew Hooker 2017-02-26 17:39:34 -08:00 committed by GitHub
commit 390f018a7d
2 changed files with 5 additions and 2 deletions

View File

@ -107,7 +107,7 @@ func (s *StepKeyPair) Cleanup(state multistep.StateBag) {
// If no key name is set, then we never created it, so just return // If no key name is set, then we never created it, so just return
// If we used an SSH private key file, do not go about deleting // If we used an SSH private key file, do not go about deleting
// keypairs // keypairs
if s.PrivateKeyFile != "" || s.KeyPairName != "" { if s.PrivateKeyFile != "" || (s.KeyPairName == "" && s.keyName == "") {
return return
} }

View File

@ -41,7 +41,10 @@ type StepRunSourceInstance struct {
func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepAction { func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepAction {
ec2conn := state.Get("ec2").(*ec2.EC2) ec2conn := state.Get("ec2").(*ec2.EC2)
keyName := state.Get("keyPair").(string) var keyName string
if name, ok := state.GetOk("keyPair"); ok {
keyName = name.(string)
}
securityGroupIds := aws.StringSlice(state.Get("securityGroupIds").([]string)) securityGroupIds := aws.StringSlice(state.Get("securityGroupIds").([]string))
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)