# Installation Instructions

**Prerequisites: Have an RDS database set up to use application.**<br>

**Create Instance Profile**

* Getting to IAM
  * Go to[ https://aws.amazon.com](https://aws.amazon.com/)
  * In top right corner, click My Account then click AWS Management Console from the drop down
  * Under Services click IAM
* Creating a Policy
* Click Policies in the sidebar
* Click Create Policy
* Click the JSON tab and replace “Statement: \[]” with the text at the following locations:
  * Under the JSON Policy link in the tab on the left
* Click Review Policy
* Name the policy mycrt
* Click Create Policy
* Creating a Role
* Click on Roles in the sidebar
* Click Create role
* Under AWS service click EC2
* Click EC2 under use case
* Click Next
* Search for the mycrt policy created in the steps above
* Click Next
* Name the role mycrt
* Click Create role

**Create Security Group**

* Under Services click EC2
* Click Security Group in the sidebar
* Click Create Security Group
* Give the security group an appropriate name
* Under Inbound rules, create and add rules that allow you to connect via SSH (port 22) for CLI tool and HTTP (port 80, 8080) for web GUI.
* Create security group

**Create EC2 Instance**

* Under services click EC2
* Click Instances in the sidebar
* Click launch instance
* (We’d recommend selecting Free tier only checkbox)
  * Step 1
    * Select Amazon Linux AMI 2017.09.1 64-bit
  * Step 2
    * Select t2.micro instance type
  * Step 3
    * Assign IAM Role now or by following instructions below
  * Step 4 & 5
    * Leave defaults
  * Step 6
    * Attach your security group or create new one here.
* Review and Launch instance

**Attach Instance Profile to Existing EC2**

* Under Services click EC2
* Click Instances in the sidebar
* Right-click the instance the program will run on and under Instance Settings click Attach/Replace IAM Role
  * You can attach an IAM role when creating the EC2 instance in Step 3
* Attach the mycrt IAM role
* Apply changes

**Attach Security Group to Existing EC2**

* Under Services click EC2
* Click Instances in the sidebar
* Right-click the instance the program will run on and under Networking click Change Security Groups
  * You can attach a security group when creating the EC2 instance in Step 3
* Attach the security group created above
* Apply changes

**Downloading the Application**

* Download the application [here](https://teamtitansaws.github.io/)
* Connect to your EC2 instance
  * Transfer local file onto your EC2 instance
    * You can use the following command
      * `> scp -i [path to EC2 key pair] [path to JAR] [ec2-user@publicDNS]:~/data/`
    * Ex.`> scp -i ~/Desktop/amazon.pem /Downloads/MyCRT-0.1.0.jar ec2-user@ec2-54-166-128-20.compute-1.amazonaws.com:~/data/`
    * \~/Desktop/amazon.pem refers to your key pairs for your EC2 instance
    * <ec2-user@ec2-54-166-128-20.compute-1.amazonaws.com> refers to your EC2 instance

**Setting Up Environment Variables On EC2**

* SSH into your EC2
* Apply Updates
  * `> sudo yum update`
* Install Java JDK
  * `> sudo yum install java-1.8.0-openjdk-devel`
  * `> JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk"`
  * `> export PATH=$JAVA_HOME/bin:$PATH`

**Using the Application**

* Run JAR
  * java -jar /jarfilelocation
* Use MyCRT
  * Open Browser
  * http\://\*Use Your EC2 IPv4 Public IP\*:8080/
