Because Afraus received a good interest, last month I override free plan limits.

That got me move my Shiny App on an Amazon AWS instance.

Well, it was not so straight forward: even if there is plenty of tutorials around the web, every one seems to miss a part: upgrading R version, removing shiny-server examples… And even having all info it is still quite a long, error-prone process.

All this pain is removed by ramazon, an R package that I developed to take care of everything is needed to deploy a shiny app on an AWS instance. An early disclaimer for Windows users: only Apple OS X is supported at the moment.

How to use ramazon (2)

Using ramazon

As one would expect, using ramazon is a very pleasant experience, given that you just have to run a function, ramazon(), passing to it the EC2 instance public_DNS and the name of the key pair file downloaded from amazon AWS. Just follow the following steps to deploy your app with ramazon.

launch an amazon EC2 instance

I am not going to go into details, I can see you are in a hurry to see your app on the Web, I will just show you screenshoots from the process.

Be sure to change all parameters in accordance with the screenshots.

retrieve the public dns

As shown within the above introduced deck, you can find your Public_dns among the instance details:
public dns

Retrieve your keypair name

your key pair name is associated with the security group you choose for the ec2 instance. take note of it directly when creating the instance.

key pair name

install ramazon package

a working version of ramazon package is available through Github. In order to use it you have to execute the following code, installing devtools an downloading ramazon from the github repo:


run ramazon()

after loading ramazon library you just need to run the following line of code, using the public DNS and key pair name ( without “.pem” extension into the name) you retrieved into the previous paragraphs:

ramazon(Public_DNS ="your_Public_DNS", key_pair_name = "your_key_pair_name")

after running this line you will see your console being populated by a lot of messages showing you what’s going on behind the scene (see next paragraph for more specific info about that).

enjoy your app!

At the end of the process, ramazon will communicate that everything went smoothly and will print out the web URL where you can find your deployed app.

Some tech specs

the full ramazon code is released under MIT license on a github repo. Nevertheless, for those interested in code details I will describe in the next lines some details about ramazon design.

Basically, what ramazon does is to write a bash script with all commands needed to:

  • install the latest version of R (non trivial issues, since Ubuntu comes with R 3.0.2 version, causing heavy packages incompatibility)
  • install the latest version of Shiny-Server
  • copy the shiny app files on the server

All commands are run with verbose on, in order to give the clearest possible vision of what is going on and what could possibly go wrong.

The resulting bash script is then run with system() function.

Possible issues

Since the package is in its very first stages, I am aware of just a little part of possible issues that could arise during its use.

I really hope you will help me to find out some more of them using it and opening issues on the Github repo 🙂

In the meanwhile, find below three tricky problems that could arise during ramazon use.

place your key correctly

ramazon is trained to look for the key pair file within the shiny app folder. Therefore you have to save that file within this folder. If you are using the same key for different instances you can also copy and paste it into the shiny app. If you are using an online repository for your project, be sure to add your key pair to the .gitignore file.

this was also kindly pointed out from Simon in comments: your .pem file should be in your working directory and your working directory should be the one hosting the app.

a matter of extensions

It sometimes happens that the key pair file is saved as a txt file. This results in ramazon not being able to connect with AWS instance and failing its job.

All you have to do in this case is to change the extension of the key pair file.

Refresh that IP

as you can see within the deck showed above, the security group associated with your instance as an SSH connection rule (see slide 10)
Even if this type is set with “My IP“, if this IP changes (i.e. you connect from another network) it will not update automatically.

This again will result in ramazon failing its job, given that it will not be able to establish an SSH connection with the instance.

All you will have to do in this case is to edit inbound rules for the security group and specify again “My IP” for the SSH Type. This will change the IP into your current IP.

No Public DNS showing

After trying ramazon (yeah, it worked 😌), @ukituki pointed me out a possible issue: the absence of a public DNS for a given instance.
this issue comes from not checking the “Automatically assign a public IP address to your instances” during the launching process.

To solve this problem you just have to follow the following steps (from question EC2 instance has no public DNS on Stackoverflow):

  • Go to
  • Go To Networking -> VPC
  • Open Your VPCs
  • select your VPC connected to your EC2
  • Edit Summary -> Change DNS hostnames: to YES

thank you ukituki!

Let me know

I am already working on some further improving of the ramazon functionalities, like the update function to be run after the first deploy and some other facilities.
Nevertheless I would really appreciate you coming back after using ramazon to tell me what you went wrong, preferably opening Github issues, what could be done better and what you would like to see.


