Using Golang with go-aws-sdk and having some issues catching invalid session credentials.
Using the shared credential files in ~/.aws/{config, credentials}
Sess, err := session.NewSessionWithOptions(session.Options{
Profile: instance.Config.AWS.AWSProfile,
})
Works fine when the credentials are valid, but if I use an invalid aws_access_key_id in the credentials file, I need a way to detect this with my AWSLogin() func.
What's happening is any subsequent calls to an AWS service raises a panic when using Sess above.
How can I detect a failed login with the above NewSessionWithOptions() method?
UPDATE: yes, the error type is nil, so the following is of no use:
if err != nil {
return nil, fmt.Errorf("Error logging into AWS: %v", err.Error())
}
recover
? This way you can at least catch the error on something you know should work in most cases. – kichik