Question

digitalocean_spaces_bucket vs digitalocean_spaces_bucket_object providers in terraform?

Posted December 23, 2020 354 views
Terraform

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

digitalocean_spaces_bucket is used to create a new Space (bucket in S3 terminology) and manage Space-wide settings like CORS policies. digitalocean_spaces_bucket_object is for adding an individual file to the Space.

They can be used together. For example:

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

resource "digitalocean_spaces_bucket_object" "image" {
  region = digitalocean_spaces_bucket.static.region
  bucket = digitalocean_spaces_bucket.static.name
  key    = "remote/path/to/image.png"
  source = "local/path/to/image.png
}

digitalocean_spaces_bucket_object can also be used with a Space created outside of Terraform by specifying its name and region rather than referencing a digitalocean_spaces_bucket