GCloudex - Friendly set of wrappers for Google Cloud Platform API's in Elixir

Hello everyone,

I’ve come here to present one of my ongoing projects in Elixir GCloudex (aka Google Cloud for Elixir).

What is GCloudex?

GCloudex is a set/collection of wrappers and clients for the various Google Cloud Platform services’s API’s. It is meant to be friendly, easy to use and configure. If you know ex_aws or erl_cloud then you can see GCloudex as a similar project but for Google Cloud Plaftorm instead of Amazon Web Services.

Why am I building GCloudex

I’m working on an Elixir library/application for my Master’s Thesis and I need to use several Google Cloud Platform API’s. I searched around on GitHub and just found a couple of wrappers for maybe one or two API’s and even those were incomplete. I knew about ex_aws so I thought “Why not build something similar myself?”. I’m going to need those wrappers and I’d like to contribute to the Elixir community so I decided to kill two birds with one stone (joking I don’t really kill birds :lol:)

What do you need to use GCloudex

First you need a Google Cloud Platform account. You may get one for free for two months (not really free but they give you $300 to spend which can be a lot).

Then to use GCloudex in any of your Elixir applications you just need to install it like in the README and then download the credentials JSON file from your Google Cloud console. Put that file in the your_app/config directory and name it creds.json.

Finally put inside the config file you want (like dev.exs) the following line:

config :goth, json: "config/creds.json" |> Path.expand |> File.read!

This will enable the Goth application to use your credentials to authenticate the API requests (please inform me if you can’t get this to work for some reason).

I still have to post a comprehensive and easy config guide on GitHub’s README

What is the Roadmap?

Right now I’ve got clients for two API’s:

  1. Google Cloud Storage

  2. Google Cloud SQL

They’re working pretty much correctly but I haven’t got around to any rigorous testing.

The next API I’m going to implement/wrap is Google Compute Engine and then either Google Cloud Datastore or Google Cloud Big Table. I plan to implement as many API’s as possible but I’m giving priority to those I need for my Msc. Thesis and those that are more popular.

Contributions

I’m open to contributions (and I welcome them). I’m thinking about creating a contributions file or a guideline. So far my main concern is to keep the structure and logic between all API’s as similar as possible.

Examples

iex(3)> GCloudex.CloudStorage.Client.list_buckets
{:ok,
%HTTPoison.Response{body: "<?xml version='1.0' encoding='UTF-8'?><ListAllMyBucketsResult xmlns='http://doc.s3.amazonaws.com/2006-03-01'><Owner><ID>00b4903a979d00a888b29e9968887baaefca546bc5f81b377fc6f3ecdfb8ae5a</ID></Owner><Buckets><Bucket><Name>firstbucket_sasha</Name><CreationDate>2016-03-04T12:10:22.716Z</CreationDate></Bucket><Bucket><Name>sasha_new_storage_new</Name><CreationDate>2016-04-10T10:51:03.588Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>",
headers: [{"X-GUploader-UploadID",
"AEnB2Up6ahrHSbuGVAU_tIeQcC8P8GcW-zPx5wlXa4eMGk8n89ebqPg9V56dRh5rAh8ATH15hMYghFfQkc001IqZDhHNgZzKjQ"},
{"Content-Type", "application/xml; charset=UTF-8"},
{"Content-Length", "445"}, {"Date", "Tue, 19 Apr 2016 16:35:35 GMT"},
{"Expires", "Tue, 19 Apr 2016 16:35:35 GMT"},
{"Cache-Control", "private, max-age=0"}, {"Server", "UploadServer"}],
status_code: 200}}

Links

GitHub
Hex

3 Likes

Why use Google Cloud over AWS?

2 Likes

I’m actually using both @uranther :slight_smile: But since I couldn’t find any set of API wrappers for Google Cloud (and I had found one for AWS that suited my needs) I decided to build my own.

Anyway, if your question was a more general “why would one use Google Cloud over AWS?” then I can do a quick comparison from my experience these last 2/3 months with both:

  • The kind of services they offer are pretty much the same. I don’t think neither wins in that regard. In more “expert” environments and uses cases I think AWS may have an advantage but Google seems to always try to offer their own version of whatever Amazon has.

  • The Google Cloud docs are wayyyyyyyyy better than AWS. Some AWS docs are really long and seem to miss details and information while Google’s are always succint and to the point and nicely formatted. Using AWS’s RDS service (for SQL databases) I found that their API reference has many request fields as optional but in fact they’re listed as required by their system when you do the API calls (just an example).

  • AWS support is really good (I think every Amazon related service has great support) I still haven’t used Google’s.

  • Google Cloud’s console is better and more complete than AWS’s IMO

  • AWS has wayyyy more services available (it’s difficult to keep track of all of them and to remember what they are meant for)

  • AWS free tier is for 12 months but you can only use the low end stuff that’s just useful for experimenting like I’m doing. Google’s is 2 months but they let you use any tier stuff I believe.

  • I haven’t studied the prices in-depth but I’m positive Google’s is quite more affordable. IIRC that’s the reason Spotify decided to host their infrastructure on Google vs. AWS

  • I so far prefer Google Cloud. Everything is more simple and user friendly. I’m a believer AWS offers certain services and complexities than may be better for people who actually need that stuff but for most developers I think Google’s more than enough.

3 Likes

Thank you for the detailed comparison! Maybe I will give Google Cloud a try when I’m ready to deploy the chess engine :069:

1 Like

I’ve began wrapping Google Compute Engine. I’ve got about half of it done (most popular and useful methods first). After I finish wrapping this API I’ll restructure the library a bit and start building test suites.

2 Likes