mitchellh / vagrant-aws

Use Vagrant to manage your EC2 and VPC instances.
MIT License
2.61k stars 574 forks source link

Issue with Amazon Linux AMI (HVM) (as opposed to PV, which is fine) #269

Open stevenringo opened 10 years ago

stevenringo commented 10 years ago

Hi,

Have followed the instructions in the readme about using a user_data config script to get it working on AWS with Amazon Linux.

This works fine on the PV version. However the HVM one seems to automatically stop the instance as soon as its created and as a result one cannot log in and it hangs on the "waiting for ssh connection". The fact the machine was created and then terminated can be seen in the AWS console.

HVM is needed as this is the only virtualisation type supported on the new t2.micro instances.

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "dummy"
  config.vm.synced_folder ".", "/vagrant", disabled: true
  config.vm.provider :aws do |aws, override|
    aws.access_key_id              = "redacted"
    aws.secret_access_key          = "redacted"
    aws.ami                        = "ami-d9fe9be3" # Amazon Linux AMI 2014.03.2 (HVM)
    aws.region                     = "ap-southeast-2"
    aws.subnet_id                  = "redacted"
    aws.keypair_name               = "redacted"
    aws.instance_type              = "t2.micro"
    aws.security_groups            = "redacted"
    aws.associate_public_ip        = true
    aws.iam_instance_profile_name  = "ec2-general-role"
    aws.block_device_mapping       = [
                                       {
                                         "DeviceName"              => "/dev/sda1",
                                         "VirtualName"             => "root",
                                         "Ebs.VolumeSize"          => 100,
                                         "Ebs.DeleteOnTermination" => true
                                       }
                                     ]
    aws.tags                       = { "Name" => "Testing" }
    aws.user_data                  = "#!/bin/bash\necho 'Defaults:ec2-user !requiretty' > /etc/sudoers.d/999-vagrant-cloud-init-requiretty && chmod 440 /etc/sudoers.d/999-vagrant-cloud-init-requiretty\n"
    override.ssh.private_key_path  = "~/.ssh/identity.ec2"
    override.ssh.username          = "ec2-user"
  end
end

I have tried following the instructions in the debug log, recommending a vagrant reload, but it was no help alas.

INFO ssh: SSH not up: #<Vagrant::Errors::SSHConnectionRefused: SSH connection was refused! This usually happens if the VM failed to...

If anyone can shed any light on this, that would be awesome.

Thanks,

Steve

ggdb commented 9 years ago

+1 Not sure how to create a t2.micro with vagrant-aws

fabio-naddafi commented 9 years ago

+1 having an issue with Ebs.VolumeSize not being set on hvm based instances, and resize2fs not working for root volume.