Giter Club home page Giter Club logo

terraform-provider-bunny's Introduction

Bunny.Net Terraform Provider

This project is discontinued.

terraform-provider-bunny's People

Contributors

dependabot[bot] avatar fho avatar jspizziri avatar roman-dymov-faraway avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

terraform-provider-bunny's Issues

resource bunny_pullzone doesn't support import

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

$ terraform -v
Terraform v1.2.2
on darwin_amd64
+ provider registry.terraform.io/simplesurance/bunny v0.7.1

Affected Resource(s)

bunny_pullzone

Panic Output

$ terraform import bunny_pullzone.my-pullzone my-pullzone
bunny_pullzone.my-pullzone: Importing from ID "my-pullzone"...

│ Error: resource my-pullzone doesn't support import

Expected Behavior

I should be able to import the Bunny pullzone.

Actual Behavior

Pullzone cannot be imported.

Steps to Reproduce

  1. Create a pullzone in the UI
  2. Try to import it in Terraform

handle deleted pull-zones gracefully

When a Pull-Zone that exists in the terraform state failed is deleted on bunny side via the API or UI, "terraform plan" will fail with an 404 error that is returned by the bunny get pull zone API.

Handle this gracefully, interpret the error as the pull zone does not exist and unset it's id.

convert pull zone integer enums to strings

The pull zone resource has currently multiple enum fields that are of type integer.
Convert them to accept strings, string values are more self explanatory then cryptic numbers

Ensure fields in bunny-go struct message are set to nil instead of the types default value

When converting fields from a resource to the bunny-go struct, schema.ResourceData.Get() is called via the type get*Ptr helper functions.
schema.ResourceData.Get() returns the types default value if a field is not set.
Investigate if in the bunny-go message fields are set to their default value instead of nil when they are unset in the provider.
If this is the case, evaluate using GetOk instead.

see also the commit message: 5-stones@773b9be

edgerule: retry looking up guid to fix: edge rule created successfully, looking up its guid failed

Sometime after creating an Edge Rule, the returned Pull Zone does not contain the new Edge Rule yet.
According to the bunny.net support, concurrent changes to edge rules are currently not supported and ca be lost.
Terraform does by default do operations in parallel.
Possible workarounds:

  • serialize all changes to edge rules
  • After changing/creating an edge rule check if the wanted change was applied to the pull zone, if it wasn't retry the create/update operation

Bug: moving Edge-Rules between Pull-Zones does not work and breaks the state.

Terraform Version

[~]$ terraform -v
Terraform v1.0.2
on linux_amd64
+ provider registry.terraform.io/cloudflare/cloudflare v2.20.0
+ provider registry.terraform.io/hashicorp/vault v3.1.1
+ provider registry.terraform.io/simplesurance/bunny v0.5.0

Affected Resource(s)

  • bunny_edgerule

Terraform Configuration Files

Before

resource "bunny_edgerule" "my_rule" {
    pull_zone_id          = bunny_pullzone.domain1.id # or the ID directly
    action_type           = "redirect"
    action_parameter_1    = "https://otherdomain.com/something"
    trigger_matching_type = "any"
    trigger {
      pattern_matching_type = "any"
      type                  = "url"
      pattern_matches       = [
        "*://www.mydomain.com/something"
      ]
    }
}

Change the pull_zone_id

