# Bucket Policy

This document provides instructions to manage [<mark style="color:blue;">Bucket Policy</mark>](https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/s3-object-storage/settings/bucket-policy) using the command-line tool. Additionally, these tasks can also be performed using the [<mark style="color:blue;">web console</mark>](https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/settings/bucket-policy#web-console) and [<mark style="color:blue;">IONOS S3 Object Storage API</mark>](https://api.ionos.com/docs/s3/v2/#tag/Policy/operation/PutBucketPolicy).

{% hint style="info" %}
**Prerequisites:**

* Set up the AWS CLI by following the [<mark style="color:blue;">installation instructions</mark>](https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/s3-object-storage/s3-tools/awscli).
* Make sure to consider the supported [<mark style="color:blue;">S3 Endpoints</mark>](https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/s3-object-storage/s3-endpoints).
  {% endhint %}

## Commands

To create a file `policy.json` with the JSON policy. For more information, see [<mark style="color:blue;">Bucket Policy Examples</mark>](https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/s3-object-storage/settings/bucket-policy/bucket-policy-examples).

To apply a bucket policy to a bucket:

```
aws s3api put-bucket-policy --bucket my-bucket --policy file://policy.json --endpoint-url https://s3-eu-central-2.ionoscloud.com

```

To save a bucket policy to file:

```
aws s3api get-bucket-policy --bucket my-bucket --endpoint-url https://s3-eu-central-2.ionoscloud.com > policy.json

```

To delete the bucket policy:

```
aws s3api delete-bucket-policy --bucket my-bucket --endpoint-url https://s3-eu-central-2.ionoscloud.com

```
