docs icon indicating copy to clipboard operation
docs copied to clipboard

Fix S3 bucket policy example to prevent "action does not apply to any resources in statement" error

Open mkdev10 opened this issue 1 year ago • 0 comments

Describe the content issue: I encountered an error when executing a policy in the AWS Console, which states "action does not apply to any resources in statement." I propose a correction to resolve this issue.

The existing policy example is:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Principal": { "AWS": "arn:aws:iam::<AWS-account-ID>:role/<role-name>" },
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::<bucket-name>/*"
            ]
        }
    ]
}

I receive an error saying "action does not apply to any resources in statement."

I propose the following correction:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Principal": { "AWS": "arn:aws:iam::<AWS-account-ID>:role/<role-name>" },
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::<bucket-name>",
                "arn:aws:s3:::<bucket-name>/*"
            ]
        }
    ]
}

By implementing this correction, it is expected that the number of people encountering this error will be reduced.

URL page where content issue is: https://docs.amplify.aws/react/build-a-backend/storage/use-with-custom-s3/

mkdev10 avatar Jul 03 '24 05:07 mkdev10