Created
January 15, 2020 16:42
-
-
Save rendicott/2cbe415a663cdf41696bcf0753327b06 to your computer and use it in GitHub Desktop.
barebones golang client application for AWS
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" | |
"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(®ion, "r", "us-east-1", "region for creds") | |
flag.Parse() | |
sessProfile := session.Must(session.NewSessionWithOptions(session.Options{ | |
Config: aws.Config{Region: ®ion}, | |
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