> 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/backup-and-storage/ionos-object-storage/s3-tools/awsterraform/awsterraform-examples.md).

# Examples

### Object Storage Bucket Examples

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

* The `access_key` and `secret_key` can be retrieved in the DCD, go to **Menu** > **Storage** > **IONOS CLOUD Object Storage** > **Key management**.
* For the list of <code class="expression">space.vars.ionos\_cloud\_object\_storage</code> Service endpoints, see [<mark style="color:blue;">Endpoints</mark>](/cloud/backup-and-storage/ionos-object-storage/endpoints.md).
  {% endhint %}

```hcl
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.50.0"
    }
  }
}

provider "aws" {
  region                      = "de"
  access_key                  = "access_key_here"
  secret_key                  = "secret_key_here"
  # all these checks need to be skipped for an s3 external provider
  skip_credentials_validation = true
  skip_requesting_account_id  = true
  skip_region_validation      = true
  endpoints {
     s3 = "https://s3-eu-central-1.ionoscloud.com"
  }
}

resource "aws_s3_bucket" "tf_bucket_name_here" {
  bucket = "unique_name_here"
  tags = {
    Name        = "my bucket name tag"
    Environment = "dev"
  }
}
```

### Object Storage bucket with Object Lock enabled

```hcl
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.50.0"
    }
  }
}

provider "aws" {
  region                      = "de"
  access_key                  = "access_key_here"
  secret_key                  = "secret_key_here"
  # all these checks need to be skipped for an s3 external provider
  skip_credentials_validation = true
  skip_requesting_account_id  = true
  skip_region_validation      = true
  endpoints {
     s3 = "https://s3-eu-central-1.ionoscloud.com"
  }
}

resource "aws_s3_bucket" "backup_bucket" {
  bucket = "unique_name_here"
  tags = {
    Name        = "backup bucket"
    Environment = "dev"
  }
 object_lock_configuration {
    object_lock_enabled = "Enabled"
    rule {
        default_retention {
            days  = 10
            mode  = "COMPLIANCE"
          }
      }
  }
}
```

### Object Storage bucket with Versioning enabled

```hcl
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.50.0"
    }
  }
}

provider "aws" {
  region                      = "de"
  access_key                  = "access_key_here"
  secret_key                  = "secret_key_here"
  # all these checks need to be skipped for an s3 external provider
  skip_credentials_validation = true
  skip_requesting_account_id  = true
  skip_region_validation      = true
  endpoints {
     s3 = "https://s3.eu-central-1.ionoscloud.com"
  }
}
resource "aws_s3_bucket" "example" {
  bucket = "unique_name_here"
}

resource "aws_s3_bucket_versioning" "example" {
  bucket = aws_s3_bucket.example.id

  versioning_configuration {
    status = "Enabled"
  }
}
```


---

# 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/backup-and-storage/ionos-object-storage/s3-tools/awsterraform/awsterraform-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.
