- Newest
- Most votes
- Most comments
I found the issue. For the get object permission resource need to be specified as "Resource": "arn:aws:s3:::your-bucket-name/*"
and not just the bucketname "Resource": "arn:aws:s3:::your-bucket-name" as I had originally done.
answered 2 years ago
It is not a requirement that S3 buckets need to have a sagemaker prefix in order to access them from a Jupyter notebook or SageMaker instance. The 403 Forbidden error you are encountering when trying to access an object in the S3 bucket usually indicates a permissions issue. Since you can list the contents of the bucket but not download the object, it suggests that there might be a difference in permissions between listing and reading objects.
Steps to Troubleshoot and Resolve the 403 Error
Verify IAM Role Permissions: Ensure that the IAM role attached to your Jupyter notebook or SageMaker instance has the necessary permissions to access the objects in the S3 bucket. The permissions should include both s3:ListBucket and s3:GetObject.
Here is an example IAM policy that grants these permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::your-bucket-name"
]
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::your-bucket-name/*"
]
}
]
}
- Bucket Policy: Ensure that the S3 bucket policy allows the role to access the objects. Sometimes bucket policies can restrict access even if the IAM role has the right permissions.
Example bucket policy allowing a specific IAM role to read objects:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::account-id:role/your-role-name"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
S3 Object ACLs: Check the Access Control List (ACL) on the specific S3 objects. Ensure that the objects are not explicitly denying read access.
VPC Endpoint Policies: If you are using a VPC endpoint for S3, ensure that the endpoint policy does not restrict access to the objects.
Testing Access: Use the AWS CLI or another tool to test access to the objects using the same IAM role. This can help identify if the issue is with the permissions or the way the Jupyter notebook is configured.
Example CLI command to list objects:
aws s3 ls s3://your-bucket-name/
Example CLI command to get an object:
aws s3 cp s3://your-bucket-name/object-key /local-path
Relevant content
- AWS OFFICIALUpdated 4 months ago

i think you will find this too in the above answer that i gave too