I want to create a space bucket using Terraform. Here is my attempt:

provider "digitalocean" {
  token = var.do_token
  spaces_access_id = var.do_spaces_client_id
  spaces_secret_key = var.do_spaces_secret_key
}

resource "digitalocean_spaces_bucket" "shop_images" {
  name = "shop_images"
  region = var.do_region
  acl = "public-read"
}

The token and spaces client id/secret key work as I can create droplet but not spaces. The do_region variable is fra1.

The error I get in return is:

digitalocean_spaces_bucket.shop_images: Creating...
2020/05/15 09:51:43 [DEBUG] digitalocean_spaces_bucket.shop_images: apply errored, but we're indicating that via the Error pointer rather than returning it: Error creating Spaces bucket: InvalidRequest: Malformed request
        status code: 400, request id: , host id: 
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2020/05/15 09:51:43 [TRACE] EvalMaybeTainted: digitalocean_spaces_bucket.shop_images encountered an error during creation, so it is now marked as tainted
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/05/15 09:51:43 [TRACE] EvalWriteState: removing state object for digitalocean_spaces_bucket.shop_images
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalApplyProvisioners
2020/05/15 09:51:43 [TRACE] EvalApplyProvisioners: digitalocean_spaces_bucket.shop_images has no state, so skipping provisioners
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2020/05/15 09:51:43 [TRACE] EvalMaybeTainted: digitalocean_spaces_bucket.shop_images encountered an error during creation, so it is now marked as tainted
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/05/15 09:51:43 [TRACE] EvalWriteState: removing state object for digitalocean_spaces_bucket.shop_images
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalIf
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalIf
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalWriteDiff
2020/05/15 09:51:43 [TRACE] <root>: eval: *terraform.EvalApplyPost
2020/05/15 09:51:43 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: Error creating Spaces bucket: InvalidRequest: Malformed request
        status code: 400, request id: , host id: 
2020/05/15 09:51:43 [ERROR] <root>: eval: *terraform.EvalSequence, err: Error creating Spaces bucket: InvalidRequest: Malformed request
        status code: 400, request id: , host id: 
2020/05/15 09:51:43 [TRACE] [walkApply] Exiting eval tree: digitalocean_spaces_bucket.shop_images
2020/05/15 09:51:43 [TRACE] vertex "digitalocean_spaces_bucket.shop_images": visit complete
2020/05/15 09:51:43 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2020/05/15 09:51:43 [TRACE] dag/walk: upstream of "provider.digitalocean (close)" errored, so skipping
2020/05/15 09:51:43 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020/05/15 09:51:43 [TRACE] statemgr.Filesystem: not making a backup, because the new snapshot is identical to the old
2020/05/15 09:51:43 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2020/05/15 09:51:43 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate

I have no clue what is blocking here.

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.

×
3 answers

The error being returned by the API here is unclear, but the cause is the underscore (_) in the Space name. In the control panel, when creating a new Space, it notes that names must be between 3 and 63 characters long and may only contain letters, numbers, dots (.), and dashes (-).

I’m not certain but my bet is that this bucket already exists. I believe like on aws the names must be unique for each data center. And shop_images seem very generic not to already exist. Try prefixing the name with your project’s name or slug.

Thanks @aboeglin67 and @asb. You were both right. I did at first had the problem with the underscore but then I also had the problem with the non-unique spaces name. I thought that names would not need to be unique if you link them to a project but I guess it is not the case.

Thank you very much.

Submit an Answer