2

This is my AWS setup:

  • 1 VPC with:
    • default public subnet, 10.0.0.0/24
      • 1 EC2 micro instance, private 10.0.0.172 and public Elastic IP
    • 1 RDS instance, running MySQL

The EC2 instance has network connection to the outside world (verified with ping 8.8.8.8). This is it's routing table:

Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default ip-10-0-0-1.eu- 0.0.0.0 UG 0 0 0 eth0 10.0.0.0 * 255.255.255.0 U 0 0 0 eth0 instance-data.e * 255.255.255.255 UH 0 0 0 eth0 

The EC2 instance can also connect to the RDS instance.

What I want, is to launch a second EC2 instance (Amazon Linux AMI 2014.03.1 64bit) from inside the first EC2 instance, using Vagrant. The second EC2 instance should be in the same VPC subnet but it's actual IP address doesn't matter much. It also doesn't need a public Elastic IP. It does need to connect to the outside world, to install software using yum.

This is my Vagrantfile:

VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "dummy" config.vm.provider :aws do |aws, override| aws.access_key_id = "ACCESS_KEY_ID" aws.secret_access_key = "SECRET_ACCESS_KEY" aws.keypair_name = "KEYPAIR_NAME" aws.ami = "ami-2918e35e" aws.instance_type = "m1.small" aws.region = "eu-west-1" aws.subnet_id = "subnet-SUBNETID" aws.security_groups = "sg-SECURITYGROUPID" override.ssh.username = "ec2-user" override.ssh.private_key_path = "PRIVATE_KEY.pem" end config.ssh.pty = true config.vm.provision "shell", path: "provision.sh" end 

In the shell script provision.sh I install some software:

yum install -y subversion 

This fails, because yum can't connect to the outside network.

When I do vagrant ssh and check the IP address, it's in the 10.0.0.0/24 range and I can ping in either direction between the two EC2 instances (ICMP was allowed in the security group). I can't ping 8.8.8.8 and I can't yum install software because the instance can't reach the repositories. I checked the route and it's identical to that of the first instance.

Also, in the AWS web console, the second instance doesn't have a public IP address.

When I add this line to my Vagrantfile:

aws.associate_public_ip = true 

then I get the following error on vagrant up --provider=aws --provision:

There are errors in the configuration of this machine. Please fix the following errors and try again: AWS Provider: * The following settings shouldn't exist: associate_public_ip 

and the instance does not launch.

So my question is: how can I give the vagrant instance a network connection, without using an Elastic IP?

1
  • 1
    I think I have found the anser to my question here: github.com/mitchellh/vagrant-aws/issues/242 In short: the associate_public_ip feature isn't in the public release of the vagrant-aws plugin yet. Commented Jun 4, 2014 at 9:49

1 Answer 1

1

in my installation that parameter was not exist but there is

aws.elastic_ip = true 

that has the same purpose.

To find the real fields used in your plugins chech this file

~/.vagrant.d/gems/gems/vagrant-aws-0.4.1/lib/vagrant-aws/config.rb 

of course I have the vagrant-aws-0.4.1 change with yours

1
  • @davidski on Github explains aws.elastic_ip vs associate_public_ip: They're very similar, but not quite identical. Elastic IPs are primarily static assignments which you "own" and can assign to instances as those hosts come and go, providing a static IP reference you can use again and again. Public IPs are only valid for the life of an instance. If you bring up a new instance, you'll get a random public IP address. There is a default limit of 10 Elastic IPs per account and you pay for any Elastic IPs you have checked out (allocated) but which are not in use by an active instance. Commented Jun 6, 2014 at 7:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.