umbe1987
umbe1987

Reputation: 3568

Using vagrant with Amazon EC2

I am new to Amazon AWS and Vagrant.

I opened a 12-moths free account and I'd like to test EC2 for my personal project. I'd need to test QGIS Server software.

Instead of creating a new instance and installing all the dependencies from scratch, I thought to use this repo, which ships a Vagrant image of QGIS Server and all the needed software to test it out.

I probably would be able to do this on my personal laptop but I am unsure on how to proceed with a EC2 instance.

Looking at this SO answer it seems I can use vagrant-aws plugin to do it.

However, it teh README also reads:

Of course prior to doing this, you'll need to obtain an AWS-compatible box file for Vagrant.

What does that supposed to mean?

Could anyone with some experience help me understanding what do I need besides the Vagrant file and the Amazon AWS account to accomplish this task?

Do I need to create an instance first or should I do it using the vagrant-aws plugin?

Many thanks in advance.

EDIT1

I think I made huge improvements.

So I read through tons of docs, and I finally ended up with a Vagrantfile that is a mix between the one from mitchellh/vagrant-aws and the one from elpaso/qgis3-server-vagrant.

Then I am supposed to run vagrant up --provider=aws but I get some syntax errors. I think my lack of knowledge in Ruby is my main obstacle here.

Here is my MODIFIED Vagrantfile (without the SECRET AWS stuff):

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Require the AWS provider plugin
require ‘vagrant-aws’

# Creating and configuring the AWS instance
Vagrant.configure(‘2’) do |config|


  # Use dummy AWS box
  config.vm.box = ‘aws’

  # Disk space (free tier ebs is limited to 30!!!)
  config.disksize.size = '20GB'

  # (taken from https://github.com/elpaso/qgis3-server-vagrant)
  config.vm.network "forwarded_port", guest: 80, host: 8080 # nginx fastcgi
  config.vm.network "forwarded_port", guest: 81, host: 8081 # apache fastcgi
  config.vm.network "forwarded_port", guest: 82, host: 8082 # nginx uwsgi
  config.vm.network "forwarded_port", guest: 83, host: 8083 # nginx mapproxy

  # Specify configuration of AWS provider
  config.vm.provider ‘aws’ do |aws, override|
    # Read AWS authentication information from environment variables
    aws.access_key_id = ‘MY_ACCESS_ID’
    aws.secret_access_key = ‘MY_SECRET_ID’
    # Specify SSH keypair to use
    aws.keypair_name = ‘MY_KEY’
    # Specify region, AMI ID, Instance and security group
    aws.region = ‘eu-west-3’
    aws.ami = ‘ami-38a01045’
    aws.instance_type = ‘t2.micro’
    # Specify username and private key path
    override.ssh.username = ‘umberto’
    override.ssh.private_key_path = ‘path/to/my/key/pair’
  end

    # Install the required software
  config.vm.provision "shell",
    path: "provisioning/setup.sh",
    args: ENV['SHELL_ARGS']

  # Run every time the VM starts
  config.vm.provision "shell",
    path: "provisioning/job.sh",
    args: ENV['SHELL_ARGS'],
    run: "always"

end

The errors I am getting are:

There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience:

/home/umberto/Documents/amazon_aws/qgis3-server-vagrant-AWS/Vagrantfile:35: syntax error, unexpected tIDENTIFIER, expecting keyword_end
  aws.region = ‘eu-west-3’
                              ^
/home/umberto/Documents/amazon_aws/qgis3-server-vagrant-AWS/Vagrantfile:36: syntax error, unexpected tIDENTIFIER, expecting keyword_end
  aws.ami = ‘ami-38a01045’
                              ^
/home/umberto/Documents/amazon_aws/qgis3-server-vagrant-AWS/Vagrantfile:42: syntax error, unexpected keyword_end, expecting end-of-input
  end
     ^

Can anybody with a bit of Ruby knowledge help me please? I think I am stuck in what seems the very last step...

Upvotes: 1

Views: 766

Answers (1)

davejagoda
davejagoda

Reputation: 2528

You have some 'smart quotes' instead of single quotes. Change all of these:

To be like this:

'

Regular double quotes should also work, just no smart quotes.

Upvotes: 2

Related Questions