Sanchit Dilip Jain/Amazon Lightsail - Overview 🔍

Created Sat, 11 May 2024 12:00:00 +0000 Modified Sat, 18 May 2024 08:49:57 +0000
759 Words 3 min

Amazon Lightsail - Overview

Introduction

  1. What is Amazon Lightsail?

    • Amazon Lightsail is the easiest way to get started with Amazon Web Services (AWS) for anyone who needs to build websites or web applications.
    • It includes everything you need to launch your project quickly—instances (virtual private servers), container services, managed databases, content delivery network (CDN) distributions, load balancers, SSD-based block storage, static IP addresses, DNS management of registered domains, and resource snapshots (backups) - for a low, predictable monthly price.
    • Lightsail also offers a unique feature, Amazon Lightsail for Research. This platform opens up a world of possibilities for academics and researchers. With Lightsail for Research, you can create powerful virtual computers in the AWS Cloud, each one with pre-installed research applications, such as RStudio and Scilab. This is an exciting opportunity to accelerate your research and take it to new heights.
  2. Why should you use Amazon Lightsail?

    • Build applications and websites fast with pre-configured cloud resources
      • Lightsail gets you started quickly with preconfigured Linux and Windows application stacks and an intuitive management console.
      • Focus on your code, not your bill. Lightsail bundles all the resources you need into a single, simple price.
      • Lightsail automatically configures networking, access, and security environments, removing the guesswork from launching your server.

Demo

  • In this demo, we will be deploying an RStudio Lightsail for Research virtual computer, downloading National Oceanic and Atmospheric Administration (NOAA) temperature data, running analysis for the maximum median temperature by year from 1929 to 1979

    1. Login to Lightsail and Deploy the Virtual Computer

    • In your browser, navigate to the AWS Management Console by clicking on the ‘Open AWS console’ link in the left pane.

    • In the search bar, type “Lightsail.”

    • Click on “Lightsail for Research” under ‘Top features’

    • Once the page loads, select the region where you will deploy your Lightsail for Research (LfR) virtual computer.

    • Scroll down to the Application section and choose RStudio.

    • Name your virtual computer ‘rStudio_Demo’ and select the ‘Standard XL’ plan. Click ‘Create virtual computer’.

    • Wait for your virtual computer to be in the ‘Running’ state.

    2.Create and attach additional disk

    • Click on name rStudio_Demo, and click Storage tab.
    • Click ‘Create disk’ and name your disk ’extra_disk’.
    • Choose the 64 GB disk size option.
    • Click ‘Create disk’.
    • Next, attach the disk to the rStudio_Demo virtual computer by clicking ‘Attach disk’.
    • Once it is done attaching the disk to your virtual computer, click the ‘Storage’ tab and note the mounted path of ’extra_disk’.

    3. Create your RStudio Query

    • Click the ‘Dashboard’ tab, then click ‘Launch RStudio’. It will take several minutes to launch.

    • Once RStudio launches you should see a window similar to this screenshot. The ‘Console’ tab is where you will run your queries. You will also use the ‘Terminal’ tab to download the files that will be used for the analysis.

    • Click the ‘Terminal’ tab and click into the command prompt window.

    • Copy the data files from the remote S3 bucket to your extra_disk partition with the following command:

       aws s3 cp --no-sign-request s3://noaa-gsod-pds/ ~/extra_disk/ --recursive --exclude "*" --include "193*/*" --include "194*/*" --include "195*/*" --include "196*/*" --include "197*/*" 
      

    • Once all files have downloaded, click the ‘Console’ tab and paste the following query into the console:

      # create the working directory
      setwd( "~/extra_disk" )
      
      # create variable for the data frame
      data_years = data.frame( matrix( ncol = 2, nrow = 0 ) )
      
      # set the column names
      colnames( data_years ) = c( "Year", "Temp" )
      # read through all the csv files and determine the maximum median temperature for each year
      for ( yr in 1930:1979 ) {
          data_files = list.files( as.character( yr ), full.names = TRUE )
          data = do.call( rbind, lapply( data_files, function( f ) { read.csv( f, na.strings = c( 9999.9 ) ) } ) )
          max_median = max( data$TEMP, na.rm = TRUE )
          data_years[ nrow( data_years ) + 1, ] = c( yr, max_median )
         message( yr, " : ", max_median )
      }
      
      # save plot to disk
      pdf("max_med_temp.pdf")
      plot( data_years$Year, data_years$Temp, xlab = "Year", ylab = "Temperature (degrees F)", ylim = c( 80, 120 ), main = "Maximum Median Temperature (degrees F)" )
      dev.off()
      

    • Once the code is in the console, hit ‘Enter’. You will see that computations are now being performed for each year starting in 1930.

    • Click ‘extra_disk’ (on the third page), then click through the different pages until you find ‘max_med_temp.pdf’. Click the filename to download it

    • Open the PDF to see the plot from the computation you ran, showing the maximum median temperature by year.

Resources

  • Visit this page to find the latest documentation.