/ #cloud9 #blog 

Blogging hugo on the cloud

Hugo is a nice site generator which can be used for blogging (Read here why i recently switched to it). However, it requires a go program to run and generate the files - something i cannot do easily on my android tablet…

Cloud to the rescue

Back in 2014 I noticed the existence of Cloud IDEs like c9.io. It’s a full blown IDE accessible from your Browser. It comes with access to a small linux container to run your stuff, which is fired on automatically, when you are on the project (in the higher plans you can also have permanent ones, and you are also able to connect your own).

It might not be perfect for everything, but for smaller projects it seems sufficient. As it has nice support for Go and Markdown files, it might be the perfect match for writing my Blog.

Cloud 9 on AWS

While i was writing this article in march, I still used c9.io directly because I had an account and I didn’t pay too much attention to the banners around the page. It’s all still working, and they promise “it will be free forever”, however things changed a lot since i last used it:

> It has been bought by and integrated into AWS (Amazon Web Services). <

Is this good or bad?

It’s great! It’s awesome! That was my first thought. I use aws for various things anyway, and love it the most out of the three major players (Google Cloud Platform (GCP)/Microsoft Azure/Amazon Webservices (AWS)).

So let’s set this up and get it running! I jumped right into it, just to notice that my standard region (eu-central-1 frankfurt) is not supported yet, d’oh. I created in us zone to try it out a bit, then abandoned it.

Several months later i tried again, forgot to select the previously configured zone in Ohio and it offered me to create instance in Frankfurt. Ohhh i love it.
Now it is! 

So it is great after all.

I just hope they still put some money and effort into developing it further.

How to configure?

It’s quite easy to setup - just press the shiny button “create new environment” on your aws console when browsing to “cloud9 service”. It will ask for name / description of the new environment and for the instance type and what linux image you want to use.

Instance setup

For hugo blog a “small instance” is all you need. I chose Ubuntu 18.04 because I’m used to it but aws image is fine as well if you like this more. All follow-up documentation here is based on ubuntu OS, so if you want to follow step-by-step, use this. Also you can configure for how long the instance should stay active, when you’re not connected to the c9 ide. Default is 30 Minutes.

After you click “create”, aws will create a new EC2 instance for your cloud9 IDE environment. This might take a couple of minutes. Once it’s ready, it will launch the IDE and is ready to use.

Setup IDE

First things first, go to “File -> Preferences” and switch to dark theme. Ahhh. Better…

Then adjust font-size and editor settings to your needs. You can adjust all of that later as well - but it’s important to check right from the beginning if you can live with it and if it comes with everything you need.

Install Hugo & Run Configuration with Preview

Installing hugo is quite easy, on ubuntu “snap” is already pre-installed, so all you need to do is running:

sudo snap install hugo

You can type it just directly to the small console window on the bottom. Once you did that, hugo is there, so you can use all the hugo commands directly from the terminal.

After that just clone your blog, i.e.:

git clone git@github.com:jbrosi/ch.jbrosi.blog.git

and you’re almost ready to go.

Switch to “Run -> Run Configurations” and press “New Run Configuration”. On the bottom a new tab will appear where you can enter a command to run the hugo server:

hugo  server --port=8080 --bind 0.0.0.0 --baseURL=https://2537921be4854ddb876abd5ad658f787.vfs.cloud9.eu-central-1.amazonaws.com/

Default port being recognized by the aws https proxy is 8080, so i specified this and used baseURL of my EC2 instance (else it will try to load stuff from “localhost”). You can get the url by pressing “preview” and in the preview window copying the URL.

If you cloned your blog into a subdirectory (default) don’t forget to select it under “CWD”.

AWS does not expose any port of your ec2 to public, so you need to adjust security groups there to be able to see the preview:

  • Go to aws console “EC2 -> security Groups”
  • add new Group “cloud 9 preview”
  • Allow inbound port 8080
  • Switch to “EC2 -> Instances”
  • Select your Cloud9 instance, right click, network -> security groups
  • add previously created “cloud 9 preview” security group

Once this is done, you should be able to hit the “preview” button after you hit the “run” button for your cloud9 ide to live-preview the changes you’re making.

Once all is finished, this is how it might look like:

Blogging in hugo on aws
Blogging in hugo on aws

Just write, preview, commit and then run through CI to deploy.

Alternatives

Linux On Dex

I was playing around with Linux on Dex a bit today. Looks promising - full (well almost) Linux on my Samsung tablet. There I could even run my beloved WebstormIDE. I will write a bit more about it shortly.

VNC/RDP

Of course you can just login remotely to your computer and work on that. Will check out how it compares in terms of performance, battery, etc.

Visual Studio Code Remote

It is possible to run visual studio code on a server and access it via browser directly. Sounds really really promising, will definitely try and write about it. For now, you might find some additional information here

Conclusion

A browser is enough, blog from anywhere, just pick up where you left. Tempting setup, let’s see if it can make me happy long term.

Updates

3.8.2019: updated the article with aws related stuff

Sources:

Author

JBrosi

Passionate coder; discovered the black magic of writing programs in the age of 13 and still loving it. When not fighting with bits & bytes probably seen outside with a camera.