Upload local Vagrant package.box to AWS

2019-07-30 06:47发布

问题:

So, I've been working locally in a vagrant ubuntu box for the past month: I've spent a lot of time working on customizing it and installing exactly all the software I want on it. I started all of this through the normal vagrant tutorial (aka, nothing special). I packaged my local vagrant box into a package.box file. Now, I want to move my development environment (e.g. package.box file) to an Amazon EC2 instance on AWS. I know I'm not supposed to ask for software recommendations, but my question is basically: is this possible to do and, if it is, could you point me to some examples of people doing it? I've read that packer might be an option, but it looks to me (a very inexperienced perspective) that maybe I should have started with that instead of trying to use it now. Any help would be appreciated - I don't want to spend a couple weeks setting up a new environment when I have one locally set up.

Edit:

Progress! I followed @error2007s link and followed the tutorial. I'm at the point where I've uploaded the VMDK image to s3 and provisioned an instance using it (all done automatically with the ec2-import-instance command on the CLI). However, I don't see a Public IP to access the new instance after I start it up.
I think this is related to cloud-init somehow, but I'm not sure what that is really. I tried it with both the /etc/cloud/cloud.cfg file that came with the box as well as the one listed here and neither of the two boxes I uploaded gave me a Public IP to access.

Edit 2:

Here are some things I see in the Console (They all seem right to me, but a more experienced eye might see something wrong):

subnet info:

Auto-assign Public IP: yes

Network ACL:

VPC info:

DNS resolution: yes

DNS hostnames: yes

ClassicLink DNS Support: no

VPC CIDR: 172.31.0.0/16

DHCP Option Set:

Options: domain-name = ec2.internal domain-name-servers = AmazonProvidedDNS

From my perspective, those all look right, or am I missing something?
I assigned an Elastic IP per these instructions, but when I ssh ec2-user@<elastic-ip>, it says ssh: connect to host <elastic-ip> port 22: Connection refused. The security group assigned to the instance is set to allow all protocols on all ports. Also, this is the first time I encounter a Elastic IP and I'm unsure what exactly it is doing.

回答1:

Amazon enables you to transfer your Vm to AWS as a EC2 instance. Check this tutorial this is more simple.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UsingVirtualMachinesinAmazonEC2.html



回答2:

You want to use the Vagrant AWS provider found here:

https://github.com/mitchellh/vagrant-aws

This is a Vagrant 1.2+ plugin that adds an AWS provider to Vagrant, allowing Vagrant to control and provision machines in EC2 and VPC.

This will allow you to provision your AWS instances using Vagrant, allowing you to migrate the same local development environment to an AWS EC2 instance.

There is a good tutorial here:

https://nurmrony.wordpress.com/2015/03/15/vagrant-deploy-and-provisioning-an-amazon-ec2-instance/