Created
November 28, 2023 12:51
-
-
Save zbstof/07726793c292c40decc21ff2d164f418 to your computer and use it in GitHub Desktop.
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/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