Skip to content

Instantly share code, notes, and snippets.

@zbstof
Created November 28, 2023 12:51
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 zbstof/07726793c292c40decc21ff2d164f418 to your computer and use it in GitHub Desktop.
Save zbstof/07726793c292c40decc21ff2d164f418 to your computer and use it in GitHub Desktop.
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/sts"
)
func main() {
_ = os.Setenv("AWS_SDK_LOAD_CONFIG", "1")
sess, err := session.NewSessionWithOptions(session.Options{
Config: aws.Config{Region: aws.String("us-east-2")},
})
if err != nil {
fmt.Println("Error creating session:", err)
return
}
svc := sts.New(sess)
result, err := svc.GetCallerIdentity(&sts.GetCallerIdentityInput{})
if err != nil {
fmt.Println("Error calling GetCallerIdentity:", err)
return
}
fmt.Println("ARN:", *result.Arn)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment