[Vagrant] The following settings don't exist: ssh_private_key_path, ssh_usernameの対処法

Vagrant + AWS連携しようとしたらエラーが出ました。
$ vagrant up --provider=aws
Bringing machine 'default' up with 'aws' provider...
An error occurred while executing multiple actions in parallel.
Any errors that occurred are shown below.

An error occurred while executing the action on the 'default'
machine. Please handle this error then try again:

There are errors in the configuration of this machine. Please fix
the following errors and try again:

AWS Provider:
* The following settings don't exist: ssh_private_key_path, ssh_username

原因と対処法

Vagrantfileの書き方に問題があったようです。
Vagrant.configure("2") do |config|
  config.vm.box = "dummy"
  config.vm.provider :aws do |aws|
    ...
    aws.ssh_username = "ec2-user"
    aws.ssh_private_key_path = "~/.ssh/private.pem"
    ...
  end
end
この記法ではダメなようです。
こういうときは公式マニュアルを見ましょう。
https://github.com/mitchellh/vagrant-aws
ただしくは、こう。
Vagrant.configure("2") do |config|
  config.vm.box = "dummy"
  config.vm.provider :aws do |aws, override|
    ...
    override.ssh.username = "ec2-user"
    override.ssh.private_key_path = "~/.ssh/private.pem"
    ...
  end
end
カテゴリ: