Skip to content
Draft
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
26 changes: 26 additions & 0 deletions e2e/tf/v4/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,29 @@ variable "crowdstrike_customer_id" {
type = string
default = ""
}

# BYO IP Prefix variables for testing
# Set via TF_VAR_byo_ip_* environment variables or directly in terraform.tfvars
variable "byo_ip_cidr" {
description = "BYO IP CIDR notation for the prefix"
type = string
default = "2606:54c2:2::/48"
}

variable "byo_ip_asn" {
description = "BYO IP ASN number"
type = string
default = "13335"
}

variable "byo_ip_loa_document_id" {
description = "BYO IP LOA document ID"
type = string
default = "a6061274b61449d3bb4521aee2e90c95"
}

variable "byo_ip_prefix_id" {
description = "BYO IP prefix ID (for v4 provider or migration tests)"
type = string
default = "b543f1a825f4474b88e945f164624412"
}
217 changes: 217 additions & 0 deletions integration/v4_to_v5/testdata/byo_ip_prefix/expected/byo_ip_prefix.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# Comprehensive Integration Tests for byo_ip_prefix Migration (v4 → v5)
# This file covers all v4 schema attributes and Terraform patterns
# Target: 15-30+ resource instances

# ============================================================================
# PATTERN 1-2: Variables & Locals
# ============================================================================

variable "cloudflare_account_id" {
description = "Cloudflare account ID"
type = string
# No default - must be provided
}

variable "cloudflare_zone_id" {
description = "Cloudflare zone ID"
type = string
# No default - must be provided
}

variable "cloudflare_domain" {
description = "Cloudflare domain for testing"
type = string
}

variable "prefix_base" {
description = "Base prefix ID for testing"
type = string
default = "cftftest"
}

variable "enable_optional" {
description = "Whether to create optional resources"
type = bool
default = true
}

variable "advertisement_status" {
description = "Advertisement status for prefixes"
type = string
default = "on"
}

locals {
name_prefix = "cftftest"
environment = "integration-test"
description_template = "BYO IP Prefix for ${local.environment}"

prefix_map = {
prod = "cftftest-prod-001"
staging = "cftftest-staging-001"
dev = "cftftest-dev-001"
test = "cftftest-test-001"
}

prefix_list = [
"cftftest-list-001",
"cftftest-list-002",
"cftftest-list-003"
]
}

# ============================================================================
# PATTERN 1: Basic Resources (3 instances)
# ============================================================================

# Instance 1: Minimal resource (only required fields)
resource "cloudflare_byo_ip_prefix" "minimal" {
account_id = var.cloudflare_account_id
}

# Instance 2: Full resource with all optional fields
resource "cloudflare_byo_ip_prefix" "full" {
account_id = var.cloudflare_account_id
description = "Full BYO IP prefix with all fields"
}

# Instance 3: Resource with variables
resource "cloudflare_byo_ip_prefix" "with_variables" {
account_id = var.cloudflare_account_id
description = local.description_template
}

# ============================================================================
# PATTERN 3: for_each with Maps (4 instances)
# ============================================================================

resource "cloudflare_byo_ip_prefix" "from_map" {
for_each = local.prefix_map

account_id = var.cloudflare_account_id
description = "Prefix for ${each.key} environment"
}

# ============================================================================
# PATTERN 4: for_each with Sets (3 instances)
# ============================================================================

resource "cloudflare_byo_ip_prefix" "from_set" {
for_each = toset(local.prefix_list)

account_id = var.cloudflare_account_id
description = "Prefix from set: ${each.value}"
}

# ============================================================================
# PATTERN 5: count-based Resources (3 instances)
# ============================================================================

resource "cloudflare_byo_ip_prefix" "with_count" {
count = 3

account_id = var.cloudflare_account_id
description = "Prefix number ${count.index + 1}"
}

# ============================================================================
# PATTERN 6: Conditional Resource Creation (2 instances)
# ============================================================================

resource "cloudflare_byo_ip_prefix" "conditional" {
count = var.enable_optional ? 1 : 0

account_id = var.cloudflare_account_id
description = "Conditional prefix"
}

resource "cloudflare_byo_ip_prefix" "conditional_ternary" {
count = var.enable_optional ? 2 : 0

account_id = var.cloudflare_account_id
description = var.enable_optional ? "Enabled prefix ${count.index}" : null
}

# ============================================================================
# PATTERN 7: Cross-resource References (1 instance)
# ============================================================================

# Note: byo_ip_prefix is a standalone resource, so cross-references are limited
# But we can reference other instances
resource "cloudflare_byo_ip_prefix" "reference" {
account_id = cloudflare_byo_ip_prefix.minimal.account_id
description = "References minimal: ${cloudflare_byo_ip_prefix.minimal.prefix_id}"
}

# ============================================================================
# PATTERN 8: Lifecycle Meta-arguments (2 instances)
# ============================================================================

resource "cloudflare_byo_ip_prefix" "with_lifecycle" {
account_id = var.cloudflare_account_id
description = "Prefix with lifecycle rules"

lifecycle {
create_before_destroy = true
ignore_changes = [description]
}
}

resource "cloudflare_byo_ip_prefix" "prevent_destroy" {
account_id = var.cloudflare_account_id
description = "Protected prefix"

lifecycle {
prevent_destroy = true
}
}

# ============================================================================
# PATTERN 9: Terraform Functions (3 instances)
# ============================================================================

resource "cloudflare_byo_ip_prefix" "with_join" {
account_id = var.cloudflare_account_id
description = join(" - ", ["BYO IP", local.environment, "test"])
}

resource "cloudflare_byo_ip_prefix" "with_format" {
account_id = var.cloudflare_account_id
description = format("Prefix for %s environment", local.environment)
}

resource "cloudflare_byo_ip_prefix" "with_interpolation" {
account_id = var.cloudflare_account_id
description = "Prefix managed by ${local.name_prefix} for ${local.environment}"
}

# ============================================================================
# EDGE CASES (2 instances)
# ============================================================================

# Edge case 1: Empty string description (vs null)
resource "cloudflare_byo_ip_prefix" "empty_description" {
account_id = var.cloudflare_account_id
description = ""
}

# Edge case 2: Advertisement off
resource "cloudflare_byo_ip_prefix" "advertisement_off" {
account_id = var.cloudflare_account_id
description = "Prefix with advertisement disabled"
}

# ============================================================================
# INSTANCE COUNT SUMMARY
# ============================================================================
# Basic: 3
# for_each maps: 4 (prod, staging, dev, test)
# for_each sets: 3
# count-based: 3
# conditional: 3 (1 + 2 when enabled)
# cross-reference: 1
# lifecycle: 2
# functions: 3
# edge cases: 2
# TOTAL: 24 instances (exceeds 15-30 target)
# ============================================================================
Loading