Skip to content

Instantly share code, notes, and snippets.

@rendicott
Created January 15, 2020 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rendicott/2cbe415a663cdf41696bcf0753327b06 to your computer and use it in GitHub Desktop.
Save rendicott/2cbe415a663cdf41696bcf0753327b06 to your computer and use it in GitHub Desktop.
barebones golang client application for AWS
package main
import (
"fmt"
"flag"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/organizations"
)
func main() {
var profile string
var region string
flag.StringVar(&profile, "p", "default", "profile for creds")
flag.StringVar(&region, "r", "us-east-1", "region for creds")
flag.Parse()
sessProfile := session.Must(session.NewSessionWithOptions(session.Options{
Config: aws.Config{Region: &region},
Profile: profile,
}))
client := organizations.New(sessProfile)
input := organizations.ListPoliciesInput{
Filter: aws.String("SERVICE_CONTROL_POLICY"),
}
result, err := client.ListPolicies(&input)
if err != nil { panic(err)}
fmt.Println(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment