Pyvider
Build Terraform providers in pure Python.
A complete Python implementation of the Terraform Plugin Protocol v6, the Cty type system, and schema validation.
Why Pyvider?
Pyvider bridges the gap between Python's rich ecosystem and Terraform's infrastructure capabilities. Until now, building providers meant wrestling with Go.
Native Python
Leverage the vast Python ecosystem and modern Python 3.12+ features like match/case patterns and type annotations.
Async-First Design
Built with modern async programming patterns for efficient resource operations and concurrent workflows.
Type Safety
Comprehensive type checking with MyPy compatibility and built-in validation for robust provider development.
Declarative APIs
Define resources and schemas with minimal boilerplate using elegant, functional-style declarations.
Complete Compatibility
Full implementation of the Terraform Plugin Protocol v6 for seamless integration with the Terraform ecosystem.
Security by Design
Built-in mTLS security and encryption for secure plugin communication between Terraform and your provider.
Provider Capabilities
Pyvider gives you all the tools to build full-featured Terraform providers in Python.
Resources
Create, read, update, and delete operations for managing infrastructure resources.
Data Sources
Query and retrieve information about existing infrastructure components.
Provider Functions
Custom logic and data transformations for use within Terraform configurations.
Schema Validation
Type-safe configuration with comprehensive validation rules and error reporting.
State Management
Efficient tracking of infrastructure state with support for complex data structures.
Plugin Protocol
Complete implementation of HashiCorp's go-plugin protocol for seamless integration.
Core Packages
Pyvider provides a comprehensive toolkit for building Terraform providers, handling the complexities of protocol communication, type validation, and schema management.
pyvider.rpcplugin
HashiCorp's Plugin Protocol, Made Pythonic
A pure Python implementation of HashiCorp's go-plugin protocol with full mTLS support, enabling seamless integration with Terraform and other compatible tools.
No Foreign Dependencies
True Protocol Compatibility
Security By Design
Modern Async Python
pyvider.cty
The Cty Type System in Pure Python
A complete implementation of Terraform's Cty type system enabling precise infrastructure data modeling with strong typing, validation, and serialization.
Bidirectional Conversion
Strong Type Safety
Rich Type System
Built-in Serialization
pyvider.schema
Define, Validate, and Transform Terraform Schemas
A schema definition system for Terraform-compatible resources with validation and transformation, bridging Pythonic code and Terraform's resource modeling.
Declarative Schema Definition
Built-in Validation Rules
Bidirectional Conversion
Schema-Driven Development
pyvider.telemetry
Structured Logging and Operational Visibility
Comprehensive structured logging, tracing, and metrics for operational visibility using OpenTelemetry standards for modern observability.
Structured Logging
Distributed Tracing
Performance Metrics
OpenTelemetry Integration
Define Resources in Python
Pyvider makes it easy to define Terraform resources with Pythonic code! Below is a simple example that shows how you might implement a "room_temperature" resource with Pyvider:
from pyvider.schema import s_resource, a_str, a_num, a_bool from pyvider.resources import register_resource, ResourceContext @register_resource("room_temperature_resource") class RoomTemperatureResource: def get_schema(self): return s_resource({ "room": a_str( required=True, description="The room name." ), "description": a_str( # Corrected: a_string -> a_str description="An optional description of the room." ), "fahrenheit": a_bool( required=True, default=True, description="Is the temperature in Fahrenheit?" ), "temperature": a_num( required=True, default=71, description="The desired room temperature." ), "fan": a_bool( computed=True, description="Whether the HVAC fan is on." ) }) async def read(self, ctx: ResourceContext): # Retrieve the current state of the resource return ctx.state or {} async def plan(self, ctx: ResourceContext): # Plan changes to the resource return ctx.config, None async def apply(self, ctx: ResourceContext): # Apply changes to the resource return ctx.planned_state, None
Ready to Build Infrastructure as Code in Python?
Start creating Terraform providers today with Pyvider.