Created
April 27, 2018 16:25
-
-
Save KernelPanicAUS/f5487017861da1a2c4cb1851bccf1093 to your computer and use it in GitHub Desktop.
List opsworks stacks in go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
❤️