Applying a Policy to Your Bucket
You can apply a policy to your bucket. A bucket policy enables you, for example, to define which users or groups can access the objects within it, potentially limiting actions to read-only or granting full permissions to modify or delete the contents. For more information, see About Policies.
If a policy has already been applied to your bucket, this command will replace it with a new one.
Applying a Policy to Your Bucket using AWS CLI (s3api)
To apply a policy to a bucket, use the put-bucket-policy command following this syntax:
$ aws s3api put-bucket-policy \
--profile YOUR_PROFILE \
--bucket BUCKET \
--confirm-remove-self-bucket-access | --no-confirm-remove-self-bucket-access \
--policy file://path/to/policy/file \
--endpoint https://oos.eu-west-2.outscale.com
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 policy. -
(optional)
confirm-remove-self-bucket-access
|no-confirm-remove-self-bucket-access
: If set toconfirm-remove-self-bucket-access
it is confirmed that you want to remove your permissions to change this bucket policy in the future. -
policy
: The path to the JSON configuration file containing the bucket policy. For more information on how to write this file, see Bucket Policy Configuration Reference. -
endpoint
: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.
The policy is applied to the 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.