AWS EC2 - Spin Lenses Instance


Question 

How to setup Lenses on an AWS EC2 instance?

Answer 

Launch Ec2 instance 

  • In the AWS platform navigate to the Launch Instance section
  • From the AWS console select an Amazon Linux AMI
  • Select an instance type, t2.large is recommended
  • Select Next on steps 3, 4 and 5
  • On step 6 Create a Security group with ssh access from your ip:

Security group

  • Click on Review and Launch and then Launch
  • At this point a Key pair window will popup

Key pair 

  • Select Create a new key pair (RSA) and give it a name
Create key Pair
  • Download your key pair
  • Rename from .cer to .pem
  • Open a terminal window at the key folder and make sure to execute chmod 400 <Your Key Name>.pem in order to be able to use the key.

Back to AWS UI 

  • Select the Key pair just created
  • Select Launch Instance

SSH to instance 

From the AWS EC2 interface grab the instance public DNS.

Then SSH to the instance by typing:

ssh -i <Path to your Key>/<Your Key Name>.pem ec2-user@<Your instance Public DNS>

CLI commands 

Once inside run the commands:

sudo yum update -y
sudo amazon-linux-extras install docker -y
sudo service docker start

and then:

sudo docker run -e LENSES_PORT=8080 -p 8080:8080 lensesio/lenses

Extra: Interact with Lenses from a browser 

At this stage Lenses is running inside an EC2 instance. In order to preview/interact with the Lenses environment from a browser, provide ALL TCP access to the security group attached to the instace for your IP.

On the security group appointed to the ec2 instance:

  • Click on edit inbound Rules
  • Add rule: All TCP Access or allow only port 8080 for increased security
  • Select your IP address and click on save rules

Security group updated

Then, access Lenses from the browser by navigating to: <Your instance publicIP>:8080

--
Last modified: June 18, 2024