# 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 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>](https://docs.ionos.com/cloud/backup-and-storage/ionos-object-storage/endpoints).
  {% 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: 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/cloud/backup-and-storage/ionos-object-storage/s3-tools/awsterraform/awsterraform-examples.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.
