Deploying Tyk on AWS
Pre-requisite: Tyk Self-managed
As part of our diverse deployment options, a Tyk Self-managed license will allow you to deploy on the platform and infrastructure of your choice.
Deploying on AWS requires Tyk Self-managed: the cloud-native API management platform for when you want total control, flexibility, and scalability across REST and GraphQL. Tyk evolves with your infrastructure, giving you complete data sovereignty and security with no lock-in.
If you haven’t gotten started with Tyk Self-managed, you can register for a free trial here.
You can install the entire Tyk API Management platform – Tyk API Dashboard, Designer, Analytics, and Developer Portal – into AWS, into Google Cloud, into your own servers, even on your own laptop. Below we’ll walk you through the steps to get started on AWS.
Performance metrics based on infrastructure size (avg)
|Hardware specs||Max Throughput (RPS)||P99 Latency *||EC2 Cost *|
|Amazon EC2 (t2.micro)||2,954 req / sec||32.9 ms||$ 0.0116 / hour|
|Amazon EC2 (t2.medium)||4,903 req / sec||22.2 ms||$ 0.0464 / hour|
|Amazon EC2 (m4.large)||4,190 req / sec||25.2 ms||$ 0.10 / hour|
|Amazon EC2 (c5.2xlarge)||23,667 req / sec||4.93 ms||$ 0.34 / hour|
|Amazon EC2 (c5.9xlarge)||69,133 req / sec||1.2 ms||$ 1.53 / hour|
* more details about these metrics can be found in our documentation
Getting started with Tyk on AWS
AWS is one of the most popular cloud platforms and getting started with Tyk on it has never been easier!
For this demonstration we will set up an EC2 instance, deploy Tyk using the tyk-pro-docker image via docker, bootstrap the dashboard, and create our first endpoint. By the end of this tutorial you’ll have a working version of Tyk that you can use to explore all of Tyk’s features!
To follow along you will need:
- An active AWS account
- A terminal to run commands in
Step 1: Create and launch your EC2 instance
Log into the AWS Management console and select ‘Launch a virtual machine’
Click “Select” on the Amazon Linux 2 AMI image (or whatever machine you’d prefer)
For instance type, select ‘t2.micro’ (or whatever type you’d prefer)
For instance details we will take the defaults, and then click ‘6. Configure Security Group’ along the top bar on the screen.
Once at the Configure Security Group screen, we will name the security group “poc-open-group” and set the Type to “All traffic”, then set “Review and Launch”.
Check to make sure all your details are correct, and click “Launch”.
To log into the EC2 instance you’ll need a key pair. If you have an existing one you can use it but for our purposes we will generate a new one by selecting “Create a new key pair” and downloading the private key file. Don’t lose this file since you’ll need it to log into the VM! After the key is saved, click “Launch Instances”.
Now you’ll see that AWS is launching your instance! Now click “View Instances” so we can head to the dashboard.
You should now see your instance starting up and running. Once the instance status is listed as “running” we can begin to move onto installing Tyk onto it.
Step 2: Installing Tyk on our new AWS instance!
Now that we have an instance up and running, let’s log into it. Bring up your favourite terminal and run the following command:
ssh -i yourkey.pem ec2-user@public-ec2-ip
yourkey.pem = path to your saved AWS key
public-ec2-ip = the public IP of your new EC2 instance (which can be found on instance dashboard screen)
Once you run the above command you’ll see this screen asking you if you want to connect to the instance. Type “yes” and press enter to log into the instance.
NOTE: If you get the following error when trying to log into the instance then you’ll need to set permissions on the private key file.
To do that, you’ll want to run sudo chmod 600 path/to/file.pem
At this point you have successfully logged into the system. You should see the following screen now displaying in your terminal:
We are now at the point where we will start to install the required components on the instance.
First, we update yum using:
sudo yum update -y
Next, we install git using:
sudo yum install git -y
Then we install docker, start, and configured the service using:
sudo yum install -y docker
sudo service docker start
sudo usermod -aG docker ec2-user
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
After all of the above is set up, clone the Tyk Pro Docker repo from github using:
Then change to the newly created directory:
We then need to open up the Tyk Analytics configuration file so that we can add in our license key. I use nano to open it up using the following command:
Once the file is opened, scroll to the “license_key” field. Currently it will be blank.
Fill in your licence key and then use the control + X command to exit. Once you do this youll be prompted to save. Save the file by typing “Y” and pressing ENTER.
Nano will then ask you for the file name to write to which will already be populated with
confs/tyk_analytics.conf. Press ENTER to save and exit.
At this point we want to bring up the stack. We do that using the docker-compose command like so:
docker-compose up -d
Once you press ENTER to run the command, the process will start to bring up the stack!
Once the process has brought up the stack you should see the following outlining that all components are up and running:
Now that we are up and running, let’s navigate to the dashboard to get started with Tyk! For this you’ll want to navigate to:
http://<your aws instance public IP>:3000
Step 3: Configuring and using your new Tyk instance!
Once we have navigated to the URL in the previous step we should see the Dashboard Setup screen. Here you’ll want to fill out your details and click “BOOTSTRAP”.
After the bootstrap has completed, you then are taken into your new Tyk installation. From here navigate to the API Designer screen by clicking the APIs menu item on the left of the screen.
Once in the API Designer screen, under API Name enter “Test API”
Scrolling down on the screen, we will put our Target URL as “http://httpbin.org”
And lastly, at the bottom of the page under Authentication mode, select “Open (Keyless)” as your authentication type. Then click SAVE to create the endpoint.
Now you should see your first endpoint created under the Created APIs list on the next screen.
Step 4: Test the endpoint!
Lastly, using Postman (or another one of your favourite tools) we will send a GET request to our endpoint. The URL we will hit will be: http://<your aws instance public IP>:8080/test-api
Your results should look like this:
And there you have it, a new instance of Tyk up and running on AWS. Now you can easily start to discover some of the great features that Tyk has to offer!