Tuesday 9 January 2018

How to setup GoCloud

GoCloud is an open source project which provides unified APIs to access various actions related to Amazon Web Services and Google Cloud Platform. 

Let's take Google Cloud Platform as an example to setup our GoCloud package and check how we can access the APIs provided End to End. 

In order to configure Google Cloud Platform(GCP) to integrate with GoCloud package, one should create a service account on GCP, and the website will provide you with a JSON file which consists of the various environment variables as keys. Such as ClientID,  ClientEmail, PrivateKey etc, to authenticate through our GoCloud package. This JSON file which the values which we get from the GCP service account, we have to save it as "googlecloud.json" within the home environment. Well, for production level, we can convert the JSON file, the keys within the file in specific as environment variables. 

Since it is a Go Library, we can initialize GoCloud package the following way in our code before accessing the Google Cloud Platform APIs

import "github.com/cloudlibz/gocloud/gocloud"

googlecloud, _ := gocloud.CloudProvider(gocloud.Googleprovider)

Here, we are going to create an object, by mentioning the CloudProvider(it's an API from GoCloud to receive the object type as either GCP or Amazon Web Services). Here we mention the cloud provider as Google Cloud Platform. 

After setting up the GoCloud package, you can access various APIs provided by Google Cloud Platform and perform operations like creating clusters, deleting instances, and so on. 

No comments:

Post a Comment