# NITRC-CE AWS environment manager
#
# This Vagrantfile can be used to spin up and manage AWS EC2 instances.
#
# Quick Start
# -----------
# 1) Download Vagrant and install it in a directory in your env PATH (e.g. /usr/bin):
#      https://www.vagrantup.com/downloads.html
# 2) Install the vagrant AWS plugin: vagrant plugin install vagrant-aws
# 3) Edit the configuration parameters below specific to your AWS subscription.
# 4) Rename this config file to "Vagrantfile" and place it into your current working directory.
# 5) Start your EC2 instance: vagrant up
#
# Useful vagrant commands
# -----------------------
# To SSH into your EC2 instance: vagrant ssh
# To get the status of your EC2 instance: vagrant status
# To stop and delete your EC2 instance: vagrant destroy
# To discover the hostname of you EC2 instance: vagrant ssh-config
#
###############################################################################

# Configuration Settings

@AWS_AMI = 'YOUR_AMI_ID_HERE' # Available AMI IDs: https://www.nitrc.org/plugins/mwiki/index.php/nitrc_es:NITRC_CE_Release_Notes
@AWS_ACCESS_KEY_ID = 'YOUR_AWS_ACCESS_KEY_ID_HERE'
@AWS_SECRET_ACCESS_KEY = 'YOUR_AWS_SECRET_ACCESS_KEY_HERE'
@AWS_REGION = 'us-east-1'
@AWS_INSTANCE_TYPE = 't2.medium'
@AWS_SECURITY_GROUP = 'YOUR_SECURITY_GROUP_ID_HERE'
@AWS_SUBNET_ID = 'YOUR_VPC_SUBNET_ID_HERE'
@AWS_KEYPAIR_NAME = 'YOUR_AWS_KEYPAIR_NAME_HERE'
@AWS_PRIVATE_KEY_PATH = '~/.ssh/id_rsa'
@AWS_INSTANCE_TAG = 'YOUR_AWS_INSTANCE_TAG_HERE' # Appears as display name in EC2 dashboard
@AWS_DISK_SIZE = 100 # Disk size in GB. Must be >= 100GB


Vagrant.configure("2") do |config|

  # Disable default synced folder
  config.vm.synced_folder ".", "/vagrant", disabled: true

  require 'vagrant-aws'
  config.vm.box = "NITRC/aws"
  config.vm.box_version = "1.0.0"

  config.vm.provider "aws" do |aws, override|
    aws.access_key_id = @AWS_ACCESS_KEY_ID
    aws.secret_access_key = @AWS_SECRET_ACCESS_KEY
    aws.keypair_name = @AWS_KEYPAIR_NAME
    aws.instance_type = @AWS_INSTANCE_TYPE
    aws.region = @AWS_REGION
    aws.ami = @AWS_AMI
    aws.security_groups = [@AWS_SECURITY_GROUP]
    if @AWS_SUBNET_ID
      aws.subnet_id =  @AWS_SUBNET_ID
    end
    override.ssh.username = 'ubuntu'
    override.ssh.private_key_path = @AWS_PRIVATE_KEY_PATH
    aws.tags = {
	    'Name' => @AWS_INSTANCE_TAG
    }
    aws.block_device_mapping = [
      {
        'DeviceName' => '/dev/sda1',
        'Ebs.VolumeSize' => @AWS_DISK_SIZE
      }
    ]
  end

end
