-
Notifications
You must be signed in to change notification settings - Fork 2
feat(load_balancer): v4 to v5 migration #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+3,424
−398
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
integration/v4_to_v5/testdata/load_balancer/expected/load_balancer.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| # Minimal load_balancer testdata for v4 to v5 migration | ||
| # This file uses v4 schema which has major breaking changes in v5 | ||
|
|
||
| # Variables for DRY configuration | ||
| variable "cloudflare_account_id" { | ||
| type = string | ||
| default = "f037e56e89293a057740de681ac9abbe" | ||
| } | ||
|
|
||
| variable "cloudflare_zone_id" { | ||
| type = string | ||
| default = "0da42c8d2132a9ddaf714f9e7c920711" | ||
| } | ||
|
|
||
| variable "cloudflare_domain" { | ||
| type = string | ||
| description = "Domain for testing" | ||
| } | ||
|
|
||
| # Locals for naming consistency | ||
| locals { | ||
| name_prefix = "cftftest" | ||
| } | ||
|
|
||
| # Note: Load balancer resources require load_balancer_pool resources | ||
| # These are not included here as they would need their own v4 to v5 migration | ||
| # For now, this file only tests the load_balancer resource schema changes | ||
|
|
||
| # 1. Basic load balancer (v4 schema) | ||
| # v4 uses: default_pool_ids, fallback_pool_id | ||
| # v5 uses: default_pools, fallback_pool | ||
| resource "cloudflare_load_balancer" "basic" { | ||
| zone_id = var.cloudflare_zone_id | ||
| name = "${local.name_prefix}-basic-lb.${var.cloudflare_domain}" | ||
| default_pools = ["pool-id-1"] | ||
| fallback_pool = "pool-id-fallback" | ||
| } | ||
|
|
||
| # 2. Load balancer with session_affinity_attributes (v4 block, v5 map) | ||
| resource "cloudflare_load_balancer" "with_affinity" { | ||
| zone_id = var.cloudflare_zone_id | ||
| name = "${local.name_prefix}-affinity-lb.${var.cloudflare_domain}" | ||
| session_affinity = "cookie" | ||
| session_affinity_ttl = 3600 | ||
|
|
||
| default_pools = ["pool-id-1"] | ||
| fallback_pool = "pool-id-fallback" | ||
| session_affinity_attributes = { | ||
| samesite = "Lax" | ||
| secure = "Always" | ||
| } | ||
| } | ||
|
|
||
| # 3. Load balancer with region_pools (v4 blocks, v5 map) | ||
| resource "cloudflare_load_balancer" "with_region_pools" { | ||
| zone_id = var.cloudflare_zone_id | ||
| name = "${local.name_prefix}-region-lb.${var.cloudflare_domain}" | ||
|
|
||
|
|
||
| default_pools = ["pool-id-1"] | ||
| fallback_pool = "pool-id-fallback" | ||
| region_pools = { | ||
| "WNAM" = ["pool-id-1"] | ||
| "ENAM" = ["pool-id-2"] | ||
| } | ||
| } | ||
|
|
||
| # 4. Load balancer with adaptive_routing (v4 block, v5 single object) | ||
| resource "cloudflare_load_balancer" "with_adaptive_routing" { | ||
| zone_id = var.cloudflare_zone_id | ||
| name = "${local.name_prefix}-adaptive-lb.${var.cloudflare_domain}" | ||
|
|
||
| default_pools = ["pool-id-1"] | ||
| fallback_pool = "pool-id-fallback" | ||
| adaptive_routing = { | ||
| failover_across_pools = false | ||
| } | ||
| } | ||
|
|
||
| # 5. Load balancer with location_strategy (v4 block, v5 single object) | ||
| resource "cloudflare_load_balancer" "with_location_strategy" { | ||
| zone_id = var.cloudflare_zone_id | ||
| name = "${local.name_prefix}-location-lb.${var.cloudflare_domain}" | ||
|
|
||
| default_pools = ["pool-id-1"] | ||
| fallback_pool = "pool-id-fallback" | ||
| location_strategy = { | ||
| prefer_ecs = "proximity" | ||
| mode = "pop" | ||
| } | ||
| } | ||
|
|
||
| # 6. Load balancer with random_steering (v4 block, v5 single object) | ||
| resource "cloudflare_load_balancer" "with_random_steering" { | ||
| zone_id = var.cloudflare_zone_id | ||
| name = "${local.name_prefix}-random-lb.${var.cloudflare_domain}" | ||
| steering_policy = "random" | ||
|
|
||
| default_pools = ["pool-id-1"] | ||
| fallback_pool = "pool-id-fallback" | ||
| random_steering = { | ||
| default_weight = 0.5 | ||
| pool_weights = { | ||
| "pool-id-1" = 0.7 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # 7. Load balancer with all single-object attributes (comprehensive test) | ||
| resource "cloudflare_load_balancer" "with_all_attributes" { | ||
| zone_id = var.cloudflare_zone_id | ||
| name = "${local.name_prefix}-all-attrs-lb.${var.cloudflare_domain}" | ||
| session_affinity = "cookie" | ||
| session_affinity_ttl = 3600 | ||
| steering_policy = "random" | ||
|
|
||
|
|
||
|
|
||
|
|
||
| default_pools = ["pool-id-1"] | ||
| fallback_pool = "pool-id-fallback" | ||
| session_affinity_attributes = { | ||
| samesite = "Lax" | ||
| secure = "Always" | ||
| } | ||
| adaptive_routing = { | ||
| failover_across_pools = false | ||
| } | ||
| location_strategy = { | ||
| prefer_ecs = "proximity" | ||
| mode = "pop" | ||
| } | ||
| random_steering = { | ||
| default_weight = 0.5 | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice