diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index 578f6d0d3..f32eb3ed3 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -57,9 +57,8 @@ type RunConfig struct { WindowsPasswordTimeout time.Duration `mapstructure:"windows_password_timeout"` // Communicator settings - Comm communicator.Config `mapstructure:",squash"` - SSHKeyPairName string `mapstructure:"ssh_keypair_name"` - SSHInterface string `mapstructure:"ssh_interface"` + Comm communicator.Config `mapstructure:",squash"` + SSHInterface string `mapstructure:"ssh_interface"` } func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { @@ -67,7 +66,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { // ssh_private_key_file, then create a temporary one, but only if the // temporary_key_pair_name has not been provided and we are not using // ssh_password. - if c.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" && + if c.Comm.SSHKeyPair == "" && c.TemporaryKeyPairName == "" && c.Comm.SSHPrivateKeyFile == "" && c.Comm.SSHPassword == "" { c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID()) @@ -93,7 +92,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { errs = append(errs, fmt.Errorf("Unknown interface type: %s", c.SSHInterface)) } - if c.SSHKeyPairName != "" { + if c.Comm.SSHKeyPair != "" { if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKeyFile == "" { errs = append(errs, fmt.Errorf("ssh_private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name.")) } else if c.Comm.SSHPrivateKeyFile == "" && !c.Comm.SSHAgentAuth {