Skip to content

Commit 039890a

Browse files
committed
feat: commit the Grit workflow for autogeneration
1 parent 205eb3d commit 039890a

File tree

12 files changed

+408
-12465
lines changed

12 files changed

+408
-12465
lines changed
+199
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
2+
language hcl
3+
4+
pattern terraform_cloudflare_v5() {
5+
or {
6+
`cors_headers { $block }` => `cors_headers = {
7+
$block
8+
}` where { $block <: within `resource "cloudflare_access_application" $_ { $_ }` },
9+
`landing_page_design { $block }` => `landing_page_design = {
10+
$block
11+
}` where { $block <: within `resource "cloudflare_access_application" $_ { $_ }` },
12+
`saas_app { $block }` => `saas_app = {
13+
$block
14+
}` where { $block <: within `resource "cloudflare_access_application" $_ { $_ }` },
15+
`scim_config { $block }` => `scim_config = {
16+
$block
17+
}` where { $block <: within `resource "cloudflare_access_application" $_ { $_ }` },
18+
`exclude { $block }` => `exclude = {
19+
$block
20+
}` where { $block <: within `resource "cloudflare_access_group" $_ { $_ }` },
21+
`include { $block }` => `include = {
22+
$block
23+
}` where { $block <: within `resource "cloudflare_access_group" $_ { $_ }` },
24+
`require { $block }` => `require = {
25+
$block
26+
}` where { $block <: within `resource "cloudflare_access_group" $_ { $_ }` },
27+
`config { $block }` => `config = {
28+
$block
29+
}` where { $block <: within `resource "cloudflare_access_identity_provider" $_ { $_ }` },
30+
`scim_config { $block }` => `scim_config = {
31+
$block
32+
}` where { $block <: within `resource "cloudflare_access_identity_provider" $_ { $_ }` },
33+
`settings { $block }` => `settings = {
34+
$block
35+
}` where { $block <: within `resource "cloudflare_access_mutual_tls_hostname_settings" $_ { $_ }` },
36+
`custom_pages { $block }` => `custom_pages = {
37+
$block
38+
}` where { $block <: within `resource "cloudflare_access_organization" $_ { $_ }` },
39+
`login_design { $block }` => `login_design = {
40+
$block
41+
}` where { $block <: within `resource "cloudflare_access_organization" $_ { $_ }` },
42+
`approval_group { $block }` => `approval_group = {
43+
$block
44+
}` where { $block <: within `resource "cloudflare_access_policy" $_ { $_ }` },
45+
`exclude { $block }` => `exclude = {
46+
$block
47+
}` where { $block <: within `resource "cloudflare_access_policy" $_ { $_ }` },
48+
`include { $block }` => `include = {
49+
$block
50+
}` where { $block <: within `resource "cloudflare_access_policy" $_ { $_ }` },
51+
`require { $block }` => `require = {
52+
$block
53+
}` where { $block <: within `resource "cloudflare_access_policy" $_ { $_ }` },
54+
`configuration { $block }` => `configuration = {
55+
$block
56+
}` where { $block <: within `resource "cloudflare_access_rule" $_ { $_ }` },
57+
`auth_id_characteristics { $block }` => `auth_id_characteristics = {
58+
$block
59+
}` where { $block <: within `resource "cloudflare_api_shield" $_ { $_ }` },
60+
`condition { $block }` => `condition = {
61+
$block
62+
}` where { $block <: within `resource "cloudflare_api_token" $_ { $_ }` },
63+
`validation_errors { $block }` => `validation_errors = {
64+
$block
65+
}` where { $block <: within `resource "cloudflare_certificate_pack" $_ { $_ }` },
66+
`validation_records { $block }` => `validation_records = {
67+
$block
68+
}` where { $block <: within `resource "cloudflare_certificate_pack" $_ { $_ }` },
69+
`ssl { $block }` => `ssl = {
70+
$block
71+
}` where { $block <: within `resource "cloudflare_custom_hostname" $_ { $_ }` },
72+
`custom_ssl_options { $block }` => `custom_ssl_options = {
73+
$block
74+
}` where { $block <: within `resource "cloudflare_custom_ssl" $_ { $_ }` },
75+
`custom_ssl_priority { $block }` => `custom_ssl_priority = {
76+
$block
77+
}` where { $block <: within `resource "cloudflare_custom_ssl" $_ { $_ }` },
78+
`data { $block }` => `data = {
79+
$block
80+
}` where { $block <: within `resource "cloudflare_device_dex_test" $_ { $_ }` },
81+
`config { $block }` => `config = {
82+
$block
83+
}` where { $block <: within `resource "cloudflare_device_managed_networks" $_ { $_ }` },
84+
`config { $block }` => `config = {
85+
$block
86+
}` where { $block <: within `resource "cloudflare_device_posture_integration" $_ { $_ }` },
87+
`input { $block }` => `input = {
88+
$block
89+
}` where { $block <: within `resource "cloudflare_device_posture_rule" $_ { $_ }` },
90+
`match { $block }` => `match = {
91+
$block
92+
}` where { $block <: within `resource "cloudflare_device_posture_rule" $_ { $_ }` },
93+
`context_awareness { $block }` => `context_awareness = {
94+
$block
95+
}` where { $block <: within `resource "cloudflare_dlp_profile" $_ { $_ }` },
96+
`hostname { $block }` => `hostname = {
97+
$block
98+
}` where { $block <: within `resource "cloudflare_list_item" $_ { $_ }` },
99+
`redirect { $block }` => `redirect = {
100+
$block
101+
}` where { $block <: within `resource "cloudflare_list_item" $_ { $_ }` },
102+
`rules { $block }` => `rules = {
103+
$block
104+
}` where { $block <: within `resource "cloudflare_load_balancer" $_ { $_ }` },
105+
`output_options { $block }` => `output_options = {
106+
$block
107+
}` where { $block <: within `resource "cloudflare_logpush_job" $_ { $_ }` },
108+
`filters { $block }` => `filters = {
109+
$block
110+
}` where { $block <: within `resource "cloudflare_notification_policy" $_ { $_ }` },
111+
`actions { $block }` => `actions = {
112+
$block
113+
}` where { $block <: within `resource "cloudflare_page_rule" $_ { $_ }` },
114+
`build_config { $block }` => `build_config = {
115+
$block
116+
}` where { $block <: within `resource "cloudflare_pages_project" $_ { $_ }` },
117+
`deployment_configs { $block }` => `deployment_configs = {
118+
$block
119+
}` where { $block <: within `resource "cloudflare_pages_project" $_ { $_ }` },
120+
`source { $block }` => `source = {
121+
$block
122+
}` where { $block <: within `resource "cloudflare_pages_project" $_ { $_ }` },
123+
`action { $block }` => `action = {
124+
$block
125+
}` where { $block <: within `resource "cloudflare_rate_limit" $_ { $_ }` },
126+
`correlate { $block }` => `correlate = {
127+
$block
128+
}` where { $block <: within `resource "cloudflare_rate_limit" $_ { $_ }` },
129+
`match { $block }` => `match = {
130+
$block
131+
}` where { $block <: within `resource "cloudflare_rate_limit" $_ { $_ }` },
132+
`data { $block }` => `data = {
133+
$block
134+
}` where { $block <: within `resource "cloudflare_record" $_ { $_ }` },
135+
`rules { $block }` => `rules = {
136+
$block
137+
}` where { $block <: within `resource "cloudflare_ruleset" $_ { $_ }` },
138+
`dns { $block }` => `dns = {
139+
$block
140+
}` where { $block <: within `resource "cloudflare_spectrum_application" $_ { $_ }` },
141+
`edge_ips { $block }` => `edge_ips = {
142+
$block
143+
}` where { $block <: within `resource "cloudflare_spectrum_application" $_ { $_ }` },
144+
`origin_dns { $block }` => `origin_dns = {
145+
$block
146+
}` where { $block <: within `resource "cloudflare_spectrum_application" $_ { $_ }` },
147+
`origin_port_range { $block }` => `origin_port_range = {
148+
$block
149+
}` where { $block <: within `resource "cloudflare_spectrum_application" $_ { $_ }` },
150+
`antivirus { $block }` => `antivirus = {
151+
$block
152+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
153+
`block_page { $block }` => `block_page = {
154+
$block
155+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
156+
`body_scanning { $block }` => `body_scanning = {
157+
$block
158+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
159+
`custom_certificate { $block }` => `custom_certificate = {
160+
$block
161+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
162+
`extended_email_matching { $block }` => `extended_email_matching = {
163+
$block
164+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
165+
`fips { $block }` => `fips = {
166+
$block
167+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
168+
`logging { $block }` => `logging = {
169+
$block
170+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
171+
`payload_log { $block }` => `payload_log = {
172+
$block
173+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
174+
`proxy { $block }` => `proxy = {
175+
$block
176+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
177+
`ssh_session_log { $block }` => `ssh_session_log = {
178+
$block
179+
}` where { $block <: within `resource "cloudflare_teams_account" $_ { $_ }` },
180+
`rule_settings { $block }` => `rule_settings = {
181+
$block
182+
}` where { $block <: within `resource "cloudflare_teams_rule" $_ { $_ }` },
183+
`config { $block }` => `config = {
184+
$block
185+
}` where { $block <: within `resource "cloudflare_tunnel_config" $_ { $_ }` },
186+
`configuration { $block }` => `configuration = {
187+
$block
188+
}` where { $block <: within `resource "cloudflare_user_agent_blocking_rule" $_ { $_ }` },
189+
`additional_routes { $block }` => `additional_routes = {
190+
$block
191+
}` where { $block <: within `resource "cloudflare_waiting_room" $_ { $_ }` },
192+
`rules { $block }` => `rules = {
193+
$block
194+
}` where { $block <: within `resource "cloudflare_waiting_room_rules" $_ { $_ }` },
195+
`settings { $block }` => `settings = {
196+
$block
197+
}` where { $block <: within `resource "cloudflare_zone_settings_override" $_ { $_ }` }
198+
}
199+
}

.grit/patterns/v5_upgrade.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
layout: "cloudflare"
3+
page_title: "Upgrading to version 5 (from 4.x)"
4+
description: Terraform Cloudflare Provider Version 5 Upgrade Guide
5+
---
6+
7+
# Terraform Cloudflare Provider Version 5 Upgrade Guide
8+
9+
Version 5 of the Cloudflare Terraform Provider is a ground-up rewrite of the provider, using code generation from our OpenAPI spec.
10+
11+
```grit
12+
language hcl
13+
14+
or {
15+
terraform_cloudflare_v5(),
16+
`provider "cloudflare" { $provider }` where {
17+
$provider <: contains `version = $old` => `version = "~> 5"`,
18+
$old <: not includes "5"
19+
}
20+
}
21+
```
22+
23+
## Provider Version Configuration
24+
25+
If you are not ready to make a move to version 5 of the Cloudflare provider,
26+
you may keep the 4.x branch active for your Terraform project by specifying:
27+
28+
```hcl
29+
provider "cloudflare" {
30+
version = "~> 4"
31+
# ... any other configuration
32+
}
33+
```
34+
35+
We highly recommend reviewing this guide, make necessary changes and move to
36+
5.x branch, as further 4.x releases are unlikely to happen outside of critical
37+
security fixes.
38+
39+
~> Before attempting to upgrade to version 5, you should first upgrade to the
40+
latest version of 4 to ensure any transitional updates are applied to your
41+
existing configuration.
42+
43+
Once ready, make the following change to use the latest 5.x release:
44+
45+
```hcl
46+
provider "cloudflare" {
47+
version = "~> 5"
48+
# ... any other configuration
49+
}
50+
```
51+
52+
## Automatic migration
53+
54+
For assisting with automatic migrations, we have provided a [GritQL] pattern.
55+
This will allow you to rewrite the parts of your Terraform configuration that have changed automatically. Once you [install Grit], you can run the following
56+
command in the directory where your Terraform configuration is located.
57+
58+
~> If you are using modules or other dynamic features of HCL, the provided
59+
codemods may not be as effective. We recommend reviewing the migration notes below to verify all the changes.
60+
61+
## Block attributes
62+
63+
All blocks used for configuration have been converted to attributes, which must be set with an `=` sign.
64+
65+
For example, the `config` block in the `cloudflare_device_posture_integration` resource must be converted from this:
66+
67+
```hcl
68+
resource "cloudflare_device_posture_integration" "example" {
69+
# old stuff
70+
config {
71+
api_url = "https://example.com/api"
72+
auth_url = "https://example.com/connect/token"
73+
client_id = "client-id"
74+
client_secret = "client-secret"
75+
}
76+
}
77+
```
78+
79+
Afterwards it will look like this:
80+
81+
```hcl
82+
resource "cloudflare_device_posture_integration" "example" {
83+
# old stuff
84+
config = {
85+
api_url = "https://example.com/api"
86+
auth_url = "https://example.com/connect/token"
87+
client_id = "client-id"
88+
client_secret = "client-secret"
89+
}
90+
}
91+
```
92+
93+
## Renames
94+
95+
## Removals
96+
97+
[GritQL]: https://www.grit.io/
98+
[install Grit]: https://docs.grit.io/cli/quickstart

.grit/workflows/stainless-gritql-generator/.gitignore

-2
This file was deleted.

.grit/workflows/stainless-gritql-generator/config/.terraform.lock.hcl

-25
This file was deleted.

0 commit comments

Comments
 (0)