- Newest
- Most votes
- Most comments
Hello.
Try changing the "default" profile as below.
"role_arn" is an option that specifies the ARN of the switch role instead of the ARN of the IAM user.
Judging from the error message, it looks like the switch is for "arn:aws:iam::6963451289992:user/user.name".
If the switch role is successful, the error message will include the string "arn:aws:iam::196354236187:role/high-access".
[default]
region = us-east-2
output = text
[profile high-access]
role_arn = arn:aws:iam::196354236187:role/high-access
mfa_serial = arn:aws:iam::6963451289992:mfa/User.Name
source_profile = default
region = us-east-2
By the way, when performing a switch role using the "--profile" option, the following IAM policy must be set for the IAM user.
I think there is no problem since the switch role is possible from the management console, but please check to be sure.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": [
"*"
]
}
]
}
Also, check out things like CloudTrail.
You may be able to identify the problem from the history of operations performed by "arn:aws:iam::6963451289992:user/user.name".
https://docs.aws.amazon.com/awscloudtrail/latest/userguide/tutorial-event-history.html
Hi,
I strongly suggest that you follow the guidance of this KC article to set your cross-account bucket access properly: https://repost.aws/knowledge-center/cross-account-access-s3
In particular, be careful on the definition of the various and required IAM policies described in this article.
Best,
Didier
The issue you're experiencing appears to be related to the way permissions are being applied when using the AWS CLI versus the AWS Console. This discrepancy often occurs due to differences in how roles and policies are evaluated in these two contexts.
Here are some potential reasons and steps to resolve the issue:
-
Role Assumption: When using the CLI, make sure you're actually assuming the role in the target account. The error messages suggest you're still operating as your IAM user in the source account. Try explicitly assuming the role before running S3 commands:
aws sts assume-role --role-arn arn:aws:iam::196354236187:role/high-access --role-session-name MySession
Then use the temporary credentials provided in the output.
-
S3 Bucket Policy: Check the S3 bucket policy in the target account. It may need to explicitly allow access from the assumed role in the target account. Add a statement like:
{ "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::196354236187:role/high-access" }, "Action": ["s3:ListBucket", "s3:GetObject"], "Resource": [ "arn:aws:s3:::bucket-i-am-trying", "arn:aws:s3:::bucket-i-am-trying/*" ] }
-
Cross-Account Access: Ensure that the role in the target account (high-access) has a trust relationship allowing it to be assumed by your IAM user or a role in the source account.
-
Permissions Boundary: The permissions boundary (user-with-boundaries) you mentioned might be restricting CLI access. Review this boundary to ensure it's not inadvertently blocking S3 actions when using the CLI.
-
Session Duration: If your assumed role session is timing out, you may need to increase the session duration or implement a solution to refresh the credentials automatically.
-
Use AWS SSO: Consider setting up AWS SSO (Single Sign-On) for easier management of cross-account access, which can simplify the process of switching between accounts and roles.
To troubleshoot further:
- Use 'aws sts get-caller-identity' after assuming the role to verify you're operating as the intended role.
- Check CloudTrail logs in both accounts to see exactly what identity is making the S3 requests and any associated errors.
- Review the IAM Access Analyzer findings for potential issues with your policies.
Remember, the console might be using a different authentication method or role, which could explain the discrepancy. Always ensure your CLI is configured to use the same permissions as your console access.
Sources
Access Denied with S3 SDK | AWS re:Post
Access Denied for boto3 list_buckets operation when assuming cross account role from sagemaker notebook | AWS re:Post
Relevant content
asked 2 years ago
asked 2 years ago
asked 3 years ago
- AWS OFFICIALUpdated a year ago

Hi Thanks for your answer, in the initial question I mentioned the issue incorrectly. I have no trouble accessing S3 buckets of target account via AWS CLI using --profile high-access.
But my problem lies in accessing buckets of source account.
I've updated my question to reflect the same, Can you please check that once ?