Applying a CORS Configuration to a Bucket

You can enable cross-origin ressource sharing (CORS) on a bucket by applying a CORS configuration to it.

Applying a CORS Configuration to a Bucket Using AWS CLI

To apply a CORS configuration to a bucket, use the put-bucket-cors command following this syntax:

Request sample
$ aws s3api put-bucket-cors \
    --profile YOUR_PROFILE \
    --bucket BUCKET \
    --cors-configuration file://MY_CORS_CONFIG.json \

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • bucket: The name of the bucket to which you want to apply the CORS configuration.

  • cors-configuration: The path to the JSON configuration file containing the CORS rules you wish to apply to your bucket. For more information on how to write this file, see CORS Configuration Reference.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The CORS configuration is applied on your bucket.

Related Pages

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.