Using golang with Eucalyptus


Posted: 2014-04-24T13:24:30+05:30 | Source | More posts about Eucalyptus golang

Here is an example code to start a new instance in your Eucalyptus cloud using golang. We are using goamz library.

package main

import (
    "fmt"
    "github.com/mitchellh/goamz/aws"
    "github.com/mitchellh/goamz/ec2"
    "net/http"
)

func main() {
    DefaultClient := &http.Client{
        Transport: &http.Transport{
            Proxy: http.ProxyFromEnvironment,
        },
    }

    auth := aws.Auth{"AKI98", "5KZb4GbQ", ""}
    mec2 := ec2.NewWithClient(
        auth,
        aws.Region{EC2Endpoint: "http://euca-ip:8773/services/Eucalyptus"},
        DefaultClient,
    )

    options := ec2.RunInstances{
        ImageId:      "emi-F5433303",
        InstanceType: "m1.xlarge",
        KeyName:      "foo",
    }
    resp, _ := mec2.RunInstances(&options)

    fmt.Println(resp)

}
comments powered by Disqus
Contents © 2004-2014 Kushal Das - Powered by Shonku