3 Answers
- Newest
- Most votes
- Most comments
0
The "Access Denied" error you're encountering when using the CopyObject operation could be due to several factors, even though your IAM policies appear to be correctly configured. Here are some potential causes and solutions:
- S3 Object Ownership and ACLs:
- If your buckets have Object Ownership set to "bucket owner enforced," ACLs are disabled. When copying objects between buckets with this setting, you need to ensure both source and destination buckets use the same setting.
- You mentioned "No ACL configured," but it's worth double-checking the Object Ownership settings on both buckets.
- Encryption Issues:
- If the objects in your source bucket are encrypted using KMS keys (SSE-KMS), your Lambda role needs permissions to both decrypt from the source key and encrypt with the destination key.
- Check if your buckets use default encryption with KMS keys and ensure your Lambda role has the necessary KMS permissions.
- Bucket Policy Restrictions:
- There might be other bucket policies or account-level restrictions that are overriding your explicit permissions.
- Verify there are no restrictive bucket policies or S3 Block Public Access settings that might be affecting the operation.
- VPC Configuration:
- If your Lambda function runs in a VPC, ensure it has proper network access to reach S3 through VPC endpoints or NAT gateways.
- Cross-Account Access:
- If the buckets are in different AWS accounts, additional permissions might be needed.
To troubleshoot:
- Try using s3_client.get_object() on the source and s3_client.put_object() on the destination separately to narrow down where the permission issue lies.
- Check CloudTrail logs for more detailed information about the denied access.
- Verify that both buckets' Object Ownership settings are compatible for the copy operation.
- If using KMS encryption, add the necessary KMS permissions to your Lambda role.
Sources
Access Denied when copying S3 objects with boto3 even using admin permissions | AWS re:Post
Copying, moving, and renaming objects - Amazon Simple Storage Service
0
Also, make sure the Lambda and S3 bucket are in the same region. If different region, Lambda won't be able to use the S3 code.
0
Make sure that you have * added to your S3 resources for GetObject, PutObject, and DeleteObject actions to succeed, e.g. arn:aws:s3:::nfd-scanbacket/*, not just arn:aws:s3:::nfd-scanbacket/.
See Writing IAM Policies: How to Grant Access to an Amazon S3 Bucket for more details.
answered a year ago
Relevant content
- AWS OFFICIALUpdated 10 months ago
