ERROR An error occurred (AccessDenied) when calling the DeleteObject operation: Access Denied

0

my s3 IAM

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:*",
                "s3-object-lambda:*"
            ],
            "Resource": "*"
        }
    ]
}

settings.py

INSTALLED_APPS = [
    'storages',
]

DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

django code

def UpdateCompanyView(request):
    user = request.user
    company = user.company
    old_logo = company.logo
    if old_logo and 'logo' in serializer.validated_data and data_logo is not None:
        old_logo.delete()
    #old_logo.delete(save=False)#I've tried this also

other all actions working put, add, but deleting occurring this error

asked a year ago556 views
1 Answer
0

Hello.

S3 bucket policy not set?
If DeleteObject is denied in the S3 bucket policy, object deletion will fail even if the IAM policy allows it.

profile picture
EXPERT
answered a year ago
  • where to set it ?

    in the bucket policy i already add the same, but same error

  • If the IAM policy is set correctly, there is no need to set the S3 bucket policy.

  • then which policy you're talking about. the IAM policy is already set. then why i'm getting this error. please give me the solution if you know about it

  • Is your AWS account managed by AWS Organizations? In that case, please check whether DeleteObject is not rejected by SCP. Additionally, please make sure that "Permissions boundaries" are not set, as described in the document below. https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html?icmpid=docs_iam_console

  • when i visit SCPs

    Your request has a problem. Please see the following details. Your account is not a member of an organization.

    and Permissions boundaries are also not set

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions