Create amazoncloudconfig.json
in your HOME/.gocloud directory as follows:
{
"AWSAccessKeyID": "xxxxxxxxxxxx",
"AWSSecretKey": "xxxxxxxxxxxx"
}
You can also set the credentials as environment variables:
export AWSAccessKeyID = "xxxxxxxxxxxx"
export AWSSecretKey = "xxxxxxxxxxxx"
import "github.com/cloudlibz/gocloud/gocloud"
amazoncloud, _ := gocloud.CloudProvider(gocloud.Amazonprovider)
create := map[string]interface{}{
"ImageId": "ami-ccf405a5",
"InstanceType": "t1.micro",
"Region": "us-east-1",
}
resp, err := amazoncloud.CreateNode(create)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
stop := map[string]string{
"instance-id": "i-06d518ba15b68685c",
"Region": "us-east-1",
}
resp, err := amazoncloud.StopNode(stop)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
start := map[string]string{
"instance-id": "i-0174bd6f54178e89b",
"Region": "us-east-1",
}
resp, err := amazoncloud.StartNode(start)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
Reboot := map[string]string{
"instance-id": "i-037a9fae81c33ac30",
"Region": "us-east-1",
}
resp, err := amazoncloud.RebootNode(Reboot)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
delete := map[string]string{
"instance-id": "i-0174bd6f54178e89b",
"Region": "us-east-1",
}
resp, err := amazoncloud.DeleteNode(delete)
response := resp.(map[string]interface{})
fmt.Println(response["body"])