Last Updated: February 25, 2016
·
1.894K
· kevinsimper

Vagrant and AWS - An active machine was found with a different provider

If you are trying to use another provider with your current vagrant machine, you will likely get this error:

An active machine was found with a different provider. Vagrant
currently allows each machine to be brought up with only a single
provider at a time. A future version will remove this limitation.
Until then, please destroy the existing machine to up with a new
provider.

The tricks is to create another machine, but to set it to not start up with your default machine.

config.vm.define "aws", autostart: false do |aws_vm|
end

Now, this machine will not get started when you do vagrant up, but will get started when you do vagrant up aws.

Next you can add the dummy image so it do not tries to start your machine on aws.

aws_vm.vm.box = "dummy"

Then inside that block you can add your aws provider details, then it would look something like this:

config.vm.define "aws", autostart: false do |aws_vm|
  aws_vm.vm.box = "dummy"
  aws_vm.vm.provider :aws do |aws, override|
    aws.access_key_id = "XXXX"
    aws.secret_access_key = "XXXX"
    aws.keypair_name = "XX"
    aws.instance_type = "m3.medium"
    aws.security_groups = ["Vagrant"]

    aws.region = "eu-west-1"

    aws.ami = "ami-f0b11187" // Ubuntu

    override.ssh.username = "ubuntu"
    override.ssh.private_key_path = "~/XX/XX.pem"
  end
end

Now you can both have your VirtuelBox running and spin another box identical up on Amazon EC2.

You run the command like this:
vagrant up aws --provider=aws

If you are spinning up a machine for the first time on EC2, remember to create a Security Group that allow ssh both in and out, and add port 80 for web traffic as well.