30 thoughts on “ramazon: Deploy your Shiny App on AWS with a Function

  1. ramazon(public_DNS =”your_Public_DNS”, key_pair_name = “your_key_pair_name”)

    public_DNS should be Public_DNS

    Also the .pem needs to be placed in your working directory (which needs to be the location of your shiny app)

    1. Hi Simon, thank you for pointing this out. going to update the post.

      Hope you enjoyed the rest of the post and that you found ramazon useful 😀

      thank you again

      1. Hi Simon, glad to hear that.
        If you have an updated version of ramazon code you could consider submiting a pull request on github Ramazon repo: I am here to help if you need advice on this.
        This would be of great help for the R community and would be surely really appreciate ( I would appreciate it too 😄).
        Thank you a lot once again.

  2. When I run ramazon() it generates a webpage, but fails to load Shiny


    The error in the browser is

    Error in eval(expr, envir, enclos) :
    The Shiny package was not found in the library. Ensure that
    Shiny is installed and is available in the Library of the
    user you’re running this application as.
    Calls: local -> eval.parent -> eval -> eval -> eval -> eval
    Execution halted

    1. Hi Mark,

      first of all I really apologise for this late reply: I am just changing my job and those have been quite challenging days :).

      That said, I experienced the same problem while developing ramazon: it was basically due to not installing shiny library at an admin level.

      This should actually be solved within amazon workflow, since shiny package installation is provided in sudo mode.

      Nevertheless you can tackle this issue doing the following:

      • open a terminal session
      • access your amazon aws instance running:

      ssh StrictHostKeyChecking=no -v -i *key_pair_address* *user_server*

      where key_pair_address user_server are the same parameters you passed to ramazon() function.

      • run the following

      sudo su - \
      -c "R -e \"install.packages('shiny', repos='')\""

      • start an r session


      • check for shiny package availability


      You can find more on the issue at the following link:

      I really hope this will help you and once again apologise for late reply.


  3. I am trying to use amazon to deploy my shiny web app.

    The app collects input from users and saves it in a AWS rds database. Because of this I have had to use “RMySQL” package in my shiny app.

    I have tried to deploy with ramazon, but i keep getting

    ERROR: there is no package called ‘RMySQL’

    Please can you help me out. You can go through my code on github

    I am using a Mac OS X as my development platform.

  4. Hello. I tried to use this package and it doesn’t work. I am fairly new to R, Shiny and AWS. I ran ramazon() and it worked put the print out url “Failed to open page”. I am using other packages other then shiny.

      1. Really thank you for getting back after trying ramazon: it is a really recent package and any help for its developement is really appreciated.
        Good thing is that I have just released a new version of the ramazon package! find out more here:
        how-to-list-loaded-packages-in-r: ramazon-gets-cleaver/

        Ramazon is now able to detect and install all packages required by your shiny app. Moreover handling for “one-file” shiny app is available.

        Anyway, let me ask you a few questions so that I can help you understand what is not working:

        1. are you working on a OS X operating system?
        2. did you installed latest ramazon version?

        to be sure just run:


        Finally, could you just send me (andreacirilloac at

        1. the bash script produced by ramazon ( find it within the shiny app folder)
        2. latest 10 lines of the Rstudio Console output after running ramazon function

        This should be enough to understand what’s going on, and should take you less time that deploying your app manually through the command line 🙂

        Thank you again,


  5. Yes, of course. The first mistake was due to the fact that I was using packages other than the shiny package. This I solved by using the code you have on Github. The second issue was simply that I didn’t have my script in the correct folder – like I said; it was me doing something stupid 🙂

    1. Thank you once again Johan, I am going to merge the new features you tried within a new package release, so thank you for testing it 😃!

      About “stupid things”: as long as you stay on debugging mode there is nothing stupid you can do 😌

    1. No problem at all Johan, really glad you managed to publish your app on the web 😊!
      if you think it could be something useful for other readers, would you mind to share with us the root cause of your issue ? Thank you anyway and keep on our sharing!

  6. Sorry! This is the code for my app.R file:


    ui <- shinyUI(pageWithSidebar(

    Application title

    headerPanel("Miles Per Gallon"),



    server <- shinyServer(function(input, output) {


    shinyApp(ui = ui, server = server)

  7. Hi again,

    Thank you for the fast reply. Yes, my Shiny application does rely on other packages than just the shiny package. So now I’ve just made a really simple app that only uses the shiny package, but I still get the same error. I am very inexperienced with Shiny so I am sure it is just me that is doing something stupid 🙂

    This is the app.R script that I have in my working directory together with the .pem file:


    ui <- shinyUI(pageWithSidebar(

    Application title

    headerPanel("Miles Per Gallon"),



    server <- shinyServer(function(input, output) {


    shinyApp(ui = ui, server = server)

    This is how I use the ramazon() function:
    ramazon(Public_DNS = “”, key_pair_name = “myname”,test = FALSE)

    And the output url is this:

  8. Hi again,

    So I followed all of your steps and eventually ran the ramazon() function, but I have obviously made a mistake somewhere because it is not working as intended. When I go the url where my Shiny app should be deployed all I see on this page is a heading “/ Index of” followed by a bullet point by the name of my R working directory folder. Clicking this link leads me to a page with the text “ERROR: cannot open the connection”

    Do you know what I am doing wrong?

    1. Hi johan,
      Thank you for reporting this.
      Two questions:
      1) does your shiny app read any external file? This kind of error message is usually related to R being unable to read some csv or similar external source.
      2) does your shiny app rely on packages different from shiny? The current version of Ramazon installs on the server only this package. I’m almost done with a new release where all required packaged are automatically detected and installed. You can find it on GitHub , develop branch.

      Thank you again and let me know 😀

    1. Thank you for commenting Johan!
      I originally developed Ramazon for personal purposes, therefore only Unix version. That said, since I have received quite a lot of requests from Windows users I am thinking of developing a windows version as well.
      You can stay updated on the GitHub repo:

    1. Thank you Ashirwad,
      I think indeed this provide a great facility for R developers.
      I’m actually planning to expand the current version with more functionalities, you can stay updated on following the dedicated repository on GitHub :
      Let me know if I can be of help in any way.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s