I'm trying to list emr clusters using go.
Here is the code I have that is returning blank. I did "the same" in python with correct results.
running := "RUNNING"
waiting := "WAITING"
emr_states := []*string {&running, &waiting}
var abc emr.ListClustersInput
abc.SetClusterStates(emr_states)
sess := session.Must(session.NewSession())
svc := emr.New(sess)
list_clusters_output, err := svc.ListClusters(&abc)
_ = err
println(fmt.Sprintf("type of list clusters output is %s", reflect.TypeOf(list_clusters_output)))
println(fmt.Sprintf("type of *list clusters output is %s", reflect.TypeOf(*list_clusters_output)))
list_clusters_output_dereffed := *list_clusters_output
println(list_clusters_output_dereffed.String())
The output I'm getting is
type of list clusters output is *emr.ListClustersOutput
type of *list clusters output is emr.ListClustersOutput
{
}
There is a cluster running that I have successfully returned with a python script.
Figured it out. I was missing region indication in the session.
Full solution below.
package main
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/emr"
)
func main() {
starting := "STARTING"
running := "RUNNING"
waiting := "WAITING"
emr_states := []*string {&starting, &running, &waiting}
var abc emr.ListClustersInput
abc.SetClusterStates(emr_states)
sess := session.Must(session.NewSession())
reggie := "us-east-1"
sess.Config.Region = ®gie
svc := emr.New(sess)
list_clusters_output, err := svc.ListClusters(&abc)
if err != nil {
println(err.Error())
}
list_clusters_output_dereffed := *list_clusters_output
println(list_clusters_output_dereffed.GoString())
}