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
- www.youtube.com/watch?v=cDj4LPTLR3o
- codeytek.com/how-to-create-a-user-and-bucket-amazon-web-services-aws/
- Step to upload from code: codeytek.com/course/upload-files-images-on-amazon-web-services-course/upload-files-images-on-amazon-web-services-content/file-uploads-on-amazon-web-services-aws-multer-s3-node-js-react-js-express-aws-sdk/
- cors: stackoverflow.com/questions/17533888/s3-access-control-allow-origin-header