This project is discontinued.
simplesurance / terraform-provider-bunny Goto Github PK
View Code? Open in Web Editor NEWbunny.net CDN Terraform Provider
License: Mozilla Public License 2.0
bunny.net CDN Terraform Provider
License: Mozilla Public License 2.0
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 -v
Terraform v1.2.2
on darwin_amd64
+ provider registry.terraform.io/simplesurance/bunny v0.7.1
bunny_pullzone
$ 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
I should be able to import the Bunny pullzone.
Pullzone cannot be imported.
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.
According to the admin panel the name
field is only allowed to contain "(letters and numbers only)" (https://panel.bunny.net/pullzones/add).
Add a validation function that ensures it.
Sometimes resources or fields are named pullzone
in other occurrences pull_zone
, align the naming.
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
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
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:
Add support for adding/removing custom hostnames to a Pull Zone:
[~]$ 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
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"
]
}
}
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" {
│
When an edge rule has multiple triggers and an attribute of one of them changes, "terraform plan" shows a diff where all triggers are recreated.
The diff should only show the changed attributes instead.
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$
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
}
https://gist.github.com/softminus/41bb3760844c97b9cf366e9669798840
No panic.
The "Force SSL" checkmark for the domain pz-terraform-test.b-cdn.net
is set to ON, and no errors are elicited.
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:
main.tf
file with the contents above (with a valid API key of course!)terraform apply
Nothing atypical that I can tell.
No other github issues I could find.
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.
The origin_url attribute of storage zones might be unused by the bunny API endpoint.
See: 5-stones#1 (comment)
Figure out if it is used, if not remove it
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:
North America:
Asia & Oceania:
LATAM:
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
Thank you
Make use of the DiffSuppressOnRefresh
function that was introduced recently to the terraform-sdk.
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:
Thanks!
Add support for EdgeRules (https://docs.bunny.net/reference/pullzonepublic_addedgerule)
Make the enable_geo_zone_*
writable:
Add support for adding/removing custom certs to a pull zone
https://docs.bunny.net/reference/pullzonepublic_addcertificate
When deleting a pull-zone that was already deleted on the provider side, the operation fails.
A warning should be logged instead and the operation should succeed.
Related: #14
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:
add support for them
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.