---
title: "Object Storage - Manage an Object Storage bucket with Terraform"
description: "- Terraform CLI installed"
url: https://docs.us.ovhcloud.com/en/storage-and-backup/object-storage/terraform
lang: en
---
> For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt.

# Object Storage - Manage an Object Storage bucket with Terraform

## Requirements

- [Terraform CLI](https://developer.hashicorp.com/terraform) installed

- Access to the [OVHcloud API](https://api.us.ovhcloud.com/) (create your login by consulting [this guide](https://docs.us.ovhcloud.com/en/manage-and-operate/api/first-steps.md))

- A [Public Cloud project](https://us.ovhcloud.com/public-cloud/) in your OVHcloud account

- Access to the OVHcloud [Terraform provider](http://registry.terraform.io/providers/ovh/ovh/latest), which is available in the official Terraform registry

  **Note:**

  You have a version >= 2.0 installed. You can follow our [How to Use Terraform](https://docs.us.ovhcloud.com/en/public-cloud/cross-functional/how-to-use-terraform.md) guide.

 

## Getting information about your API tokens

The “OVH provider” must be configured with a set of credentials:

- an `application_key`
- an `application_secret`
- a `consumer_key`

 

### Why?

Because, behind the scenes, the OVH Terraform provider makes requests to the OVHcloud APIs.

To retrieve this necessary information, please follow the tutorial [First steps with the OVHcloud APIs](https://docs.us.ovhcloud.com/en/manage-and-operate/api/first-steps.md).

Once you've successfully generated your OVHcloud tokens, keep them. You'll need to set them in the next few minutes.

The last piece of information you'll need is the `service_name`: this is the ID of your Public Cloud project.

 

### How do I get it?

In the Public Cloud section of the [OVHcloud Control Panel](https://manager.us.ovhcloud.com/), you can retrieve your service name ID using the `Copy to clipboard` button.

You can also use this information in Terraform resource definition files.

 

## Instructions

If you would like to access the provider's documentation on Object Storage, [click here](https://registry.terraform.io/providers/ovh/ovh/latest/docs/resources/cloud_project_storage).

 

### Configuration

First, create a `provider.tf` file with the minimum version, the US endpoint (“ovh-us”), and the keys you obtained in this guide.

Terraform:

```
terraform {
  required_providers {
    ovh = {
      source  = "ovh/ovh"
      version = "~> 2.1" # greater than or equal to 2.1
    }
  }
}

provider "ovh" {
  endpoint           = "ovh-us"
  application_key    = "<your_access_key>"
  application_secret = "<your_application_secret>"
  consumer_key       = "<your_consumer_key>"
}
```

Here, we've defined the `ovh-us` endpoint because we want to call the OVHcloud US API, but other endpoints exist, depending on your needs:

- `ovh-eu` pour OVHcloud Europe API
- `ovh-ca` pour OVHcloud North-America API

 

### Create a bucket

You can create a file named `object_storage_simple.tf` and write the following:

```

# Create an Object Storage bucket

resource "ovh_cloud_project_storage" "my_bucket" {
 service_name = "service_name" # Replace with your OVHcloud project ID
 region_name = "US-EAST-VA" # Replace with the desired region in uppercase.
  name = "object-storage-simple"
  versioning = {
    status = "enabled"
  }
  encryption = {
    sse_algorithm = "AES256"
  }
}
```

You can create your resource by entering the following command:

```
terraform apply
```

 

### Delete a bucket

You can delete your bucket and all the objects it contains by entering the following command:

**Note:**

This process may fail if the bucket contains locked objects. In this case, you'll need to delete these objects manually before you can run the command again.

```
terraform destroy
```

 

## Go further

Browse all the [Object Storage (S3™-compatible) guides](https://docs.us.ovhcloud.com/en/storage-and-backup/object-storage/landing-page-object-storage.md).

Browse the rest of the [OVHcloud US documentation](https://docs.us.ovhcloud.com/en/index.md) for guides on our other products and services.

Learn more about [Object Storage](https://us.ovhcloud.com/public-cloud/object-storage/) on the OVHcloud US website.

If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](https://us.ovhcloud.com/professional-services/) to get a quote and ask our Professional Services experts for a custom analysis of your project.

\*S3 is a trademark filed by Amazon Technologies, Inc. OVHcloud's service is not sponsored by, endorsed by, or otherwise affiliated with Amazon Technologies, Inc.
