-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set-cors-policy
command
#47
Comments
I need a CORS-enabled bucket today in order to experiment more with |
CORS policies can look like this: [
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"https://simonwillison.net/"
],
"ExposeHeaders": []
}
] Or this - from https://grrr.tech/posts/2022/cors-s3-bucket/ {
"CORSRules": [
{
"AllowedOrigins": ["*"],
"AllowedHeaders": ["*"],
"AllowedMethods": ["GET", "POST"]
}
]
} Full documentation here: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CORSRule.html - which lists the following options:
|
I could do this as a I'm leaning towards that second option because there are a bunch of different options here and it feels like a command would make it easier to express them. But I could always do |
Boto documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-example-configuring-buckets.html#set-a-bucket-cors-configuration # Define the configuration rules
s3 = boto3.client("s3")
s3.put_bucket_cors(Bucket="BUCKET_NAME", CORSConfiguration={
"CORSRules": [
{
"AllowedHeaders": ["Authorization"],
"AllowedMethods": ["GET", "PUT"],
"AllowedOrigins": ["*"],
"ExposeHeaders": ["GET", "PUT"],
"MaxAgeSeconds": 3000,
}
]
}) Though that example looks misleading to me - |
Filed a PR to fix that documentation example: |
Moro boto documentation:
Interesting to note that while the list of |
Design for this command:
|
If you don't provide a |
I ran my prototype:
I added a
|
Forgot to make the bucket public. Trying this instead:
|
https://s3.amazonaws.com/simonwillison-cors-allowed-public/click_default_group-1.2.2-py3-none-any.whl is now a file I can download. It looks like that is setting the right CORS headers, provided you send an
|
For setting the bucket-level CORS policy on newly created (or maybe even existing?) buckets.
See https://til.simonwillison.net/aws/s3-cors
The text was updated successfully, but these errors were encountered: