> For the complete documentation index, see [llms.txt](https://docs.ionos.com/terraform-provider/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/terraform-provider/resources/s3_bucket.md).

# ionoscloud\_s3\_bucket

Manages [IONOS Object Storage Buckets](https://docs.ionos.com/cloud/storage-and-backup/ionos-object-storage) on IONOS CLOUD.

## Example Usage

```hcl

resource "ionoscloud_s3_bucket" "example" {
  name = "example"
  region = "eu-central-3"
  object_lock_enabled = true
  force_destroy = true
  
  tags = {
    key1 = "value1"
    key2 = "value2"
  }

  timeouts {
    create = "10m"
    delete = "10m"
  }
}

```

## Argument Reference

The following arguments are supported:

* `name` - (Required)\[string] The bucket name. \[ 3 .. 63 ] characters
* `region` - (Optional)\[string] Specifies the Region where the bucket will be created. Available regions are: `eu-central-3`, `eu-central-4`, `us-central-1`. Can be used only if the region is the same as the global region (set using `IONOS_S3_REGION` env var or `s3_region` provider attribute) or if the global region is unset. For using multiple different regions, please check the `Working with multiple regions/locations` section presented [here](/terraform-provider/index.md).
* `object_lock_enabled` - (Optional)\[bool] The object lock configuration status of the bucket. Must be `true` or `false`.
* `tags` - (Optional) A mapping of tags to assign to the bucket.
* `timeouts` - (Optional) Timeouts for this resource.
  * `create` - (Optional)\[string] Time to wait for the bucket to be created. Default is `10m`.
  * `delete` - (Optional)\[string] Time to wait for the bucket to be deleted. Default is `60m`.
* `force_destroy` - (Optional)\[bool] Default is `false`.By setting force\_destroy to true, you instruct Terraform to delete the bucket and all its contents during the terraform destroy process. This is particularly useful when dealing with buckets that contain objects, as it allows for automatic cleanup without requiring the manual deletion of objects beforehand. If force\_destroy is not set or is set to false, Terraform will refuse to delete a bucket that still contains objects. You must manually empty the bucket before Terraform can remove it.There is a significant risk of accidental data loss when using this attribute, as it irreversibly deletes all contents of the bucket. It's crucial to ensure that the bucket does not contain critical data before using force\_destroy.

## Attributes Reference

* `id` - (Computed) Name of the bucket

⚠️ **Note:** The name must be unique across all IONOS accounts in all IONOS Object Storage regions. The name should adhere to the following [restrictions](https://docs.ionos.com/cloud/storage-and-backup/ionos-object-storage/concepts/buckets#naming-conventions).

## Import

In Terraform v1.12.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `identity` attribute. For example:

```hcl
import {
  to = ionoscloud_s3_bucket.example
  identity = {
    id     = "bucket_name"
    region = "your_bucket_region"
  }
}

resource "ionoscloud_s3_bucket" "example" {
  ### Configuration omitted for brevity ###
}
```

### Identity Schema

#### Required

* `id` (String) Name of the bucket.
* `region` (String) Region where the bucket is located.

***

A bucket can be imported using the `bucket name` and the `region`:

```shell
terraform import ionoscloud_s3_bucket.example region:bucket_name
```

The `region` can be omitted, in which case the bucket will be imported from the default location: `eu-central-3`.

```shell
terraform import ionoscloud_s3_bucket.example bucket_name
```

## Query (List Resource)

Object Storage buckets can be listed using `terraform query` (requires Terraform 1.14+). List blocks must be placed in a dedicated `tfquery.hcl` file.

```hcl
list "ionoscloud_s3_bucket" "all" {
  provider         = ionoscloud
  include_resource = true
}
```

Filter by region:

```hcl
list "ionoscloud_s3_bucket" "eu_central" {
  provider         = ionoscloud
  include_resource = true
  config {
    filters = [{
      field_name  = "region"
      field_value = "eu-central-3"
    }]
  }
}
```

See the [ionoscloud\_s3\_bucket list resource](/terraform-provider/list-resources/s3_bucket.md) documentation for the full filter reference.


---

# 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:

```
GET https://docs.ionos.com/terraform-provider/resources/s3_bucket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
