Home Vagrant : An AMI must be configured via "ami" (region: #{region})
Reply: 2

Vagrant : An AMI must be configured via "ami" (region: #{region})

lakshmikandan
1#
lakshmikandan Published in 2017-12-07 12:50:17Z

I got an error as below when run vagrant command,

 # vagrant up --provider=aws

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

AWS Provider: * An AMI must be configured via "ami" (region: #{region})

I'm using Vagrant 2.0.1 with vagrant-aws 0.7.2

Vagrant file:

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

How to solve it?

Frédéric Henri
2#
Frédéric Henri Reply to 2017-12-07 13:14:28Z

us-west-2a is not a valid region name, see https://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region for the full list of available region and end-points.

If you AMI is location in US West (Oregon), then you need to replace with us-west-2 in your Vagrantfile

J. Parashar
3#
J. Parashar Reply to 2017-12-08 11:19:34Z

Going through "vagrant-aws" documentation, following worked for me.

Installed "vagrant-aws" plugin with shell:

vagrant plugin install vagrant-aws

Added AWS compatible 'dummy-box' named "aws" added in config.vm.box = "aws":

vagrant box add aws https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box

Created following Vagrant file:

# 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

Fired vagrant up --provider=aws.

Check once and let me know if you face any issue.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.369757 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO