- Newest
- Most votes
- Most comments
Try by using below commands:
To list IAM policies: aws iam list-policies --scope Global
To list IAM roles: aws iam list-roles
Please make sure below items before above commands:
-
Enable Server Access Logging: This will log all requests made to S3 bucket. You can enable server access logging by going to the S3 bucket properties and enabling access logging.
-
Enable AWS CloudTrail Logging: CloudTrail logs API calls made to S3 resources. You can enable CloudTrail logging for your S3 bucket to track who accessed it.
-
Analyze Logs with Amazon Athena: Once you have the logs, you can use Amazon Athena to query and analyze them. This will help you identify all users who have accessed the bucket.
-
Use AWS IAM Policies and Roles: Review the IAM policies and roles that grant access to the S3 bucket. You can use the AWS Management Console or AWS CLI to list IAM policies and roles.
Along what has already been suggested. You could us also use IAM Access Analyzer for S3 https://docs.aws.amazon.com/IAM/latest/UserGuide/what-is-access-analyzer.html
This would also be helpful moving forward to help you determine which roles have permissions to your bucket but arent used.
Try using
Bucket access using IAM Access Analyzer for S3
IAM Access Analyzer for S3 alerts you to S3 buckets that are configured to allow access to anyone on the internet or other AWS accounts, including AWS accounts outside of your organization. For each public or shared bucket, you receive findings into the source and level of public or shared access. For example, IAM Access Analyzer for S3 might show that a bucket has read or write access provided through a bucket access control list (ACL), a bucket policy, a Multi-Region Access Point policy, or an access point policy. With these findings, you can take immediate and precise corrective action to restore your bucket access to what you intended.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-analyzer.html
Relevant content
- asked 2 years ago
