> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/s3-object-storage/settings/bucket-policy/bucket-policy-examples.md).

# Bucket Policy Examples

Following are a few examples of common use cases and their corresponding bucket policy configurations.

## Grant full control of the bucket to other users

To grant full control over a bucket and its objects to other IONOS S3 Object Storage users:

```bash
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Grant Full Control",
      "Effect": "Allow",
      "Principal": {
        "CanonicalUser": ["CANONICAL_USER_ID_1", "CANONICAL_USER_ID_2"]
      },
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::my-bucket",
        "arn:aws:s3:::my-bucket/*"
      ]
    }
  ]
}
```

## Grant read-only access to a specific prefix

To grant read-only access to objects within a specific prefix of a bucket to other IONOS S3 Object Storage users:

```bash
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "GrantReadOnlyAccessToPrefix",
      "Effect": "Allow",
      "Principal": {
         "CanonicalUser": ["CANONICAL_USER_ID_1", "CANONICAL_USER_ID_2"]
      },
      "Action": [
        "s3:GetObject",
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::my-bucket/prefix/*",
        "arn:aws:s3:::my-bucket"
      ],
      "Condition": {
        "StringLike": {
          "s3:prefix": [
            "prefix/*"
          ]
        }
      }
    }
  ]
}
```

## Public read access

To allow read access to certain objects within a bucket while keeping other objects private:

```bash
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicRead",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::example-bucket/public/*"
    }
  ]
}
```

## Restrict access to specific IP addresses

To restrict all users from performing any S3 operations within the designated bucket, unless the request is initiated from the specified range of IP addresses:

```bash
{
    "Version": "2012-10-17",
    "Id": "Restrict access to specific IP addresses",
    "Statement": [
        {
            "Sid": "Restrict access to specific IP addresses",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::MY-BUCKET",
                "arn:aws:s3:::MY-BUCKET/*"
            ],
            "Condition": {
                "NotIpAddress": {
                    "aws:SourceIp": "123123.123.0/24"
                }
            }
        }
    ]
}
```

For more information on bucket policy configurations, see [<mark style="color:blue;">Bucket Policy</mark>](/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/s3-object-storage/settings/bucket-policy.md), supported [<mark style="color:blue;">bucket and object</mark>](https://api.ionos.com/docs/s3/v2/#tag/Policy/operation/PutBucketPolicy) actions and condition values, and [<mark style="color:blue;">Retrieve Canonical User ID</mark>](/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/s3-object-storage/how-tos/retrieve-user-ids.md#retrieve-canonical-user-id).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ionos.com/cloud/~/revisions/bM7yG7XCmGE9IxWqMpBu/managed-services/s3-object-storage/settings/bucket-policy/bucket-policy-examples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
