Refactor Terraform tests to remove project_id references

- Removed project_id variable and its usage from multiple Terraform test files (23-probe-crud, 24-status-page-crud, 25-status-page-with-domain, 26-monitor-steps-basic, 27-monitor-types, 28-incident-crud, 29-alert-crud, 30-scheduled-maintenance-crud, 31-on-call-duty-policy-crud, 32-monitor-group-crud, 33-team-crud, 35-monitor-with-steps, 36-monitor-types-basic, 37-label-order-idempotency).
- Updated ResourceGenerator to treat project_id as computed-only, inferred from API key authentication.
- Adjusted related logic in resource update and delete operations to exclude project_id from requests.
This commit is contained in:
Nawaz Dhandala
2026-01-27 20:00:41 +00:00
parent 935608d23d
commit 9d29a1d00b
75 changed files with 17 additions and 268 deletions

View File

@@ -10,7 +10,6 @@ source "$TEST_DIR/test-env.sh"
echo "=== Running Terraform E2E Tests ==="
echo "OneUptime URL: $ONEUPTIME_URL"
echo "Project ID: $ONEUPTIME_PROJECT_ID"
# Build and install provider locally
echo ""

View File

@@ -123,8 +123,6 @@ cat > "$TEST_DIR/test-env.sh" << EOF
#!/bin/bash
export ONEUPTIME_URL="$ONEUPTIME_URL"
export ONEUPTIME_API_KEY="$API_KEY"
export ONEUPTIME_PROJECT_ID="$PROJECT_ID"
export TF_VAR_project_id="$PROJECT_ID"
export TF_VAR_api_key="$API_KEY"
export TF_VAR_oneuptime_url="$ONEUPTIME_URL"
EOF
@@ -137,5 +135,4 @@ rm -f "$TEST_DIR/cookies.txt"
echo ""
echo "=== Setup Complete ==="
echo "ONEUPTIME_URL: $ONEUPTIME_URL"
echo "PROJECT_ID: $PROJECT_ID"
echo "API_KEY: $API_KEY"

View File

