pyvider_warning_example (Resource)¶
The pyvider_warning_example resource is designed to demonstrate how Terraform providers can issue warnings for deprecated attributes, configuration conflicts, and validation scenarios. This resource is primarily used for testing warning mechanisms during provider development and for educational purposes.
๐ค AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
Note
This provider is currently in POC (proof-of-concept) status and under active development. Features and APIs may change without notice. Not intended for production infrastructure.
This resource showcases Terraform's built-in warning capabilities, demonstrating how providers can guide users through API migrations, deprecate old attributes, and validate configurations with helpful warnings rather than hard errors. It's an invaluable tool for provider developers learning to implement graceful deprecation paths and for users understanding how Terraform communicates configuration guidance.
Capabilities¶
This resource enables you to:
- Provider development: Test and implement warning mechanisms in Terraform providers
- Educational purposes: Learn and demonstrate how Terraform warnings work in practice
- Migration testing: Test deprecated attribute warnings during API version transitions
- Validation testing: Test configuration validation and warning scenarios
- Documentation examples: Provide clear examples of warning patterns in provider docs
- Deprecation paths: Demonstrate graceful migration paths for deprecated attributes
- Configuration validation: Show how to validate mutually exclusive or conflicting attributes
Example Usage¶
resource "pyvider_warning_example" "example" {
name = "example_warning"
}
output "example_name" {
description = "The name of the pyvider_warning_example resource"
value = pyvider_warning_example.example.name
}
Examples¶
Explore these examples to see the resource in action:
- example.tf - Basic warning demonstration and configuration patterns
Argument Reference¶
Schema¶
Optional¶
name(String) -old_name(String) -source_file(String) -
Warning Mechanisms¶
The resource demonstrates several types of Terraform warnings:
1. Deprecated Attribute Warnings¶
When using the old_name attribute, Terraform will issue a deprecation warning:
2. Configuration Validation Warnings¶
The resource validates configuration and issues warnings for:
- Mutually exclusive attributes (name and source_file)
- Missing required configuration (all attributes empty)
3. Migration Path Warnings¶
Demonstrates how to guide users through attribute migrations and API changes gracefully.
Attribute Behavior¶
Configuration Logic¶
| Attribute | Purpose | Warning Behavior |
|---|---|---|
name |
Primary attribute for resource name | No warnings (preferred) |
old_name |
Deprecated attribute | Triggers deprecation warning |
source_file |
Alternative file-based configuration | No warnings (valid alternative) |
Validation Rules¶
nameandsource_fileare mutually exclusive- At least one of
name,old_name, orsource_filemust be specified old_nametriggers a deprecation warning when used
Value Resolution Precedence¶
- If
nameis specified: usesnamevalue - If
old_nameis specified: usesold_namevalue (with warning) - If
source_fileis specified: usesfrom_file:{source_file}format
Configuration Patterns¶
Modern Configuration (No Warnings)¶
Deprecated Configuration (Triggers Warning)¶
resource "pyvider_warning_example" "deprecated" {
old_name = "legacy-style-name"
}
# Warning: Attribute 'old_name' is deprecated. Please use 'name' instead.
File-Based Configuration¶
resource "pyvider_warning_example" "file_based" {
source_file = "config.yaml"
}
# Result: "from_file:config.yaml"
Migration Scenario Testing¶
Before Migration (Triggers Warning)¶
After Migration (No Warning)¶
Conditional Migration¶
variable "use_legacy_config" {
type = bool
default = false
}
resource "pyvider_warning_example" "conditional" {
name = var.use_legacy_config ? null : "modern-config"
old_name = var.use_legacy_config ? "legacy-config" : null
}
Testing Warning Mechanisms¶
Multiple Configuration Methods¶
# Method 1: Direct name (preferred)
resource "pyvider_warning_example" "direct" {
name = "direct-configuration"
}
# Method 2: File-based configuration
resource "pyvider_warning_example" "file_based" {
source_file = "config.yaml"
}
# Method 3: Legacy method (with warning)
resource "pyvider_warning_example" "legacy" {
old_name = "legacy-style"
}
Import¶
Documentation version: 0.0.19 | Last updated: 2025-11-09