GoCloud
GoCloud is a golang library which hides the difference between different APIs provided by varied cloud providers (AWS, GCP, OpenStack etc.) and allows you to manage different cloud resources through a unified and easy to use API.
Now we support AWS, Google Cloud, DigitalOcean, Alibaba Cloud. Common service types of the cloud providers we support are:
- Compute — Allows you to manage cloud and virtual servers.
- Compute Storage — Allows you to manage Compute storage.
- Container — Allows users to install and deploy containers onto container based virtualization platforms.
- Load balancer — Allows you to manager Load Balancer service.
- DNS — Allows you to manage DNS service.
And we also support other service types, such as Machine Learning of AWS, Serverless of Google Cloud and AWS.
Alibaba Cloud support
GoCloud for Alibaba Cloud now we support ECS (compute service), Load Balancer, Storage, Container and DNS.
Once you have configured your Alibaba Cloud credentials (AccessKeyID, AccessKeySecret)
Locally. You can create a load balancer by this
gocloud.AlibabaCloudProvider().LoadBalancer().Createloadbalancer()
How to use
For example, we want to create a load balancer
1. Configure credentials locally
Create a directory called .gocloud in your HOME directory.
Create `alicloudconfig.json` as follows and store it in .gocloud folder.
{
“AliAccessKeyID”: “xxxxxxxxxxxx”,
“AliAccessKeySecret”: “xxxxxxxxxxxx”
}
also You can setup environment variables as
export AliAccessKeyID = “xxxxxxxxxxxx”
export AliAccessKeySecret = “xxxxxxxxxxxx”
2. Create a cloud provider client
aliProvider := gocloud.AlibabaCloudProvider()
3. Prepare parameters
createLoadBalancer := map[string]interface{}{
“RegionId”: “cn-qingdao”,
“LoadBalancerName”: “abc”,
“AddressType”: “internet”,
“InternetChargeType”: “paybytraffic”,
}
or use builder
createLoadBalancer, err := aliloadbalancer.NewCreateLoadBalancerBuilder().
RegionID(“cn-qingdao”).
LoadBalancerName(“abc”).
AddressType(“internet”).
InternetChargeType(“paybytraffic”).
Build()
if err != nil {
fmt.Println(err)
return
}
4. Do it
resp, err := aliProvider.LoadBalancer().Createloadbalancer(createLoadBalancer)