Say I get a set of access keys from a user, Is there a way to validate them?
For now I'm making simple API calls to methods like, describeVolumes(), describeLoadBalancers() or describeAddresses() and work with Exception codes to validate the Credentials.
But what if I don't know the service? Is there a better way to validate the Credentials?
If you simply wish to validate whether the Credentials are "correct", then your current method is good:
InvalidAccessKeyId
then the credentials are invalidThis is different to checking whether the user has Permissions to make the API call. Determining whether they have the correct permissions could be done using the IAM Policy Simulator or by attempting a call and checking the response (eg
AccessDenied
).Take a look at the AWS IAM API, specifically the GetUser function. From the description: