Skip to content

Instantly share code, notes, and snippets.

@KernelPanicAUS
Created April 27, 2018 16:25
Show Gist options
  • Save KernelPanicAUS/f5487017861da1a2c4cb1851bccf1093 to your computer and use it in GitHub Desktop.
Save KernelPanicAUS/f5487017861da1a2c4cb1851bccf1093 to your computer and use it in GitHub Desktop.
List opsworks stacks in go
package main
import (
"fmt"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/opsworks"
)
func main() {
sess, err := session.NewSession(&aws.Config{
Region: aws.String("us-east-1")},
)
svc := opsworks.New(sess)
result, err := svc.DescribeStacks(nil)
if err != nil {
exitErrorf("Unable to list stacks", err)
}
for _, stack := range result.Stacks {
fmt.Printf("%s\n", aws.StringValue(stack.Name))
}
}
func exitErrorf(msg string, args ...interface{}) {
fmt.Fprintf(os.Stderr, msg+"\n", args...)
os.Exit(1)
}
@Fabs
Copy link

Fabs commented Apr 27, 2018

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment