Trying to set up Amazon's S3 bucket: 403 Forbidden error & setting permissions

前端 未结 7 2037
Happy的楠姐
Happy的楠姐 2021-01-03 02:52

I\'m following Hartl\'s railstutorial.org and have arrived at 11.4.4: Image upload in production. What I\'ve done:

  • Signed up for Amazon Web Services
  • I
7条回答
  •  死守一世寂寞
    2021-01-03 03:44

    To enable S3 file Uploads, I had to:

    • specify my region (us-west)
    • create an IAM user
    • add a Bucket Policy specifying that user as a Principal
    {
        "Version": "2008-10-17",
        "Statement": [
            {
                "Sid": "AllowFileUpload",
                "Effect": "Allow",
                "Principal": {
                    "AWS": "arn:aws:iam::XXXXXXX:user/instaswan"
                },
                "Action": [
                    "s3:GetObject",
                    "s3:PutObject",
                    "s3:PutObjectAcl"
                ],
                "Resource": [
                    "arn:aws:s3:::instaswan-dev",
                    "arn:aws:s3:::instaswan-dev/*"
                ]
            }
        ]
    }
    

    Be sure to include both the top-level and "/*" Resource, and include any other "Action" attributes you need.

提交回复
热议问题