AWS AmazonS3: Reformat PutBucketCors example and link CORS docs
Summary
Reformatted the put-bucket-cors CLI example and JSON policy, and added a link to CORS guidance.
Security assessment
The added text documents CORS rules including GET from any domain; this is security-adjacent, but the change is formatting and linking rather than a vulnerability fix.
Evidence
The following `put-bucket-cors` example enables `PUT`, `POST`, and `DELETE` requests from _www.example.com_ , and enables `GET` requests from any domain.
Diff
diff --git a/AmazonS3/latest/developerguide/s3_example_s3_PutBucketCors_section.md b/AmazonS3/latest/developerguide/s3_example_s3_PutBucketCors_section.md index 3901c6a..4ec7baa 100644 --- a//AmazonS3/latest/developerguide/s3_example_s3_PutBucketCors_section.md +++ b//AmazonS3/latest/developerguide/s3_example_s3_PutBucketCors_section.md @@ -53 +53 @@ CLI -The following example enables `PUT`, `POST`, and `DELETE` requests from _www.example.com_ , and enables `GET` requests from any domain: +**To configure CORS for a bucket** @@ -54,0 +55,9 @@ The following example enables `PUT`, `POST`, and `DELETE` requests from _www.exa +The following `put-bucket-cors` example enables `PUT`, `POST`, and `DELETE` requests from _www.example.com_ , and enables `GET` requests from any domain. + + + aws s3api put-bucket-cors \ + --bucket amzn-s3-demo-bucket \ + --cors-configuration file://cors.json + + +Contents of `cors.json`: @@ -56 +64,0 @@ The following example enables `PUT`, `POST`, and `DELETE` requests from _www.exa - aws s3api put-bucket-cors --bucket amzn-s3-demo-bucket --cors-configuration file://cors.json @@ -58 +65,0 @@ The following example enables `PUT`, `POST`, and `DELETE` requests from _www.exa - cors.json: @@ -62,3 +69,11 @@ The following example enables `PUT`, `POST`, and `DELETE` requests from _www.exa - "AllowedOrigins": ["http://www.example.com"], - "AllowedHeaders": ["*"], - "AllowedMethods": ["PUT", "POST", "DELETE"], + "AllowedOrigins": [ + "http://www.example.com" + ], + "AllowedHeaders": [ + "*" + ], + "AllowedMethods": [ + "PUT", + "POST", + "DELETE" + ], @@ -66 +81,3 @@ The following example enables `PUT`, `POST`, and `DELETE` requests from _www.exa - "ExposeHeaders": ["x-amz-server-side-encryption"] + "ExposeHeaders": [ + "x-amz-server-side-encryption" + ] @@ -69,3 +86,9 @@ The following example enables `PUT`, `POST`, and `DELETE` requests from _www.exa - "AllowedOrigins": ["*"], - "AllowedHeaders": ["Authorization"], - "AllowedMethods": ["GET"], + "AllowedOrigins": [ + "*" + ], + "AllowedHeaders": [ + "Authorization" + ], + "AllowedMethods": [ + "GET" + ], @@ -76,0 +100,3 @@ The following example enables `PUT`, `POST`, and `DELETE` requests from _www.exa +This command produces no output. + +For more information, see [Using cross-origin resource sharing (CORS)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cors.html) in the _Amazon S3 User Guide_.