Set CORS rule on Bucket level
Set CORS rules for each bucket when it gets created.
s3.Bucket("<name>").Cors().put(CORSConfiguration={
'CORSRules': [
{
'ID': 'websiteaccess',
'AllowedHeaders': [
"amz-sdk-invocation-id",
"amz-sdk-request",
"authorization",
"content-type",
"x-amz-content-sha256",
"x-amz-copy-source",
"x-amz-date",
"x-amz-user-agent",
"content-md5"
],
'AllowedMethods': [
"GET",
"PUT",
"POST",
"DELETE"
],
'AllowedOrigins': [
"<domain>"
],
'ExposeHeaders': [
"Etag",
],
'MaxAgeSeconds': 100
},
]
})