diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index e9b1f5216..040cb351c 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -41,7 +41,10 @@ type StepRunSourceInstance struct { func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepAction { 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)) ui := state.Get("ui").(packer.Ui)