Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boto3 without param region_name may cause error:InvalidAccessKeyId #15

Open
funnyndk opened this issue Nov 17, 2022 · 0 comments
Open

Comments

@funnyndk
Copy link

I tried to access a S3 using awsKeyTools with AK/SK, but got a error:
botocore.exceptions.ClientError: An error occurred (InvalidAccessKeyId) when calling the ListBuckets operation: The AWS Access Key Id you provided does not exist in our records.
it turns out that boto3 without param region_name cant work. i changed awsKeyTools/commands/user_info_command.py as below and fix the problem:
class UserInfoCommand(Command): def run(self, line): client = boto3.client('s3',region_name="cn-north-1")# 实际生产环境region_name一定要准确填写 buckets = client.list_buckets()['Buckets'] print("\nbucket:") for bucket in buckets: print(bucket['Name']) iam = boto3.resource('iam',region_name="cn-north-1") global current_user current_user = iam.CurrentUser() print("\nUserInfo:") print("\tuser_id:\t\t", current_user.user_id)...
but i was using a low-privileged AK/SK, that code only works before bucket listing. new error was occurred:
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the GetUser operation: User: xxxxxxxxxxxxxxxxxxxxxxxxxx is not authorized to perform: iam:GetUser on resource: user dmsfiles because no identity-based policy allows the iam:GetUser action
it is better that the tool can catch some normal error from botocore and show some help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant