Web Development/General Tech Knowledges

How to Set up S3 bucket

Nomad Kim 2021. 4. 11. 15:59

The steps to take

1. Create an account on console.aws.amazon.com

2. Create a user and a new bucket. Note the accessKeyId, the secretAccessKey and ARN

3. Add policy to the bucket and the user, add CORS to the bucket.

 

1) policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AddCannedAcl",
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:my arn"
                ]
            },
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::onclick/*"
            ],
            "Condition": {
                "StringEquals": {
                    "s3:x-amz-acl": [
                        "public-read"
                    ]
                }
            }
        }
    ]
}

2) cors

S3 now expects the rules to be in Array Json format.

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]

 

 

Source from