Go Cloud

Cloud services library

View project on GitHub

gocloud container - AWS

Configure AWS credentials

Create gocloudconfig.json as follows,

{
  "AWSAccessKeyID": "xxxxxxxxxxxx",
  "AWSSecretKey": "xxxxxxxxxxxx",
}

also You can setup enviroment variables as

export AWSAccessKeyID =  "xxxxxxxxxxxx"
export AWSSecretKey = "xxxxxxxxxxxx"

Initialize library


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

amazoncloud, _ := gocloud.CloudProvider(gocloud.Amazonprovider)

Createcluster

  createcluster := map[string]interface{}{
		"clusterName": "gocloud-test",
		"Region":      "us-east-1",
	}

 resp, err := ecscontainer.Createcluster(createcluster)

 response := resp.(map[string]interface{})
 fmt.Println(response["body"])

delete cluster

 deletecluster := map[string]interface{}{
		"clusterName": "gocloud-test",
		"Region":      "us-east-1",
	}

  resp, err := ecscontainer.Deletecluster(deletecluster)
  response := resp.(map[string]interface{})
  fmt.Println(response["body"])

Create service

 LoadBalancers := []map[string]interface{}{
	{
	"containerName":    "rootmonk",
	"loadBalancerName": "us-east-2",
	}, 
    {
	"containerName":    "rootmonk",
	"loadBalancerName": "us-east-2",
     },
  }
  
  createservice := map[string]interface{}{
		"serviceName":    "ecs-simple-service",
		"taskDefinition": "ecs-demo",
		"desiredCount":   1,
		"Region":         "us-east-1",
		"LoadBalancers":  LoadBalancers,
	}

  resp, err := ecscontainer.Createservice(createservice)

  response := resp.(map[string]interface{})
  fmt.Println(response["body"])

Delete service

  deleteservice := map[string]interface{}{
	"cluster": "cluster",
	"service": "service",
	"Region":  "us-east-1",
   }
  
  resp, err := ecscontainer.Deleteservice(deleteservice)
  
  response := resp.(map[string]interface{})
  fmt.Println(response["body"])

Back to Home Page