运行vagrant命令时出现如下错误,
# vagrant up --provider=aws
本机配置有误。请修理 出现以下错误并再试一次:
AWS提供商: *必须通过“ami”(区域:#{region})
配置AMI我正在使用Vagrant 2.0.1和vagrant-aws 0.7.2
Vagrant档案:
Vagrant.configure("2") do |config|
require 'vagrant-aws'
Vagrant.configure('2') do |config|
config.vm.box = 'Vagarent'
config.vm.provider 'aws' do |aws, override|
aws.access_key_id = "xxxxxxxxxxxxxxxxxx"
aws.secret_access_key = "xxxxxxxxxxxxxxxxxxxxxxxx"
aws.keypair_name = 'ssh-keypair-name'
aws.instance_type = "t2.micro"
aws.region = 'us-west-2a'
aws.ami = 'ami-1122298f0'
aws.security_groups = ['default']
override.ssh.username = 'ubuntu'
override.ssh.private_key_path = '~/.ssh/ssh-keypair-file'
end
end
如何解决?
答案 0 :(得分:1)
us-west-2a
不是有效的地区名称,有关可用地区和终点的完整列表,请参阅https://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region。
如果AMI位于美国西部(俄勒冈州),那么您需要在Vagrantfile中替换为us-west-2
答案 1 :(得分:1)
经历" vagrant-aws" documentation,以下为我工作。
已安装" vagrant-aws"带shell的插件:
vagrant plugin install vagrant-aws
添加了AWS兼容'虚拟框'命名" aws"添加在config.vm.box = "aws"
中:
vagrant box add aws https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
按照Vagrant文件创建:
# Require the AWS provider plugin
require 'vagrant-aws'
Vagrant.configure(2) do |config|
config.vm.box = "aws"
config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
config.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY']
aws.secret_access_key = ENV['AWS_SECRET_KEY']
aws.region = "us-east-1"
#aws.availability_zone = "us-east-1c"
# EC2 Instance AMI
aws.ami = "ami-aa2ea6d0" # Ubuntu 16.04 in US-EAST
aws.keypair_name = "awswindows" #change as per your key
aws.instance_type = "t2.micro"
aws.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => 10 }]
aws.security_groups = ["YOUR_SG"]
aws.tags = {
'Name' => 'Vagrant EC2 Instance'
}
# Credentials to login to EC2 Instance
override.ssh.username = "ubuntu"
override.ssh.private_key_path = ENV['AWS_PRIVATE_KEY']
end
end
被解雇vagrant up --provider=aws
。
检查一次,如果您遇到任何问题,请告诉我。