AWS: Create an EC2 Instance
Use this guide to learn how to create and configure an AWS EC2 instance for the FaceTec Server.
Important Note: AWS EC2 is not required for deploying the FaceTec Server remotely. There are numerous other cloud environments and remote server options that can also be used. We recommend that you utilize what is best for your specific use case.
Video Walkthrough
Create a Security Group [0:00 - 0:44].
Create an EC2 Instance [0:44 - 1:48].
Configure Inbound Traffic for a Remote Connection (via SSH) [1:48 - 2:28].
Use ssh to access the AWS EC2 Instance [2:28 - 2:35].
Copy and Build the FaceTec Server onto the EC2 Instance [2:35 - 3:18].
For the full guide see Step 2 in Setting up the FaceTec Server.
From localhost, test the /status and /session-token APIs (via Curl) [3:18 - 3:45].
Configure Inbound Traffic for API Calls (Port 8080) [3:45 - 4:37].
From Your Development Device, test the /status and /session-token APIs (via Curl) [4:37 - 5:06].
Create a Security Group
- In the AWS Search Bar, search for "security groups" and choose Security Groups (EC2 feature).
- In the top-right corner of the AWS Console, click Create Security Group.
- Provide a Name and Description for Your Security Group in Security group name and Description, respectively. Afterwards, choose a VPC (Virtual Private Cloud).
- A preconfigured VPC is a prerequisite for this step. To learn how to create a VPC, please see Amazon Web Service's Create a VPC Guide.
- Finish creating the Security Group by going to the bottom of the page and clicking Create Security Group.
Create an EC2 Instance
- In the AWS Search Bar, search for "ec2" and choose EC2 (Virtual Servers in the Cloud).
- In the EC2 Dashboard, go to Instances (running) and click Launch Instances.
- In Name and Tags, choose a name for Your EC2 Instance.
- In Application and OS Images (Amazon Machine Image), go to Quick Start, choose a modern Linux distribution, such as Amazon Linux, and set the architecture to 64-bit (x86).
- In Instance type, choose the type of EC2 Instance to create. To determine which EC2 instance to use, see Server Hardware Requirements.
- In Key Pair Login, choose a key pair for remotely connecting (via SSH) to Your EC2 instance. If you have not yet created a key pair, you can generate one by clicking on the Create new key pair link.
In Network Settings, click Edit and set Auto-assign public IP to "Enable". Then, click Select Existing Security Group and choose the Security Group you created in Create a Security Group.
- In Configure Storage, choose the amount of disk space Your EC2 Instance will use. To determine the minimum amount of disk space Your EC2 Instance will need, see Server Hardware Requirements.
- Beneath the Summary Section, click Launch Instance to finish configuring and launching Your EC2 Instance.
Configure Inbound Traffic for a Remote Connection (via SSH)
- From the Console Home Page, click EC2. Then, go to Instances (running) and click Launch Instances.
- Click on Your EC2 Instance and then go to the Security Tab in the bottom panel.
- Underneath Security Groups, click Your EC Instance's Security Group.
- In the Security Group, choose Edit Inbound Rules and click Add rule.
- Underneath Type, choose "SSH". In the selection for IP Addresses, specify the IP Address of the machine you will use for SSH.
- Click Save rules to finish the configuration for SSH.
Test the /status and /session-token APIs (via Curl)
Run the following command to test the FaceTec Server's /status API:
curl <SERVER_IP_ADDRESS>:8080/statusRun the following command to test the FaceTec Server's /session-token API:
curl <SERVER_IP_ADDRESS>:8080/session-tokenConfigure Inbound Traffic for API Calls (Port 8080)
- Click on Your EC2 Instance and then go to the Security Tab in the bottom panel.
- Underneath Security Groups, click Your EC Instance's Security Group.
- In the Security Group, choose Edit Inbound Rules and click Add rule.
- Choose "Custom TCP" for Type and "8080" for Port range, and specify the IP Address where the API Calls will come from.
- Click Save rules to allow API Calls on Port 8080 from the Specified IP Address.
Configure Outbound Traffic
Important Note: In AWS, the default setting for Security Groups is to allow All Outbound Traffic. This is not ideal and not secure. In Your Production Environment, you will want to update Your Outbound Traffic Settings to only allow traffic on the necessary ports.
- Click on Your EC2 Instance and then go to the Security Tab in the bottom panel.
- Underneath Security Groups, click Your EC Instance's Security Group.
- In the Security Group, choose Edit Outbound Rules.
- Delete the default Outbound rule (if not already deleted).
- Click Add rule.
- Choose HTTPS for Type with Destination of "Anywhere-IPv4".
- Click Save rules to only allow Outbound Traffic on HTTPS (an Outbound HTTPS or SFTP Connection to FaceTec is necessary for the Usage Logs).
- (Optional) If connecting to an external MongoDB Database, you will need to specify a second Outbound rule. For this second Outbound rule, click Add rule. Then, choose "Custom TCP" for Type, 27017 for Port Range, and specify the IP Address where the MongoDB Database is hosted.
Create a Target Group
- For Protocol: Port, choose HTTP and 8080.
- For Health checks, set Health Check Path to /status.
- The FaceTec Server already has a /status API, so Your Load Balancer should use that to ensure the FaceTec Server is running.
- After clicking Next, click on the Target Instance, select Include as pending below, and press Create target group.
Create a Load Balancer with a SSL/TLS Certificate
Choose the Load Balancer's Security Group.
Create an HTTPS Listener for the Load Balancer's Target Group.
In Default SSL/TLS server certificate, choose From ACM and choose Your SSL/TLS Server Certificate.
A SSL/TLS Server Certificate from AWS Certificate Manager (ACM) is required for this step. For more information see AWS Certificate Manager Features.
Create a HTTPS Alias (Route 53)
- In Route 53, go to Hosted Zones and choose the Hosted Zone for the FaceTec Server.
- Click Create Record.
- Toggle Alias and choose Alias to Application and Classic Load Balancer. Then select the region and the Load Balancer.
- Finish by clicking Create Records.