Click on Launch instances
as shown below.
Under choose AMI, first check the Free tier only
box on the left side of the window and then select any image. I selected Ubuntu Server 20.04 LTS
image. You can experiment with any of the images.
Make sure you select the t3.micro (it is the free tier
instance type) and then click on Review and Launch
then Launch
. This will display a window asking you to select or create a key pair. Select the applicable option and then click on Launch Instance
Give your virtual server a name. Mine is named server-01
. Wait for your server to change Instance state
to Running
before you connect to it.
Now, you can connect to your virtual server using PuTTy, Powershell, Bash (if you are using Linux), CMD or any client application that supports SSH
. I am using PuTTy. To connect to the compute
or virtual server, ssh to the Public IPv4 DNS
address specified under the Details
tab.
The user name is ubuntu
. The virtual server has access to the internet and you can install any package you need. Now, let’s install the Rust compiler.
Install Rust and buid-essential
(sudo apt install build-essential).
We will be deploying two types of application on the virtual server - a telecoms application (a GTPv2-C server) and a web application based on the warp crate. GTPv2C protocol is used in the 3GPP based 3G, 4G and 5G networks for signaling and it uses port 2123 and the UDP transport protocol. We will configure our Rust GTP server to listen on UDP port 2123 in compilance with the 3GPP TS 29.274 (GTPv2-C) standard.
The web server will listen on TCP port 3030.
Configure the Inbound rules
as shown below. AWS EC2 will apply these rules to our virtual server and it will allow our Rust applications to send and receive messages using these rules.
Create your web server application using cargo new web_server
and edit with nano as shown below. The original code is available here:https://github.com/seanmonstar/warp and it has been slightly modified for this tutorial. Run the web server with cargo run
.
After this step, you will have two Rust applications running in the cloud. You can use the ps aux | grep target
to check the two processes running (gtp
and web_server
)
Open another PuTTy session and connect to the virtual server. Clone the GTPv2-C server from https://github.com/eshikafe/ngc and edit the ngc/common/gtp/src/main.rs
so that the server listens and accepts conections from any IP address (i.e 0.0.0.0
) as shown below. Run the application with cargo run
In the screen shot below, a simple Python
script (the client) sends a message to the gtp server application using the Public IP address
and port 2123. The script sends a GTPv2-C Create Session Request
message from my Windows PC, through the internet, to the Rust GTPv2-C server application running in the cloud. This implies that you can deploy a telecom application (based on Rust) in the cloud to serve multiple devices concurrently and efficiently. The sample gtp application uses the tokio crate to achieve concurrency. Concurrency is a key requirement for a 4G/5G telecom server application.
Lastly, open a web browser and paste the following URL in the address bar:{Public IPv4 DNS}:3030/hello/Rustacean
. Replace Public IPv4 DNS
with the domain assigned to your compute. You should see the message below.
You can also use curl to test your web server as shown below.
To deploy your applications securely in the cloud, you need to understand how the AWS EC2 security group works. Please read the AWS EC2 security group documentation before you deploy your application as a production system in the cloud.