(AccessDenied) when calling the PutObject operation: Access Denied

0

I am trying to enable object lock option in s3 in AWS. it seems that this option is not working trough GUI and we should use CLI to enable it for upload objects. when I try to create an objcet as a sample I get bellow error message:

aws s3api put-object --bucket <my Bucketlist name> --key test-1 --body test-1 --object-lock-mode GOVERNANCE --object-lock-retain-until-date 2025-06-12

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

I also enabled public ACL policy as well as access permssion as the follwing JSON format:

{
"Version": "2012-10-17",
"Id": "ExamplePolicy01",
"Statement": [
    {
        "Sid": "ExampleStatement01",
        "Effect": "Allow",
        "Principal": {
            "AWS": "arn:aws:iam::********:root"
        },
        "Action": "*",
        "Resource": [
            "arn:aws:s3:::<my Bucketlist name>",
            "arn:aws:s3:::<my Bucketlist name>/*"
        ]
    }
]

anyone faced this issue before?

posta un mese fa133 visualizzazioni
1 Risposta
0

Hello.

I made the same settings as you in my environment and was able to upload successfully.
Is the permission to execute "PutObject" set in the IAM policy of the IAM user running AWS CLI?

Also, if you are performing operations as an IAM user, try changing the ARN to that of the IAM user as shown below.

{
    "Version": "2012-10-17",
    "Id": "ExamplePolicy01",
    "Statement": [
        {
            "Sid": "ExampleStatement01",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::********:user/test"
            },
            "Action": "*",
            "Resource": [
                "arn:aws:s3:::<my Bucketlist name>",
                "arn:aws:s3:::<my Bucketlist name>/*"
            ]
        }
    ]
}

If the S3 bucket and IAM user belong to the same AWS account, you should be able to access it if the above bucket policy setting or IAM policy allows the operation.

profile picture
ESPERTO
con risposta un mese fa
profile picture
ESPERTO
verificato un mese fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande