Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions internal/app/cf-terraforming/cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,13 @@ func TestResourceGenerationV5(t *testing.T) {
"cloudflare dns record simple": {identiferType: "zone", resourceType: "cloudflare_dns_record", testdataFilename: "cloudflare_dns_record"},
// "cloudflare dns record subdomain": {identiferType: "zone", resourceType: "cloudflare_dns_record", testdataFilename: "cloudflare_dns_record_subdomain"},
// "cloudflare dns record TXT SPF": {identiferType: "zone", resourceType: "cloudflare_dns_record", testdataFilename: "cloudflare_dns_record_txt_spf"},
"cloudflare dns zone transfers acl": {identiferType: "account", resourceType: "cloudflare_dns_zone_transfers_acl", testdataFilename: "cloudflare_dns_zone_transfers_acl"},
"cloudflare dns zone transfers incoming": {identiferType: "zone", resourceType: "cloudflare_dns_zone_transfers_incoming", testdataFilename: "cloudflare_dns_zone_transfers_incoming"},
"cloudflare dns zone transfers outgoing": {identiferType: "zone", resourceType: "cloudflare_dns_zone_transfers_outgoing", testdataFilename: "cloudflare_dns_zone_transfers_outgoing"},
"cloudflare dns zone transfers peer": {identiferType: "account", resourceType: "cloudflare_dns_zone_transfers_peer", testdataFilename: "cloudflare_dns_zone_transfers_peer"},
"cloudflare dns zone transfers tsig": {identiferType: "account", resourceType: "cloudflare_dns_zone_transfers_tsig", testdataFilename: "cloudflare_dns_zone_transfers_tsig"},
"cloudflare dns zone transfers acl": {identiferType: "account", resourceType: "cloudflare_dns_zone_transfers_acl", testdataFilename: "cloudflare_dns_zone_transfers_acl"},
"cloudflare dns zone transfers incoming": {identiferType: "zone", resourceType: "cloudflare_dns_zone_transfers_incoming", testdataFilename: "cloudflare_dns_zone_transfers_incoming"},
"cloudflare dns zone transfers outgoing": {identiferType: "zone", resourceType: "cloudflare_dns_zone_transfers_outgoing", testdataFilename: "cloudflare_dns_zone_transfers_outgoing"},
"cloudflare dns zone transfers peer": {identiferType: "account", resourceType: "cloudflare_dns_zone_transfers_peer", testdataFilename: "cloudflare_dns_zone_transfers_peer"},
"cloudflare dns zone transfers tsig": {identiferType: "account", resourceType: "cloudflare_dns_zone_transfers_tsig", testdataFilename: "cloudflare_dns_zone_transfers_tsig"},
"cloudflare notification policy": {identiferType: "account", resourceType: "cloudflare_notification_policy", testdataFilename: "cloudflare_notification_policy"},
"cloudflare notification policy webhooks": {identiferType: "account", resourceType: "cloudflare_notification_policy_webhooks", testdataFilename: "cloudflare_notification_policy_webhooks"},
// "cloudflare ruleset (ddos_l7)": {identiferType: "zone", resourceType: "cloudflare_ruleset", testdataFilename: "cloudflare_ruleset_zone_ddos_l7"},
// "cloudflare ruleset (http_log_custom_fields)": {identiferType: "zone", resourceType: "cloudflare_ruleset", testdataFilename: "cloudflare_ruleset_zone_http_log_custom_fields"},
// "cloudflare ruleset (http_ratelimit)": {identiferType: "zone", resourceType: "cloudflare_ruleset", testdataFilename: "cloudflare_ruleset_zone_http_ratelimit"},
Expand Down
135 changes: 135 additions & 0 deletions testdata/cloudflare/v5/cloudflare_notification_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
Accept:
- application/json
X-Stainless-Arch:
- arm64
X-Stainless-Lang:
- go
X-Stainless-Os:
- MacOS
X-Stainless-Package-Version:
- 4.1.0
X-Stainless-Retry-Count:
- "0"
X-Stainless-Runtime:
- go
X-Stainless-Runtime-Version:
- go1.24.0
url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/alerting/v3/policies
method: GET
response:
body: |
{
"errors": [],
"messages": [],
"result": [
{
"alert_type": "universal_ssl_event_type",
"conditions": {},
"created": "2022-03-21T23:45:41.781264Z",
"description": "test description update",
"enabled": true,
"filters": {},
"id": "58a3e747dc764237bcc6fcecc236cb85",
"mechanisms": {
"email": [
{
"id": "[email protected]"
}
]
},
"modified": "2024-11-05T21:30:27.96569Z",
"name": "foo2"
},
{
"alert_type": "zone_aop_custom_certificate_expiration_type",
"conditions": {},
"created": "2022-08-08T02:30:36.597653Z",
"description": "This notification is automatically set by Cloudflare",
"enabled": true,
"filters": {},
"id": "e1e9661596144e8db32722512a519daf",
"mechanisms": {
"email": [
{
"id": "[email protected]"
},
{
"id": "[email protected]"
},
{
"id": "[email protected]"
},
{
"id": "[email protected]"
}
]
},
"modified": "2022-08-08T02:30:36.597653Z",
"name": "Default notification"
},
{
"alert_type": "billing_usage_alert",
"conditions": {
">=": [
{
"var": "worker_requests"
},
100
]
},
"created": "2022-08-17T04:02:30.929892Z",
"description": "test description",
"enabled": true,
"filters": {
"limit": [
"100"
],
"product": [
"worker_requests"
]
},
"id": "0b20eef144264cb7951921ec29361a0b",
"mechanisms": {
"email": [
{
"id": "[email protected]"
}
]
},
"modified": "2022-08-17T04:02:30.929892Z",
"name": "workers usage notification"
}
],
"success": true
}
headers:
Cache-Control:
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Cf-Auditlog-Id:
- 01954e0f-e6fe-797b-8524-123d9e9cdb2f
Connection:
- keep-alive
Content-Type:
- application/json
Expires:
- Sun, 25 Jan 1981 05:00:00 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
- accept-encoding
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
status: 200 OK
code: 200
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
Accept:
- application/json
X-Stainless-Arch:
- arm64
X-Stainless-Lang:
- go
X-Stainless-Os:
- MacOS
X-Stainless-Package-Version:
- 4.1.0
X-Stainless-Retry-Count:
- "0"
X-Stainless-Runtime:
- go
X-Stainless-Runtime-Version:
- go1.24.0
url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/alerting/v3/destinations/webhooks
method: GET
response:
body: |
{
"errors": [],
"messages": [],
"result": [
{
"created_at": "2025-03-12T17:31:52.88075Z",
"id": "1dbdd679dc554259b0d1928b787d0dab",
"last_failure": null,
"last_success": null,
"name": "my webhooks destination for receiving Cloudflare notifications",
"type": "generic",
"url": "https://httpbin.org/post"
}
],
"success": true
}
headers:
Cache-Control:
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Cf-Auditlog-Id:
- 01954e0f-e6fe-797b-8524-123d9e9cdb2f
Connection:
- keep-alive
Content-Type:
- application/json
Expires:
- Sun, 25 Jan 1981 05:00:00 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
- accept-encoding
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
status: 200 OK
code: 200
duration: ""
94 changes: 41 additions & 53 deletions testdata/terraform/v5/cloudflare_notification_policy/test.tf
Original file line number Diff line number Diff line change
@@ -1,63 +1,51 @@
resource "cloudflare_notification_policy" "terraform_managed_resource" {
account_id = "023e105f4ecef8ad9ca31a8372d0c353"
alert_type = "access_custom_certificate_expiration_type"
enabled = true
resource "cloudflare_notification_policy" "terraform_managed_resource_0" {
account_id = "f037e56e89293a057740de681ac9abbe"
alert_type = "universal_ssl_event_type"
description = "test description update"
enabled = true
name = "foo2"
filters = {}
mechanisms = {
email = [{
id = "[email protected]"
}]
pagerduty = [{

}]
webhooks = [{
}
}

resource "cloudflare_notification_policy" "terraform_managed_resource_1" {
account_id = "f037e56e89293a057740de681ac9abbe"
alert_type = "zone_aop_custom_certificate_expiration_type"
description = "This notification is automatically set by Cloudflare"
enabled = true
name = "Default notification"
filters = {}
mechanisms = {
email = [{
id = "[email protected]"
}, {
id = "[email protected]"
}, {
id = "[email protected]"
}, {
id = "[email protected]"
}]
}
name = "SSL Notification Event Policy"
alert_interval = "30m"
description = "Something describing the policy."
}

resource "cloudflare_notification_policy" "terraform_managed_resource_2" {
account_id = "f037e56e89293a057740de681ac9abbe"
alert_type = "billing_usage_alert"
description = "test description"
enabled = true
name = "workers usage notification"
filters = {
actions = ["string"]
affected_asns = ["string"]
affected_components = ["string"]
affected_locations = ["string"]
airport_code = ["string"]
alert_trigger_preferences = ["string"]
alert_trigger_preferences_value = ["string"]
enabled = ["string"]
environment = ["string"]
event = ["string"]
event_source = ["string"]
event_type = ["string"]
group_by = ["string"]
health_check_id = ["string"]
incident_impact = ["INCIDENT_IMPACT_NONE"]
input_id = ["string"]
insight_class = ["string"]
limit = ["string"]
logo_tag = ["string"]
megabits_per_second = ["string"]
new_health = ["string"]
new_status = ["string"]
packets_per_second = ["string"]
pool_id = ["string"]
pop_names = ["string"]
product = ["string"]
project_id = ["string"]
protocol = ["string"]
query_tag = ["string"]
requests_per_second = ["string"]
selectors = ["string"]
services = ["string"]
slo = ["99.9"]
status = ["string"]
target_hostname = ["string"]
target_ip = ["string"]
target_zone_name = ["string"]
traffic_exclusions = ["security_events"]
tunnel_id = ["string"]
tunnel_name = ["string"]
where = ["string"]
zones = ["string"]
limit = ["100"]
product = ["worker_requests"]
}
mechanisms = {
email = [{
id = "[email protected]"
}]
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "cloudflare_notification_policy_webhooks" "terraform_managed_resource" {
account_id = "023e105f4ecef8ad9ca31a8372d0c353"
name = "Slack Webhook"
url = "https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"
secret = "secret"
account_id = "f037e56e89293a057740de681ac9abbe"
name = "my webhooks destination for receiving Cloudflare notifications"
url = "https://httpbin.org/post"
}

Loading