```hcl
resource "bunny_edgerule" "my_rule" {
    pull_zone_id          = bunny_pullzone.domain2.id # or the other ID directly
    action_type           = "redirect"
    action_parameter_1    = "https://otherdomain.com/something"
    trigger_matching_type = "any"
    trigger {
      pattern_matching_type = "any"
      type                  = "url"
      pattern_matches       = [
        "*://www.mydomain.com/something"
      ]
    }
}

Output

1 st apply:

  # bunny_edgerule.my_rule will be updated in-place
  ~ resource "bunny_edgerule" "schutzklick_de_redirects" {
        id                    = "dab21363-da60-434a-8f7d-d0bce6d9e158"
      ~ pull_zone_id          = XXXXXX -> XXXXXY
        # (5 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

During apply:

│ Error: updating edge rule failed: http-request to https://api.bunny.net/pullzone/XXXXXY/edgerules/addOrUpdate failed: Not Found (404)
│ 
│   with bunny_edgerule.my_rule,
│   on my_file.tf line XX, in resource "bunny_edgerule" "my_rule":
│   XX: resource "bunny_edgerule" "my_rule" {
│ 

After that each apply causes this error:

│ Error: pull zone has no edge rules
│ 
│   with bunny_edgerule.my_rule,
│   on my_file.tf line XX, in resource "bunny_edgerule" "my_rule":
│   XX: resource "bunny_edgerule" "my_rule" {
│ 

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

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.

Feature Request: DNS

Hi,

I suppose this might be contingent on simplesurance/bunny-go#26, but as I'm trying to migrate away from another DNS+CDN provider I have set up in terraform I would highly appreciate the ability to manage Bunny DNS zones and records via this module. Unfortunately I'm no Go developer so I wouldn't be able to make a PR for this.

storagezone: Adding new replication regions

Hello

I have created a storage zone and pull zone manually. Next, I want to import it to terraform.

Error: 1 error occurred:* 'replication_regions' can be added but not removed once the zone has been created.This error occurred when attempting to remove values ["NY" "SG" "SE" "DE" "UK"] from 'replication_regions'.

When I try to add these regions to terraform code, I have the next errors

Error: expected replication_regions to be one of [DE NY LA SG SYD], got GB

I think your need to add new bunny regions. What do we have?

Europe:

  • Falkenstein (DE)
  • London (GB)
  • Stockholm (SE)

North America:

  • Los Angeles (US). Your name is LA
  • New York (US). Your name is NY

Asia & Oceania:

  • Sydney (AU). Your name is SYD
  • Singapore (SG)

LATAM:

  • Sao Paulo (BR)

So we have the next regions: DE, LA, NY, SYD, SG and you need to add GB, SE, and BR regions. I am not a programmer, but think it could be added to

https://github.com/simplesurance/terraform-provider-bunny/blob/main/internal/provider/resource_storagezone.go#L65

Thank you

[Feature Request] Storage Zones

Great work here! I've not used the provider yet but I'm very interested in managing Storage Zone resources too. I'd be interested in contributing as well. I've never worked on a provider before (although I've used lots of them) nor have I worked with the Bunny API.

My questions are:

  1. Is this something you'd be interested in supporting?
  2. Is it feasible from your understanding of the APIs at play?
  3. Are you able to actively provide oversight, guidance, & merge/release?
  4. (unrelated) have you used the provider in its current state in a prod environment?

Thanks!

Support setting enable_geo_zone_* fields

Make the enable_geo_zone_* writable:

  • set computed to false
  • when a pull zone type is 1(volume) the enable_geo_zone fields are irrelevant, the Get API will always return a true value for them, either add a validation rule that ensures that enable_geo_zone_fields can only bet set to true if type is=1, or ignore them somehow when type is 1
  • in the admin panel there is only an option to enable the EU + US zone, the API has separate fields for it, that can also be set independently, when only enabling one of them the result shown in the webinterface is not clear, either combine them in terraform to also only have one EU+US geozone field or add a validation that both settings always needs to have the same values
  • according to the admin panel, >=1 geozone must always be enabled, it's possible to disable all in the api though, add a validation for it
  • add a testcase to set enable_geo_zone_* fields to false when type=0
  • add a testcase that ensures that enable_geo_zone-* can only be true or are ignored when type is 1

Support new Edge Rule Action Types

In the bunny.net web ui 2 new edge rule actions appeared that are not documented yet in the API documentation.
According to the support they have the following action ids:

  • Set Status Code = 14
  • Bypass Perma-Cache = 15

add support for them

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.