Skip to content

Commit 052a269

Browse files
committed
feat: migrate zero_trust_access_group migrations
The custom plan checker was created to solve a specific problem with Zero Trust Access Group migration tests failing due to ordering and nil representation differences between the v4 and v5 Terraform providers. When migrating from v4 to v5, the same logical configuration (like include rules with emails and IPs) would be stored differently in Terraform state - sometimes in different orders or with different nil value representations (e.g., map[field:<nil>] vs <nil>). This caused migration tests to fail with "plan not empty" errors even though the configurations were functionally equivalent. The custom plan checker (ExpectEmptyPlanExceptZeroTrustAccessGroupOrdering) recognizes that [{email: "a"}, {ip: "1.1.1.1"}] and [{ip: "1.1.1.1"}, {email: "a"}] represent the same access group rules, allowing migration tests to pass while still catching real configuration drift. This was a testing-only solution that doesn't affect actual user experience - users still see legitimate migration changes in their plans, but our test suite can now properly validate that the migrations work correctly despite internal ordering differences.
1 parent e153444 commit 052a269

File tree

9 files changed

+2842
-1
lines changed

9 files changed

+2842
-1
lines changed

cmd/migrate/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ func transformFile(content []byte, filename string) ([]byte, error) {
264264
if isZeroTrustAccessMTLSHostnameSettingsResource(block) {
265265
transformZeroTrustAccessMTLSHostnameSettingsBlock(block, diags)
266266
}
267+
268+
if isAccessGroupResource(block) {
269+
transformAccessGroupBlock(block, diags)
270+
}
267271
}
268272

269273
// Remove old blocks

cmd/migrate/test_dir/test.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
resource "cloudflare_zero_trust_access_group" "example" {
2+
account_id = "test-account"
3+
name = "test-group"
4+
5+
include = [{ email = { email = "[email protected]" } },
6+
{ email = { email = "[email protected]" } },
7+
{ email_domain = { domain = "example.com" } },
8+
{ email_domain = { domain = "test.com" } },
9+
{ ip = { ip = "192.0.2.1/32" } },
10+
{ ip = { ip = "10.0.0.0/8" } },
11+
{
12+
azure_ad = {
13+
id = "group1"
14+
identity_provider_id = "azure-provider"
15+
}
16+
},
17+
{
18+
azure_ad = {
19+
id = "group2"
20+
identity_provider_id = "azure-provider"
21+
}
22+
}]
23+
}

0 commit comments

Comments
 (0)