@@ -13,7 +13,6 @@ provider "oneuptime" {
}
resource "oneuptime_label" "test" {
project_id = var.project_id
name = "terraform-e2e-label-${formatdate("YYYYMMDDhhmmss", timestamp())}"
description = "Label created by Terraform E2E tests"
color = "#FF5733"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -13,7 +13,6 @@ provider "oneuptime" {
}
resource "oneuptime_monitor_status" "test" {
project_id = var.project_id
name = "terraform-e2e-status-${formatdate("YYYYMMDDhhmmss", timestamp())}"
description = "Monitor status created by Terraform E2E tests"
color = "#00FF00"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -13,7 +13,6 @@ provider "oneuptime" {
}
resource "oneuptime_incident_severity" "test" {
project_id = var.project_id
name = "terraform-e2e-severity-${formatdate("YYYYMMDDhhmmss", timestamp())}"
description = "Incident severity created by Terraform E2E tests"
color = "#FFA500"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -13,7 +13,6 @@ provider "oneuptime" {
}
resource "oneuptime_incident_state" "test" {
project_id = var.project_id
name = "terraform-e2e-state-${formatdate("YYYYMMDDhhmmss", timestamp())}"
description = "Incident state created by Terraform E2E tests"
color = "#0000FF"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -13,7 +13,6 @@ provider "oneuptime" {
}
resource "oneuptime_status_page" "test" {
project_id = var.project_id
name = "terraform-e2e-statuspage-${formatdate("YYYYMMDDhhmmss", timestamp())}"
description = "Status page created by Terraform E2E tests"
page_title = "Terraform Test Status"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -13,7 +13,6 @@ provider "oneuptime" {
}
resource "oneuptime_alert_severity" "test" {
project_id = var.project_id
name = "terraform-e2e-alert-sev-${formatdate("YYYYMMDDhhmmss", timestamp())}"
description = "Alert severity created by Terraform E2E tests"
color = "#FF0000"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -13,7 +13,6 @@ provider "oneuptime" {
}
resource "oneuptime_alert_state" "test" {
project_id = var.project_id
name = "terraform-e2e-alert-state-${formatdate("YYYYMMDDhhmmss", timestamp())}"
description = "Alert state created by Terraform E2E tests"
color = "#800080"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -15,7 +15,6 @@ provider "oneuptime" {
# Test for GitHub Issue #2228: probe_version field produces inconsistent result after apply
# The probe_version should remain as "1.0.0" and not be converted to JSON like {"_type":"Version","value":"1.0.0"}
resource "oneuptime_probe" "test" {
project_id = var.project_id
key = "terraform-e2e-probe-key-${formatdate("YYYYMMDDhhmmss", timestamp())}"
name = "terraform-e2e-probe-${formatdate("YYYYMMDDhhmmss", timestamp())}"
probe_version = "1.0.0"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -22,7 +22,6 @@ resource "random_id" "suffix" {
# Comprehensive CRUD test for label resource
resource "oneuptime_label" "test" {
project_id = var.project_id
name = "TF CRUD Label ${random_id.suffix.hex}"
description = var.label_description
color = var.label_color

View File

@@ -9,10 +9,6 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}
variable "label_name" {
type = string

View File

@@ -14,7 +14,6 @@ provider "oneuptime" {
# Comprehensive CRUD test for monitor_status resource
resource "oneuptime_monitor_status" "test" {
project_id = var.project_id
name = var.status_name
description = var.status_description
color = var.status_color

View File

@@ -9,10 +9,6 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}
variable "status_name" {
type = string

View File

@@ -22,7 +22,6 @@ resource "random_id" "suffix" {
# Comprehensive CRUD test for incident_severity resource
resource "oneuptime_incident_severity" "test" {
project_id = var.project_id
name = "TF CRUD Severity ${random_id.suffix.hex}"
description = var.severity_description
color = var.severity_color

View File

@@ -9,10 +9,6 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}
variable "severity_name" {
type = string

View File

@@ -24,14 +24,12 @@ resource "random_id" "suffix" {
# The domain must be verified before it can be used with status_page_domain
# For test domains (.example.com), DNS verification is bypassed
resource "oneuptime_domain" "test" {
project_id = var.project_id
domain = "sp-domain-${random_id.suffix.hex}.example.com"
is_verified = true
}
# Then, create a status page (required for status_page_domain)
resource "oneuptime_status_page" "test" {
project_id = var.project_id
name = "TF SP Domain Test ${random_id.suffix.hex}"
description = "Status page created by Terraform E2E tests"
page_title = "Terraform Test Status"
@@ -46,7 +44,6 @@ resource "oneuptime_status_page" "test" {
# - full_domain is computed (server generates from subdomain + domain)
# - cname_verification_token is computed (server generates a UUID)
resource "oneuptime_status_page_domain" "test" {
project_id = var.project_id
domain_id = oneuptime_domain.test.id
status_page_id = oneuptime_status_page.test.id
subdomain = "status"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -24,14 +24,12 @@ resource "random_id" "suffix" {
# The domain must be verified before it can be used with status_page_domain
# For test domains (.example.com), DNS verification is bypassed
resource "oneuptime_domain" "test" {
project_id = var.project_id
domain = "computed-test-${random_id.suffix.hex}.example.com"
is_verified = true
}
# Then, create a status page (required for status_page_domain)
resource "oneuptime_status_page" "test" {
project_id = var.project_id
name = "TF Computed Fields SP ${random_id.suffix.hex}"
description = "Status page created by Terraform E2E tests for computed fields test"
page_title = "Computed Fields Test Status"
@@ -55,7 +53,6 @@ resource "oneuptime_status_page" "test" {
# - User should NOT need to provide this value
#
resource "oneuptime_status_page_domain" "test" {
project_id = var.project_id
domain_id = oneuptime_domain.test.id
status_page_id = oneuptime_status_page.test.id
subdomain = var.subdomain

View File

@@ -9,10 +9,6 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}
variable "domain_name" {
type = string

View File

@@ -35,7 +35,6 @@ resource "random_id" "suffix" {
# 3. Verify server provides default values for the field
resource "oneuptime_status_page" "test_server_defaults" {
project_id = var.project_id
name = "TF Server Defaults SP ${random_id.suffix.hex}"
description = "Tests that server-provided defaults work correctly (Issue #2232)"
page_title = "Server Defaults Test"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -28,7 +28,6 @@ provider "oneuptime" {
# 3. Verify server can inject defaults into monitor_steps
resource "oneuptime_monitor" "test_server_defaults" {
project_id = var.project_id
name = "Monitor Server Defaults Test"
description = "Tests that server-provided defaults work correctly (Issue #2226)"
monitor_type = "Manual"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -23,7 +23,6 @@ provider "oneuptime" {
# First create an incident severity (required dependency)
resource "oneuptime_incident_severity" "test" {
project_id = var.project_id
name = "Incident Test Severity"
description = "Severity for incident server defaults test"
color = "#FF0000"
@@ -32,7 +31,6 @@ resource "oneuptime_incident_severity" "test" {
# Create incident with minimal fields - let server provide defaults
resource "oneuptime_incident" "test_server_defaults" {
project_id = var.project_id
title = "Incident Server Defaults Test"
incident_severity_id = oneuptime_incident_severity.test.id

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -31,7 +31,6 @@ resource "random_id" "suffix" {
# First create an alert severity (required dependency)
resource "oneuptime_alert_severity" "test" {
project_id = var.project_id
name = "TF Alert Severity ${random_id.suffix.hex}"
description = "Severity for alert server defaults test"
color = "#FFA500"
@@ -40,7 +39,6 @@ resource "oneuptime_alert_severity" "test" {
# Create alert with minimal fields - let server provide defaults
resource "oneuptime_alert" "test_server_defaults" {
project_id = var.project_id
title = "TF Alert Defaults ${random_id.suffix.hex}"
alert_severity_id = oneuptime_alert_severity.test.id

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -23,7 +23,6 @@ provider "oneuptime" {
# Create scheduled maintenance event with minimal fields
resource "oneuptime_scheduled_maintenance_event" "test_server_defaults" {
project_id = var.project_id
title = "Scheduled Maintenance Server Defaults Test"
# Required datetime fields - use future dates

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -24,7 +24,6 @@ provider "oneuptime" {
# Create on-call policy with minimal fields
resource "oneuptime_on_call_policy" "test_server_defaults" {
project_id = var.project_id
name = "On-Call Policy Server Defaults Test"
# IMPORTANT: We intentionally DO NOT specify these Optional+Computed fields:

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -23,7 +23,6 @@ provider "oneuptime" {
# - Second apply: READ returns wrapped format {"_type":"Version","value":"1.0.0"}
# - Provider fails with "inconsistent result after apply"
resource "oneuptime_probe" "test" {
project_id = var.project_id
key = "tf-probe-idem-${formatdate("YYYYMMDDhhmmss", timestamp())}"
name = "tf-probe-idempotency-test-${formatdate("YYYYMMDDhhmmss", timestamp())}"
probe_version = "1.0.0"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -41,14 +41,12 @@ resource "random_id" "suffix" {
# First, create a domain
resource "oneuptime_domain" "test" {
project_id = var.project_id
domain = "idempotency-test-${random_id.suffix.hex}.example.com"
is_verified = true
}
# Then, create a status page
resource "oneuptime_status_page" "test" {
project_id = var.project_id
name = "Idempotency Test Status Page ${random_id.suffix.hex}"
description = "Status page for idempotency testing"
page_title = "Idempotency Test"
@@ -63,7 +61,6 @@ resource "oneuptime_status_page" "test" {
# - full_domain is NOT specified (it's computed)
# - cname_verification_token is NOT specified (it's computed)
resource "oneuptime_status_page_domain" "test" {
project_id = var.project_id
domain_id = oneuptime_domain.test.id
status_page_id = oneuptime_status_page.test.id
subdomain = "status"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -33,7 +33,6 @@ resource "random_id" "suffix" {
# Test Case 1: Manual Monitor (Basic)
resource "oneuptime_monitor" "manual_basic" {
project_id = var.project_id
name = "TF E2E Manual Monitor ${random_id.suffix.hex}"
description = "Manual monitor created by Terraform E2E tests"
monitor_type = "Manual"
@@ -41,7 +40,6 @@ resource "oneuptime_monitor" "manual_basic" {
# Test Case 2: Manual Monitor with Custom Settings
resource "oneuptime_monitor" "manual_custom" {
project_id = var.project_id
name = "TF E2E Custom Monitor ${random_id.suffix.hex}"
description = "Custom manual monitor with additional settings"
monitor_type = "Manual"
@@ -49,14 +47,12 @@ resource "oneuptime_monitor" "manual_custom" {
# Test Case 3: Monitor with Labels (if labels exist)
resource "oneuptime_label" "test_label" {
project_id = var.project_id
name = "TF E2E Monitor Label ${random_id.suffix.hex}"
description = "Label for monitor testing"
color = "#3498db"
}
resource "oneuptime_monitor" "with_labels" {
project_id = var.project_id
name = "TF E2E Labeled Monitor ${random_id.suffix.hex}"
description = "Monitor with attached labels"
monitor_type = "Manual"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -33,7 +33,6 @@ resource "random_id" "suffix" {
# Test Case 1: Basic Probe
resource "oneuptime_probe" "basic" {
project_id = var.project_id
key = "tf-e2e-probe-basic-${random_id.suffix.hex}"
name = "TF E2E Basic Probe ${random_id.suffix.hex}"
description = "Basic probe created by Terraform E2E tests"
@@ -42,7 +41,6 @@ resource "oneuptime_probe" "basic" {
# Test Case 2: Probe with Different Version
resource "oneuptime_probe" "versioned" {
project_id = var.project_id
key = "tf-e2e-probe-v2-${random_id.suffix.hex}"
name = "TF E2E Versioned Probe ${random_id.suffix.hex}"
description = "Probe with specific version"
@@ -51,7 +49,6 @@ resource "oneuptime_probe" "versioned" {
# Test Case 3: Probe with Auto-Enable Setting
resource "oneuptime_probe" "auto_enable" {
project_id = var.project_id
key = "tf-e2e-probe-auto-${random_id.suffix.hex}"
name = "TF E2E Auto-Enable Probe ${random_id.suffix.hex}"
description = "Probe with auto-enable on new monitors"
@@ -61,14 +58,12 @@ resource "oneuptime_probe" "auto_enable" {
# Test Case 4: Probe with Labels
resource "oneuptime_label" "probe_label" {
project_id = var.project_id
name = "TF E2E Probe Label ${random_id.suffix.hex}"
description = "Label for probe testing"
color = "#9b59b6"
}
resource "oneuptime_probe" "with_labels" {
project_id = var.project_id
key = "tf-e2e-probe-labeled-${random_id.suffix.hex}"
name = "TF E2E Labeled Probe ${random_id.suffix.hex}"
description = "Probe with attached labels"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -29,7 +29,6 @@ resource "random_id" "suffix" {
# Test Case 1: Public Status Page
resource "oneuptime_status_page" "public" {
project_id = var.project_id
name = "TF E2E Public Status Page ${random_id.suffix.hex}"
description = "Public status page created by Terraform E2E tests"
page_title = "Public Status"
@@ -41,7 +40,6 @@ resource "oneuptime_status_page" "public" {
# Test Case 2: Private Status Page
resource "oneuptime_status_page" "private" {
project_id = var.project_id
name = "TF E2E Private Status Page ${random_id.suffix.hex}"
description = "Private status page for internal use"
page_title = "Private Status"
@@ -53,7 +51,6 @@ resource "oneuptime_status_page" "private" {
# Test Case 3: Status Page with Email Subscribers
resource "oneuptime_status_page" "with_email" {
project_id = var.project_id
name = "TF E2E Email Subscribers Page ${random_id.suffix.hex}"
description = "Status page with email subscriber notifications"
page_title = "Email Status"
@@ -65,7 +62,6 @@ resource "oneuptime_status_page" "with_email" {
# Test Case 4: Status Page with Custom Branding Settings
resource "oneuptime_status_page" "branded" {
project_id = var.project_id
name = "TF E2E Branded Status Page ${random_id.suffix.hex}"
description = "Status page with custom branding"
page_title = "Branded Status"
@@ -78,14 +74,12 @@ resource "oneuptime_status_page" "branded" {
# Test Case 5: Status Page with Labels
resource "oneuptime_label" "status_page_label" {
project_id = var.project_id
name = "TF E2E Status Page Label ${random_id.suffix.hex}"
description = "Label for status page testing"
color = "#e74c3c"
}
resource "oneuptime_status_page" "with_labels" {
project_id = var.project_id
name = "TF E2E Labeled Status Page ${random_id.suffix.hex}"
description = "Status page with attached labels"
page_title = "Labeled Status"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -35,21 +35,18 @@ resource "random_id" "suffix" {
# Step 1: Create the base domain
resource "oneuptime_domain" "primary" {
project_id = var.project_id
domain = "primary-${random_id.suffix.hex}.example.com"
is_verified = true
}
# Step 2: Create a secondary domain for multiple domain testing
resource "oneuptime_domain" "secondary" {
project_id = var.project_id
domain = "secondary-${random_id.suffix.hex}.example.com"
is_verified = true
}
# Step 3: Create the main status page
resource "oneuptime_status_page" "main" {
project_id = var.project_id
name = "TF E2E Main Status Page ${random_id.suffix.hex}"
description = "Main status page with custom domains"
page_title = "System Status"
@@ -64,7 +61,6 @@ resource "oneuptime_status_page" "main" {
# Step 4: Create a secondary status page
resource "oneuptime_status_page" "secondary" {
project_id = var.project_id
name = "TF E2E Secondary Status Page ${random_id.suffix.hex}"
description = "Secondary status page for testing"
page_title = "Secondary Status"
@@ -76,7 +72,6 @@ resource "oneuptime_status_page" "secondary" {
# Step 5: Link primary domain to main status page
resource "oneuptime_status_page_domain" "primary_main" {
project_id = var.project_id
domain_id = oneuptime_domain.primary.id
status_page_id = oneuptime_status_page.main.id
subdomain = "status"
@@ -87,7 +82,6 @@ resource "oneuptime_status_page_domain" "primary_main" {
# Step 6: Link secondary domain to main status page (multiple domains on one page)
resource "oneuptime_status_page_domain" "secondary_main" {
project_id = var.project_id
domain_id = oneuptime_domain.secondary.id
status_page_id = oneuptime_status_page.main.id
subdomain = "api-status"
@@ -97,7 +91,6 @@ resource "oneuptime_status_page_domain" "secondary_main" {
# Step 7: Link primary domain to secondary status page (one domain, multiple pages)
resource "oneuptime_status_page_domain" "primary_secondary" {
project_id = var.project_id
domain_id = oneuptime_domain.primary.id
status_page_id = oneuptime_status_page.secondary.id
subdomain = "internal"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -33,7 +33,6 @@ resource "random_id" "suffix" {
# Test Case 1: Manual Monitor - No monitor_steps (server provides defaults)
resource "oneuptime_monitor" "manual_no_steps" {
project_id = var.project_id
name = "TF Manual No Steps ${random_id.suffix.hex}"
description = "Manual monitor without explicit monitor_steps"
monitor_type = "Manual"
@@ -41,7 +40,6 @@ resource "oneuptime_monitor" "manual_no_steps" {
# Test Case 2: Manual Monitor - With description only (server provides monitor_steps)
resource "oneuptime_monitor" "manual_with_description" {
project_id = var.project_id
name = "TF Manual With Description ${random_id.suffix.hex}"
description = "Manual monitor with custom description"
monitor_type = "Manual"
@@ -49,7 +47,6 @@ resource "oneuptime_monitor" "manual_with_description" {
# Test Case 3: Monitor with monitoring interval
resource "oneuptime_monitor" "with_interval" {
project_id = var.project_id
name = "TF Monitor With Interval ${random_id.suffix.hex}"
description = "Monitor with custom monitoring interval"
monitor_type = "Manual"
@@ -58,7 +55,6 @@ resource "oneuptime_monitor" "with_interval" {
# Test Case 4: Monitor with disable flag
resource "oneuptime_monitor" "disabled" {
project_id = var.project_id
name = "TF Disabled Monitor ${random_id.suffix.hex}"
description = "Monitor that is disabled"
monitor_type = "Manual"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -31,7 +31,6 @@ resource "random_id" "suffix" {
# Test Case 1: Manual Monitor
resource "oneuptime_monitor" "manual" {
project_id = var.project_id
name = "TF Manual Type ${random_id.suffix.hex}"
description = "Manual type monitor for testing"
monitor_type = "Manual"
@@ -39,7 +38,6 @@ resource "oneuptime_monitor" "manual" {
# Test Case 2: Incoming Request Monitor
resource "oneuptime_monitor" "incoming_request" {
project_id = var.project_id
name = "TF Incoming Request Type ${random_id.suffix.hex}"
description = "Incoming Request type monitor for testing"
monitor_type = "Incoming Request"
@@ -47,7 +45,6 @@ resource "oneuptime_monitor" "incoming_request" {
# Test Case 3: Server Monitor
resource "oneuptime_monitor" "server" {
project_id = var.project_id
name = "TF Server Type ${random_id.suffix.hex}"
description = "Server type monitor for agent-based monitoring"
monitor_type = "Server"
@@ -55,14 +52,12 @@ resource "oneuptime_monitor" "server" {
# Test Case 4: Multiple monitors of same type (uniqueness test)
resource "oneuptime_monitor" "manual_2" {
project_id = var.project_id
name = "TF Manual Type 2 ${random_id.suffix.hex}"
description = "Second manual monitor"
monitor_type = "Manual"
}
resource "oneuptime_monitor" "manual_3" {
project_id = var.project_id
name = "TF Manual Type 3 ${random_id.suffix.hex}"
description = "Third manual monitor"
monitor_type = "Manual"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -30,7 +30,6 @@ resource "random_id" "suffix" {
# First, create incident severity and state for testing
resource "oneuptime_incident_severity" "test_severity" {
project_id = var.project_id
name = "TF Test Severity ${random_id.suffix.hex}"
description = "Test severity for incident CRUD"
color = "#e74c3c"
@@ -38,7 +37,6 @@ resource "oneuptime_incident_severity" "test_severity" {
}
resource "oneuptime_incident_state" "test_state" {
project_id = var.project_id
name = "TF Test State ${random_id.suffix.hex}"
description = "Test state for incident CRUD"
color = "#3498db"
@@ -47,7 +45,6 @@ resource "oneuptime_incident_state" "test_state" {
# Test Case 1: Basic Incident
resource "oneuptime_incident" "basic" {
project_id = var.project_id
title = "TF Basic Incident ${random_id.suffix.hex}"
description = "Basic incident created by Terraform E2E tests"
current_incident_state_id = oneuptime_incident_state.test_state.id
@@ -56,7 +53,6 @@ resource "oneuptime_incident" "basic" {
# Test Case 2: Incident with root cause
resource "oneuptime_incident" "with_root_cause" {
project_id = var.project_id
title = "TF Incident With Root Cause ${random_id.suffix.hex}"
description = "Incident with detailed root cause analysis"
current_incident_state_id = oneuptime_incident_state.test_state.id
@@ -66,7 +62,6 @@ resource "oneuptime_incident" "with_root_cause" {
# Test Case 3: Incident with visibility settings
resource "oneuptime_incident" "visibility_settings" {
project_id = var.project_id
title = "TF Visibility Incident ${random_id.suffix.hex}"
description = "Incident with custom visibility"
current_incident_state_id = oneuptime_incident_state.test_state.id
@@ -77,14 +72,12 @@ resource "oneuptime_incident" "visibility_settings" {
# Test Case 4: Incident with labels
resource "oneuptime_label" "incident_label" {
project_id = var.project_id
name = "TF Incident Label ${random_id.suffix.hex}"
description = "Label for incident testing"
color = "#9b59b6"
}
resource "oneuptime_incident" "with_labels" {
project_id = var.project_id
title = "TF Labeled Incident ${random_id.suffix.hex}"
description = "Incident with labels attached"
current_incident_state_id = oneuptime_incident_state.test_state.id

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -30,7 +30,6 @@ resource "random_id" "suffix" {
# Create prerequisites
resource "oneuptime_alert_severity" "test_severity" {
project_id = var.project_id
name = "TF Alert Severity ${random_id.suffix.hex}"
description = "Test severity for alert CRUD"
color = "#f39c12"
@@ -38,7 +37,6 @@ resource "oneuptime_alert_severity" "test_severity" {
}
resource "oneuptime_alert_state" "test_state" {
project_id = var.project_id
name = "TF Alert State ${random_id.suffix.hex}"
description = "Test state for alert CRUD"
color = "#2ecc71"
@@ -46,7 +44,6 @@ resource "oneuptime_alert_state" "test_state" {
}
resource "oneuptime_monitor" "for_alert" {
project_id = var.project_id
name = "TF Monitor For Alert ${random_id.suffix.hex}"
description = "Monitor associated with alerts"
monitor_type = "Manual"
@@ -56,7 +53,6 @@ resource "oneuptime_monitor" "for_alert" {
# Note: We do NOT specify current_alert_state_id because the server
# will set it to the default "Created" state and override any value we provide
resource "oneuptime_alert" "basic" {
project_id = var.project_id
title = "TF Basic Alert ${random_id.suffix.hex}"
description = "Basic alert created by Terraform E2E tests"
alert_severity_id = oneuptime_alert_severity.test_severity.id
@@ -65,7 +61,6 @@ resource "oneuptime_alert" "basic" {
# Test Case 2: Alert with root cause
resource "oneuptime_alert" "with_root_cause" {
project_id = var.project_id
title = "TF Root Cause Alert ${random_id.suffix.hex}"
description = "Alert with root cause analysis"
alert_severity_id = oneuptime_alert_severity.test_severity.id
@@ -75,14 +70,12 @@ resource "oneuptime_alert" "with_root_cause" {
# Test Case 3: Alert with labels
resource "oneuptime_label" "alert_label" {
project_id = var.project_id
name = "TF Alert Label ${random_id.suffix.hex}"
description = "Label for alert testing"
color = "#1abc9c"
}
resource "oneuptime_alert" "with_labels" {
project_id = var.project_id
title = "TF Labeled Alert ${random_id.suffix.hex}"
description = "Alert with labels attached"
alert_severity_id = oneuptime_alert_severity.test_severity.id

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -36,7 +36,6 @@ locals {
# Test Case 1: Basic Scheduled Maintenance
resource "oneuptime_scheduled_maintenance_event" "basic" {
project_id = var.project_id
title = "TF Basic Maintenance ${random_id.suffix.hex}"
description = "Basic scheduled maintenance for testing"
starts_at = local.starts_at
@@ -49,7 +48,6 @@ resource "oneuptime_scheduled_maintenance_event" "basic" {
# Test Case 2: Scheduled Maintenance with visibility
resource "oneuptime_scheduled_maintenance_event" "visibility" {
project_id = var.project_id
title = "TF Visibility Maintenance ${random_id.suffix.hex}"
description = "Maintenance with visibility settings"
starts_at = local.starts_at
@@ -64,14 +62,12 @@ resource "oneuptime_scheduled_maintenance_event" "visibility" {
# Test Case 3: Scheduled Maintenance with labels
resource "oneuptime_label" "maintenance_label" {
project_id = var.project_id
name = "TF Maintenance Label ${random_id.suffix.hex}"
description = "Label for maintenance testing"
color = "#8e44ad"
}
resource "oneuptime_scheduled_maintenance_event" "with_labels" {
project_id = var.project_id
title = "TF Labeled Maintenance ${random_id.suffix.hex}"
description = "Maintenance with labels"
starts_at = local.starts_at

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -30,14 +30,12 @@ resource "random_id" "suffix" {
# Test Case 1: Basic On-Call Policy
resource "oneuptime_on_call_policy" "basic" {
project_id = var.project_id
name = "TF Basic OnCall Policy ${random_id.suffix.hex}"
description = "Basic on-call policy for testing"
}
# Test Case 2: On-Call Policy with repeat settings
resource "oneuptime_on_call_policy" "repeat" {
project_id = var.project_id
name = "TF Repeat OnCall Policy ${random_id.suffix.hex}"
description = "On-call policy with repeat settings"
repeat_policy_if_no_one_acknowledges = true
@@ -45,14 +43,12 @@ resource "oneuptime_on_call_policy" "repeat" {
# Test Case 3: On-Call Policy with labels
resource "oneuptime_label" "oncall_label" {
project_id = var.project_id
name = "TF OnCall Label ${random_id.suffix.hex}"
description = "Label for on-call testing"
color = "#16a085"
}
resource "oneuptime_on_call_policy" "with_labels" {
project_id = var.project_id
name = "TF Labeled OnCall Policy ${random_id.suffix.hex}"
description = "On-call policy with labels"
labels = [oneuptime_label.oncall_label.id]

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -24,21 +24,18 @@ resource "random_id" "suffix" {
# Test Case 1: Basic Monitor Group
resource "oneuptime_monitor_group" "basic" {
project_id = var.project_id
name = "TF Basic Monitor Group ${random_id.suffix.hex}"
description = "Basic monitor group for testing"
}
# Test Case 2: Monitor Group with labels
resource "oneuptime_label" "group_label" {
project_id = var.project_id
name = "TF Group Label ${random_id.suffix.hex}"
description = "Label for monitor group testing"
color = "#27ae60"
}
resource "oneuptime_monitor_group" "with_labels" {
project_id = var.project_id
name = "TF Labeled Monitor Group ${random_id.suffix.hex}"
description = "Monitor group with labels"
labels = [oneuptime_label.group_label.id]
@@ -46,7 +43,6 @@ resource "oneuptime_monitor_group" "with_labels" {
# Test Case 3: Multiple monitor groups
resource "oneuptime_monitor_group" "secondary" {
project_id = var.project_id
name = "TF Secondary Monitor Group ${random_id.suffix.hex}"
description = "Secondary monitor group"
}

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -24,27 +24,23 @@ resource "random_id" "suffix" {
# Test Case 1: Basic Team
resource "oneuptime_team" "basic" {
project_id = var.project_id
name = "TF Basic Team ${random_id.suffix.hex}"
description = "Basic team for testing"
}
# Test Case 2: Team with description
resource "oneuptime_team" "detailed" {
project_id = var.project_id
name = "TF Detailed Team ${random_id.suffix.hex}"
description = "A detailed team with comprehensive description for testing various scenarios"
}
# Test Case 3: Multiple teams (uniqueness)
resource "oneuptime_team" "engineering" {
project_id = var.project_id
name = "TF Engineering Team ${random_id.suffix.hex}"
description = "Engineering team"
}
resource "oneuptime_team" "operations" {
project_id = var.project_id
name = "TF Operations Team ${random_id.suffix.hex}"
description = "Operations team"
}

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -32,7 +32,6 @@ resource "random_id" "suffix" {
# Create monitor statuses for criteria
resource "oneuptime_monitor_status" "operational" {
project_id = var.project_id
name = "TF Operational ${random_id.suffix.hex}"
description = "Monitor is operational"
color = "#2ecc71"
@@ -41,7 +40,6 @@ resource "oneuptime_monitor_status" "operational" {
}
resource "oneuptime_monitor_status" "degraded" {
project_id = var.project_id
name = "TF Degraded ${random_id.suffix.hex}"
description = "Monitor is degraded"
color = "#f39c12"
@@ -50,7 +48,6 @@ resource "oneuptime_monitor_status" "degraded" {
}
resource "oneuptime_monitor_status" "offline" {
project_id = var.project_id
name = "TF Offline ${random_id.suffix.hex}"
description = "Monitor is offline"
color = "#e74c3c"
@@ -62,7 +59,6 @@ resource "oneuptime_monitor_status" "offline" {
# Test Case 1: Website Monitor with Monitor Steps
# =============================================================================
resource "oneuptime_monitor" "website" {
project_id = var.project_id
name = "TF Website Monitor ${random_id.suffix.hex}"
description = "Website monitor with URL destination and response criteria"
monitor_type = "Website"
@@ -156,7 +152,6 @@ resource "oneuptime_monitor" "website" {
# Test Case 2: API Monitor with Headers and Body
# =============================================================================
resource "oneuptime_monitor" "api" {
project_id = var.project_id
name = "TF API Monitor ${random_id.suffix.hex}"
description = "API monitor with POST request, headers, and body"
monitor_type = "API"
@@ -232,7 +227,6 @@ resource "oneuptime_monitor" "api" {
# Test Case 3: Ping Monitor
# =============================================================================
resource "oneuptime_monitor" "ping" {
project_id = var.project_id
name = "TF Ping Monitor ${random_id.suffix.hex}"
description = "Ping monitor with hostname destination"
monitor_type = "Ping"
@@ -318,7 +312,6 @@ resource "oneuptime_monitor" "ping" {
# Test Case 4: Port Monitor
# =============================================================================
resource "oneuptime_monitor" "port" {
project_id = var.project_id
name = "TF Port Monitor ${random_id.suffix.hex}"
description = "Port monitor checking HTTPS port"
monitor_type = "Port"
@@ -384,7 +377,6 @@ resource "oneuptime_monitor" "port" {
# Test Case 5: SSL Certificate Monitor
# =============================================================================
resource "oneuptime_monitor" "ssl" {
project_id = var.project_id
name = "TF SSL Certificate Monitor ${random_id.suffix.hex}"
description = "SSL certificate monitor checking certificate validity"
monitor_type = "SSL Certificate"
@@ -471,7 +463,6 @@ resource "oneuptime_monitor" "ssl" {
# Test Case 6: IP Monitor
# =============================================================================
resource "oneuptime_monitor" "ip" {
project_id = var.project_id
name = "TF IP Monitor ${random_id.suffix.hex}"
description = "IP monitor checking connectivity"
monitor_type = "IP"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -34,7 +34,6 @@ resource "random_id" "suffix" {
# Test Case 1: Website Monitor
# =============================================================================
resource "oneuptime_monitor" "website" {
project_id = var.project_id
name = "TF Website Basic ${random_id.suffix.hex}"
description = "Basic website monitor"
monitor_type = "Website"
@@ -44,7 +43,6 @@ resource "oneuptime_monitor" "website" {
# Test Case 2: API Monitor
# =============================================================================
resource "oneuptime_monitor" "api" {
project_id = var.project_id
name = "TF API Basic ${random_id.suffix.hex}"
description = "Basic API monitor"
monitor_type = "API"
@@ -54,7 +52,6 @@ resource "oneuptime_monitor" "api" {
# Test Case 3: Ping Monitor
# =============================================================================
resource "oneuptime_monitor" "ping" {
project_id = var.project_id
name = "TF Ping Basic ${random_id.suffix.hex}"
description = "Basic ping monitor"
monitor_type = "Ping"
@@ -64,7 +61,6 @@ resource "oneuptime_monitor" "ping" {
# Test Case 4: Port Monitor
# =============================================================================
resource "oneuptime_monitor" "port" {
project_id = var.project_id
name = "TF Port Basic ${random_id.suffix.hex}"
description = "Basic port monitor"
monitor_type = "Port"
@@ -74,7 +70,6 @@ resource "oneuptime_monitor" "port" {
# Test Case 5: SSL Certificate Monitor
# =============================================================================
resource "oneuptime_monitor" "ssl" {
project_id = var.project_id
name = "TF SSL Basic ${random_id.suffix.hex}"
description = "Basic SSL certificate monitor"
monitor_type = "SSL Certificate"
@@ -84,7 +79,6 @@ resource "oneuptime_monitor" "ssl" {
# Test Case 6: IP Monitor
# =============================================================================
resource "oneuptime_monitor" "ip" {
project_id = var.project_id
name = "TF IP Basic ${random_id.suffix.hex}"
description = "Basic IP monitor"
monitor_type = "IP"
@@ -94,7 +88,6 @@ resource "oneuptime_monitor" "ip" {
# Test Case 7: Incoming Request Monitor (Heartbeat)
# =============================================================================
resource "oneuptime_monitor" "incoming_request" {
project_id = var.project_id
name = "TF Incoming Request Basic ${random_id.suffix.hex}"
description = "Basic incoming request (heartbeat) monitor"
monitor_type = "Incoming Request"
@@ -104,7 +97,6 @@ resource "oneuptime_monitor" "incoming_request" {
# Test Case 8: Server Monitor
# =============================================================================
resource "oneuptime_monitor" "server" {
project_id = var.project_id
name = "TF Server Basic ${random_id.suffix.hex}"
description = "Basic server monitor"
monitor_type = "Server"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -24,21 +24,18 @@ resource "random_id" "suffix" {
# This test ensures labels are treated as order-independent and do not cause drift.
resource "oneuptime_label" "first" {
project_id = var.project_id
name = "TF E2E Label First ${random_id.suffix.hex}"
description = "First label for order idempotency"
color = "#3498db"
}
resource "oneuptime_label" "second" {
project_id = var.project_id
name = "TF E2E Label Second ${random_id.suffix.hex}"
description = "Second label for order idempotency"
color = "#e74c3c"
}
resource "oneuptime_probe" "with_labels" {
project_id = var.project_id
key = "tf-e2e-probe-label-order-${random_id.suffix.hex}"
name = "TF E2E Probe Label Order ${random_id.suffix.hex}"
description = "Probe with labels in non-sorted order"

View File

@@ -9,7 +9,3 @@ variable "api_key" {
sensitive = true
}
variable "project_id" {
type = string
description = "OneUptime Project ID"
}

View File

@@ -572,7 +572,14 @@ ${this.generateValidObjectTypesMap()}
),
);
if (attr.required) {
// project_id is inferred from API key authentication, so make it computed-only
const isProjectIdField: boolean =
name === "project_id" || name === "projectId";
if (isProjectIdField) {
// Project ID is always computed from API key - users don't need to provide it
options.push("Computed: true");
} else if (attr.required) {
options.push("Required: true");
} else if (attr.optional && attr.computed) {
// Handle fields that are both optional and computed (server-managed with optional user input)
@@ -1153,14 +1160,14 @@ func (r *${resourceTypeName}Resource) Delete(ctx context.Context, req resource.D
const updateSchema: any = resource.operationSchemas?.update || {};
const conditionalAssignments: string[] = [];
// Fields that should never be included in update requests (truly immutable)
const immutableFields: Array<string> = ["projectId", "project_id"];
// Fields that should never be included in requests (inferred from API key)
const serverInferredFields: Array<string> = ["projectId", "project_id"];
// Check if there are any fields to process
const hasFields: boolean = Object.entries(updateSchema).some(
([name, attr]: [string, any]) => {
return (
name !== "id" && !attr.computed && !immutableFields.includes(name)
name !== "id" && !attr.computed && !serverInferredFields.includes(name)
);
},
);
@@ -1184,8 +1191,8 @@ func (r *${resourceTypeName}Resource) Delete(ctx context.Context, req resource.D
continue;
}
// Skip truly immutable fields
if (immutableFields.includes(name)) {
// Skip server-inferred fields (project_id is inferred from API key)
if (serverInferredFields.includes(name)) {
continue;
}
@@ -1293,8 +1300,8 @@ func (r *${resourceTypeName}Resource) Delete(ctx context.Context, req resource.D
): string {
const fields: string[] = [];
// Fields that should not be included in update requests
const immutableFields: Array<string> = ["projectId", "project_id"];
// Fields that should not be included in requests (inferred from API key)
const serverInferredFields: Array<string> = ["projectId", "project_id"];
for (const [name, attr] of Object.entries(schema)) {
if (name === "id") {
@@ -1306,8 +1313,8 @@ func (r *${resourceTypeName}Resource) Delete(ctx context.Context, req resource.D
continue;
}
// Skip immutable fields in update requests
if (isUpdate && immutableFields.includes(name)) {
// Skip project_id - it's inferred from API key authentication
if (serverInferredFields.includes(name)) {
continue;
}