AWS S3

Bucket Policy Example:

{
    "Version": "2012-10-17",
    "Id": "Policy1618732609027",
    "Statement": [
        {
            "Sid": "Stmt1618732601748",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:GetObject",
                "s3:DeleteObject"
            ],
            "Resource": "arn:aws:s3:::xxxx-upload-test/*"
        }
    ]
}

注意:

  • Principal一定要是*, 測試結果就算是用root IAM也不能上傳
  • Action一定要有 s3:PutObjectAcl

https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html

設定Bucket的CORS Policy

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "DELETE"
        ],
        "AllowedOrigins": [
            "http://www.example1.com"
        ],
        "ExposeHeaders": []
    },
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "DELETE"
        ],
        "AllowedOrigins": [
            "http://www.example2.com"
        ],
        "ExposeHeaders": []
    },
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]