terraform-provider-bunny icon indicating copy to clipboard operation
terraform-provider-bunny copied to clipboard

Allow forcing SSL on the default b-cdn.net hostname

Open softminus opened this issue 1 year ago • 0 comments

Terraform Version

sasha_work@myouren:~/src/download-server-terraform$ terraform -version
Terraform v1.3.9
on linux_amd64
+ provider registry.terraform.io/simplesurance/bunny v0.10.0
sasha_work@myouren:~/src/download-server-terraform$ 

Affected Resource(s)

  • bunny_hostname

Terraform Configuration Files

terraform {
  required_providers {
    bunny = {
      source = "registry.terraform.io/simplesurance/bunny"
    }
  }
}


provider "bunny" {
  api_key = "REDACTED"
}

resource "bunny_pullzone" "download_pullzone" {
  name       = "pz-terraform-test"
  type = 1
  follow_redirects = true
  verify_origin_ssl = true
  disable_cookies = true
  block_post_requests = true
  block_root_path_access = true
  origin_url = "https://xkcd.com"
}

resource "bunny_hostname" "bcdn_default_hostname" {
  hostname = "${bunny_pullzone.download_pullzone.name}.${bunny_pullzone.download_pullzone.cname_domain}"
  pull_zone_id = bunny_pullzone.download_pullzone.id
  force_ssl = true
}

Debug Output

https://gist.github.com/softminus/41bb3760844c97b9cf366e9669798840

Panic Output

No panic.

Expected Behavior

The "Force SSL" checkmark for the domain pz-terraform-test.b-cdn.net is set to ON, and no errors are elicited.

Actual Behavior

Terraform produces this error:

2023-02-28T17:07:57.120-0800 [ERROR] vertex "bunny_hostname.bcdn_default_hostname" error: could not add hostname
╷
│ Error: could not add hostname
│ 
│   with bunny_hostname.bcdn_default_hostname,
│   on main.tf line 25, in resource "bunny_hostname" "bcdn_default_hostname":
│   25: resource "bunny_hostname" "bcdn_default_hostname" {
│ 
│ http-request to https://api.bunny.net/pullzone/1240826/addHostname failed: Bad Request (400), pullzone.hostname_already_registered: Hostname, The hostname is already registered.

and the desired change is not executed: Screenshot from 2023-02-28 17-11-12

Steps to Reproduce

  1. create the main.tf file with the contents above (with a valid API key of course!)
  2. terraform apply

Important Factoids

Nothing atypical that I can tell.

References

No other github issues I could find.

softminus avatar Mar 01 '23 01:03 softminus