Skip to content

Commit 2c44d36

Browse files
authored
feat(logpush_job): v4 to v5 migrations (#16)
* initial code changes after Claude ran * account for kind changes and v4 defaults after running provider tests * ensure http_requests (zone level) and audit_logs (account level) are tested in int tests * remove 0 deletion from max_upload_* values * remove references to 0 deletion * first pass on e2e tests * update logpush to delete instant-logs for kind * update logpush with new function signatures * v4 empty string and zero val to null defaults * add false default for cve option * remove logpush_job e2e test for instant-logs * update zone level resource to use appropriate dataset
1 parent 806c490 commit 2c44d36

File tree

10 files changed

+1601
-51
lines changed

10 files changed

+1601
-51
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
variable "cloudflare_account_id" {
2+
description = "Cloudflare account ID"
3+
type = string
4+
}
5+
6+
variable "cloudflare_zone_id" {
7+
description = "Cloudflare zone ID"
8+
type = string
9+
}
10+
11+
# Minimal logpush job
12+
resource "cloudflare_logpush_job" "minimal" {
13+
account_id = var.cloudflare_account_id
14+
dataset = "audit_logs"
15+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
16+
}
17+
18+
# Job with logpull_options only (no output_options)
19+
resource "cloudflare_logpush_job" "with_logpull_options" {
20+
account_id = var.cloudflare_account_id
21+
dataset = "audit_logs"
22+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
23+
logpull_options = "fields=ClientIP,EdgeStartTimestamp&timestamps=unixnano"
24+
}
25+
26+
# Job with output_options block
27+
resource "cloudflare_logpush_job" "with_output_options" {
28+
account_id = var.cloudflare_account_id
29+
dataset = "audit_logs"
30+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
31+
32+
output_options = {
33+
batch_prefix = "{"
34+
batch_suffix = "}"
35+
field_names = ["ClientIP", "EdgeStartTimestamp"]
36+
output_type = "ndjson"
37+
cve_2021_44228 = false
38+
field_delimiter = ","
39+
record_prefix = "{"
40+
record_suffix = "}\n"
41+
timestamp_format = "unixnano"
42+
sample_rate = 1
43+
}
44+
}
45+
46+
# Job with cve20214428 field (should be renamed)
47+
resource "cloudflare_logpush_job" "with_cve_field" {
48+
account_id = var.cloudflare_account_id
49+
dataset = "audit_logs"
50+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
51+
52+
output_options = {
53+
output_type = "ndjson"
54+
cve_2021_44228 = true
55+
field_delimiter = ","
56+
record_prefix = "{"
57+
record_suffix = "}\n"
58+
timestamp_format = "unixnano"
59+
sample_rate = 1
60+
}
61+
}
62+
63+
# Job with edge kind (should be preserved)
64+
resource "cloudflare_logpush_job" "edge_logs" {
65+
zone_id = var.cloudflare_zone_id
66+
dataset = "http_requests"
67+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
68+
kind = "edge"
69+
}
70+
71+
# Job with "" kind (should be preserved)
72+
resource "cloudflare_logpush_job" "empty_kind" {
73+
zone_id = var.cloudflare_zone_id
74+
dataset = "http_requests"
75+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
76+
kind = ""
77+
}
78+
79+
# Full featured job with all transformations
80+
resource "cloudflare_logpush_job" "full" {
81+
zone_id = var.cloudflare_zone_id
82+
dataset = "http_requests"
83+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
84+
kind = "edge"
85+
enabled = true
86+
name = "my-logpush-job"
87+
frequency = "high"
88+
89+
output_options = {
90+
batch_prefix = "{"
91+
batch_suffix = "}"
92+
field_names = ["ClientIP", "EdgeStartTimestamp", "RayID"]
93+
output_type = "ndjson"
94+
sample_rate = 1.0
95+
timestamp_format = "unixnano"
96+
cve_2021_44228 = true
97+
field_delimiter = ","
98+
record_prefix = "{"
99+
record_suffix = "}\n"
100+
}
101+
}
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
{
2+
"version": 4,
3+
"terraform_version": "1.5.0",
4+
"serial": 1,
5+
"lineage": "test-logpush-job-lineage",
6+
"outputs": {},
7+
"resources": [
8+
{
9+
"mode": "managed",
10+
"type": "cloudflare_logpush_job",
11+
"name": "minimal",
12+
"provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
13+
"instances": [
14+
{
15+
"schema_version": 0,
16+
"attributes": {
17+
"id": "1",
18+
"account_id": "f037e56e89293a057740de681ac9abbe",
19+
"dataset": "audit_logs",
20+
"destination_conf": "https://logpush-receiver.sd.cfplat.com",
21+
"enabled": true
22+
}
23+
}
24+
]
25+
},
26+
{
27+
"mode": "managed",
28+
"type": "cloudflare_logpush_job",
29+
"name": "with_logpull_options",
30+
"provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
31+
"instances": [
32+
{
33+
"schema_version": 0,
34+
"attributes": {
35+
"id": "2",
36+
"account_id": "f037e56e89293a057740de681ac9abbe",
37+
"dataset": "http_requests",
38+
"destination_conf": "https://logpush-receiver.sd.cfplat.com",
39+
"enabled": true,
40+
"logpull_options": "fields=ClientIP,EdgeStartTimestamp&timestamps=unixnano"
41+
}
42+
}
43+
]
44+
},
45+
{
46+
"mode": "managed",
47+
"type": "cloudflare_logpush_job",
48+
"name": "with_output_options",
49+
"provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
50+
"instances": [
51+
{
52+
"schema_version": 0,
53+
"attributes": {
54+
"id": "3",
55+
"account_id": "f037e56e89293a057740de681ac9abbe",
56+
"dataset": "http_requests",
57+
"destination_conf": "https://logpush-receiver.sd.cfplat.com",
58+
"enabled": true,
59+
"output_options": {
60+
"batch_prefix": "{",
61+
"batch_suffix": "}",
62+
"field_names": ["ClientIP", "EdgeStartTimestamp"],
63+
"output_type": "ndjson",
64+
"cve_2021_44228": false,
65+
"field_delimiter": ",",
66+
"record_prefix": "{",
67+
"record_suffix": "}\n",
68+
"timestamp_format": "unixnano",
69+
"sample_rate": 1
70+
}
71+
}
72+
}
73+
]
74+
},
75+
{
76+
"mode": "managed",
77+
"type": "cloudflare_logpush_job",
78+
"name": "with_cve_field",
79+
"provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
80+
"instances": [
81+
{
82+
"schema_version": 0,
83+
"attributes": {
84+
"id": "4",
85+
"account_id": "f037e56e89293a057740de681ac9abbe",
86+
"dataset": "http_requests",
87+
"destination_conf": "https://logpush-receiver.sd.cfplat.com",
88+
"enabled": true,
89+
"output_options": {
90+
"cve_2021_44228": true,
91+
"output_type": "ndjson",
92+
"field_delimiter": ",",
93+
"record_prefix": "{",
94+
"record_suffix": "}\n",
95+
"timestamp_format": "unixnano",
96+
"sample_rate": 1
97+
}
98+
}
99+
}
100+
]
101+
},
102+
{
103+
"mode": "managed",
104+
"type": "cloudflare_logpush_job",
105+
"name": "empty_kind",
106+
"provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
107+
"instances": [
108+
{
109+
"schema_version": 0,
110+
"attributes": {
111+
"id": "5",
112+
"zone_id": "0da42c8d2132a9ddaf714f9e7c920711",
113+
"dataset": "http_requests",
114+
"destination_conf": "https://logpush-receiver.sd.cfplat.com",
115+
"enabled": true,
116+
"kind": ""
117+
}
118+
}
119+
]
120+
},
121+
{
122+
"mode": "managed",
123+
"type": "cloudflare_logpush_job",
124+
"name": "edge_logs",
125+
"provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
126+
"instances": [
127+
{
128+
"schema_version": 0,
129+
"attributes": {
130+
"id": "6",
131+
"zone_id": "0da42c8d2132a9ddaf714f9e7c920711",
132+
"dataset": "http_requests",
133+
"destination_conf": "https://logpush-receiver.sd.cfplat.com",
134+
"enabled": true,
135+
"kind": "edge"
136+
}
137+
}
138+
]
139+
},
140+
{
141+
"mode": "managed",
142+
"type": "cloudflare_logpush_job",
143+
"name": "full",
144+
"provider": "provider[\"registry.terraform.io/cloudflare/cloudflare\"]",
145+
"instances": [
146+
{
147+
"schema_version": 0,
148+
"attributes": {
149+
"id": "7",
150+
"zone_id": "0da42c8d2132a9ddaf714f9e7c920711",
151+
"dataset": "http_requests",
152+
"destination_conf": "https://logpush-receiver.sd.cfplat.com",
153+
"enabled": true,
154+
"kind": "edge",
155+
"name": "my-logpush-job",
156+
"frequency": "high",
157+
"max_upload_bytes": 5000000,
158+
"max_upload_records": 1000,
159+
"max_upload_interval_seconds": 30,
160+
"output_options": {
161+
"cve_2021_44228": true,
162+
"batch_prefix": "{",
163+
"batch_suffix": "}",
164+
"field_names": ["ClientIP", "EdgeStartTimestamp", "RayID"],
165+
"output_type": "ndjson",
166+
"sample_rate": 1,
167+
"timestamp_format": "unixnano",
168+
"field_delimiter": ",",
169+
"record_prefix": "{",
170+
"record_suffix": "}\n"
171+
}
172+
}
173+
}
174+
]
175+
}
176+
]
177+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
variable "cloudflare_account_id" {
2+
description = "Cloudflare account ID"
3+
type = string
4+
}
5+
6+
variable "cloudflare_zone_id" {
7+
description = "Cloudflare zone ID"
8+
type = string
9+
}
10+
11+
# Minimal logpush job
12+
resource "cloudflare_logpush_job" "minimal" {
13+
account_id = var.cloudflare_account_id
14+
dataset = "audit_logs"
15+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
16+
}
17+
18+
# Job with logpull_options only (no output_options)
19+
resource "cloudflare_logpush_job" "with_logpull_options" {
20+
account_id = var.cloudflare_account_id
21+
dataset = "audit_logs"
22+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
23+
logpull_options = "fields=ClientIP,EdgeStartTimestamp&timestamps=unixnano"
24+
}
25+
26+
# Job with output_options block
27+
resource "cloudflare_logpush_job" "with_output_options" {
28+
account_id = var.cloudflare_account_id
29+
dataset = "audit_logs"
30+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
31+
32+
output_options {
33+
batch_prefix = "{"
34+
batch_suffix = "}"
35+
field_names = ["ClientIP", "EdgeStartTimestamp"]
36+
output_type = "ndjson"
37+
}
38+
}
39+
40+
# Job with cve20214428 field (should be renamed)
41+
resource "cloudflare_logpush_job" "with_cve_field" {
42+
account_id = var.cloudflare_account_id
43+
dataset = "audit_logs"
44+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
45+
46+
output_options {
47+
cve20214428 = true
48+
output_type = "ndjson"
49+
}
50+
}
51+
52+
# Job with edge kind (should be preserved)
53+
resource "cloudflare_logpush_job" "edge_logs" {
54+
zone_id = var.cloudflare_zone_id
55+
dataset = "http_requests"
56+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
57+
kind = "edge"
58+
}
59+
60+
# Job with "" kind (should be preserved)
61+
resource "cloudflare_logpush_job" "empty_kind" {
62+
zone_id = var.cloudflare_zone_id
63+
dataset = "http_requests"
64+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
65+
kind = ""
66+
}
67+
68+
# Full featured job with all transformations
69+
resource "cloudflare_logpush_job" "full" {
70+
zone_id = var.cloudflare_zone_id
71+
dataset = "http_requests"
72+
destination_conf = "https://logpush-receiver.sd.cfplat.com"
73+
kind = "edge"
74+
enabled = true
75+
name = "my-logpush-job"
76+
frequency = "high"
77+
78+
output_options {
79+
cve20214428 = true
80+
batch_prefix = "{"
81+
batch_suffix = "}"
82+
field_names = ["ClientIP", "EdgeStartTimestamp", "RayID"]
83+
output_type = "ndjson"
84+
sample_rate = 1.0
85+
timestamp_format = "unixnano"
86+
}
87+
}

0 commit comments

Comments
 (0)