37

Are there any 'boxes' available to download for Vagrant that closely mirror the Linux version and packages available for Amazon EC2 instances?

I am testing locally using Vagrant, currently using the Precise32 box. I am deploying my code to Amazon EC2 instances with the 'Amazon Linux AMI 2013.03' AMI.

The problem I am facing is that the packages available to install on the Precise32 box have different names e.g.

  • php5-fpm - in the vagrant box
  • php54-fpm - in the Amazon EC2 instance.

Although I could fix this by using variables in the Puppet config files to handle the different package names, that sounds a bit like a hack.

So are there any vagrant boxes available that will mirror the Amazon EC2 environment closely.

Or is it possible for me to tell a vagrant box to use the same packages source as an Amazon EC2 instance?

To clarify one thing - the reason I want to do this is so that I can test locally without having to commit everything first. Although Vagrant has support for AWS as a provider, that wouldn't actually achieve being able to test locally.

7
  • Hoping this gets a useful answer, I'd love to have an Amazon Linux local install for this sort of use case.
    – ceejayoz
    May 8, 2013 at 15:32
  • 1
    Don't use Amazon Linux? May 8, 2013 at 16:15
  • 2
    @MichaelHampton It's often nice to have an Amazon built and supported Linux variant. Having stuff like the AWS tools function out-of-the-box can be invaluable.
    – ceejayoz
    May 8, 2013 at 16:55
  • @ceejayoz Yes, that's useful, but not so much when the rest of the system doesn't work. I haven't been impressed with the build quality of Amazon Linux; there always seems to be something important that's broken. May 8, 2013 at 16:56
  • YMMV, I guess. I've yet to encounter such breakage on our nginx/php-fpm/percona cluster.
    – ceejayoz
    May 8, 2013 at 16:57

6 Answers 6

11

No, there is no way to use Amazon Linux outside of EC2. If you want to use a Red Hat Enterprise Linux derivative (which Amazon Linux is), I recommend using CentOS 6 both in Vagrant and on EC2. You will find many CentOS base boxes here, and the official AMIs are listed here.

3
  • 1
    That does appear to be more similar than most, but still slightly different e.g. Amazon linux has separate PHP 5.3 and PHP 5.4 available in it's packages. I think my idea of having an Vagrant environment that would be close enough to match Amazon's environment so as to be identical for installation scripts is not feasible without a lot of work at creating custom box.
    – Danack
    May 14, 2013 at 19:49
  • Right, Amazon Linux adds additional and newer software beyond what RHEL and CentOS include. Thats why I would not recommend using Amazon Linux.
    – sciurus
    May 15, 2013 at 21:07
  • 2
    For those (like me) who find this 5+ Years later, now, in 2018, this answer is no longer true: > "there is no way to use Amazon Linux outside of EC2" Amazon now provides virtual machine images (for VirtualBox, ansible, VMWare, Windowz-hyper-z-whatever and Docker) of Amazon Linux, which is basically just a vanilla recent CentOS distro that is optimized and preconfigured for EC2 with Amazon's API tools and cloudinit packages preinstalled, and they totally support and encourage you to run it on-premises as well as in AWS: Amazon Linux 2 aws.amazon.com/amazon-linux-2/#Resources
    – gigawatt
    Jul 23, 2018 at 16:05
19

NOTE: This answer is not about finding a vagrant box for "Amazon Linux". This answer is about helping the original poster solve the goal of using the same system in production as in dev, which happens to be Ubuntu. As you can see in the comments below, OP agreed this would solve his problem.


Canonical provides official Ubuntu AMIs on EC2 and corresponding official Vagrant boxes for download.

For Ubuntu 12.04 Precise, the AMIs are listed at

http://cloud-images.ubuntu.com/precise/current/

and the Vagrant boxes are listed at

http://cloud-images.ubuntu.com/vagrant/precise/current/

You can use this to start with the same base config on EC2 as you are using locally in dev.

3
  • 1
    Those won't act anything like the RHEL-based Amazon Linux AMI.
    – ceejayoz
    May 8, 2013 at 21:20
  • 2
    Thanks that would solve the problem for myself, as I don't particularly care which flavour of Linux I use. However it would still be good to see if anyone has solved it by making an Amazon flavoured Vagrant box.
    – Danack
    May 8, 2013 at 21:31
  • 1
    @ceejayoz: I'm proposing solving the OP's core problem of having the same image on dev+prod by switching prod instead of switching dev. Not all answers need to limit themselves to the assumptions we read into the question. What we're trying to do is help the questioner solve their real world issues with practical solutions. "No you can't do it" is a valid answer, but I appreciate "You can accomplish your underlying goal by..." May 9, 2013 at 23:33
7

On 13-Dec-2017, Amazon released Amazon Linux 2. With this Amazon now provides downloadable images that will run in VirtualBox, VMWare, MS Hyper-V.

Prior to this, you did have the option to use the Amazon ECS Docker image. That continues to be available for both v1 and v2.

Have a look at Running Amazon Linux 2 as a Virtual Machine On-Premises.

I suspect someone will publish a vagrant box soon. In the interrim, it is fairly easy to build a base box yourself.

4

Also worth taking a look at http://www.packer.io it can be used to give you exactly the same ami image for your external vagrant

6
  • 1
    Welcome to Server Fault! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – slm
    Aug 21, 2013 at 21:53
  • 1
    noted, did not want to litter the answer with the full install and usage page contents? but if thats the preference, i'll do that next time Aug 21, 2013 at 22:02
  • It's OK to paraphrase, it doesn't have to be the full details, but just the gist.
    – slm
    Aug 21, 2013 at 22:05
  • 1
    Packer will not give you "exactly the same ami image for your external vagrant". As I understand it Packer can take an ami base image and run your custom provisioning script over that to create an output ami. It can also use a vagrant box (ovf) or .iso image as a base for running the same provisioning script to make an output vagrant box. While the provisioning script will be the same, the base boxes will differ to some extent. You cannot create a vagrant box directly from an AMI.
    – poshest
    Feb 10, 2016 at 14:02
  • @poshest So we still need the same development and production environment (like Ubuntu) to make the Vagrant box behave (almost) the same as an AMI? Jun 20, 2017 at 13:36
2

Amazon Linux is based on Redhat/CentOS, so the names will match more closely if you run one of those locally.

Debian/Ubuntu based Linux OSes change up the package names, e.g. "dev" instead of "devel" as a suffix for development packages.

Btw, you might want to check out the output of "rpm -qa" on an Amazon Linux instance, munge it to match CentOS/Redhat package names, and then think creating your own OS version that closely matches Amazon's.

1

As of 2017, yes.

The name of the Vagrant box is mvbcoding/awslinux hosted in Vagrant cloud (as all other public Vagrant boxes).

You can launch a box with the following command.

vagrant init mvbcoding/awslinux; vagrant up --provider virtualbox
4
  • welcome, can you please give a more detailed answer?
    – bgtvfr
    Jun 27, 2017 at 8:15
  • @bgtvfr he means that we now do have a “Vagrant box similar to Amazon EC2 instances”, that is, the mvbcoding/awslinux. That is the only box named awslinux by far. Jul 2, 2017 at 15:22
  • Is it safe to use public boxes hosted on Vagrant cloud? Does the Vagrant cloud do any audit before accepting public boxes?
    – Varun
    Aug 10, 2017 at 9:25
  • Who knows? You need to ask Mitch Hashimoto.
    – egorpe
    Aug 11, 2017 at 10:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .