digitalocean_spaces_bucket

Provides a bucket resource for Spaces, DigitalOcean's object storage product.

The Spaces API was designed to be interoperable with Amazon's AWS S3 API. This allows users to interact with the service while using the tools they already know. Spaces mirrors S3's authentication framework and requests to Spaces require a key pair similar to Amazon's Access ID and Secret Key.

The authentication requirement can be met by either setting the SPACES_ACCESS_KEY_ID and SPACES_SECRET_ACCESS_KEY environment variables or the provider's spaces_access_id and spaces_secret_key arguments to the access ID and secret you generate via the DigitalOcean control panel. For example:

provider "digitalocean" {
  token             = var.digitalocean_token

  spaces_access_id  = var.access_id
  spaces_secret_key = var.secret_key
}

resource "digitalocean_spaces_bucket" "static-assets" {
  # ...
}

For more information, See An Introduction to DigitalOcean Spaces

Example Usage

Create a New Bucket

resource "digitalocean_spaces_bucket" "foobar" {
  name   = "foobar"
  region = "nyc3"
}

Create a New Bucket With CORS Rules

resource "digitalocean_spaces_bucket" "foobar" {
  name   = "foobar"
  region = "nyc3"

  cors_rule {
    allowed_headers = ["*"]
    allowed_methods = ["GET"]
    allowed_origins = ["*"]
    max_age_seconds = 3000
  }

  cors_rule {
    allowed_headers = ["*"]
    allowed_methods = ["PUT", "POST", "DELETE"]
    allowed_origins = ["https://www.example.com"]
    max_age_seconds = 3000
  }
}

Argument Reference

The following arguments are supported:

The cors_rule object supports the following:

The lifecycle_rule object supports the following:

At least one of expiration or noncurrent_version_expiration must be specified.

The expiration object supports the following:

The noncurrent_version_expiration object supports the following:

The versioning object supports the following:

Attributes Reference

The following attributes are exported:

Import

Buckets can be imported using the region and name attributes (delimited by a comma):

terraform import digitalocean_spaces_bucket.foobar `region`,`name`