Getting Started with Pyvider¶
Welcome to Pyvider! This guide will help you get started building Terraform providers in Python.
๐ค 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.
What is Pyvider?¶
Pyvider is a Python framework for building Terraform providers. It lets you create fully functional Terraform providers using Python instead of Go, making provider development more accessible and leveraging Python's rich ecosystem.
Key Features¶
- ๐ Build Providers in Python - Use Python instead of Go for Terraform provider development
- ๐ง Type-Safe Components - Strong typing with attrs-based schema definitions
- โก Async-First Design - Native async/await support for efficient I/O operations
- ๐งฉ Component System - Modular, reusable components with decorator-based registration
- ๐ Protocol v6 Support - Full Terraform Plugin Protocol v6 implementation
- ๐ gRPC Infrastructure - Built on pyvider-rpcplugin for reliable communication
Installation¶
Using uv (Recommended)¶
Quick Start¶
Ready to build your first provider? Check out the Quick Start Guide for a hands-on introduction that walks you through creating a working provider in about 5 minutes!
Documentation Structure¶
- Quick Start Guide - Build your first provider in 5 minutes
- Core Concepts - Understanding Pyvider architecture
- API Reference - Complete API documentation
- Examples - Working examples and patterns
Prerequisites¶
Before getting started with Pyvider, you should have:
- โ Python 3.11 or higher installed
- โ Basic understanding of Terraform concepts (providers, resources, data sources)
- โ Familiarity with Python async/await patterns
- โ Basic knowledge of type hints and attrs
Core Concepts¶
Component Types¶
Pyvider supports four main component types:
- Providers - Configure and authenticate provider instances
- Resources - Manage infrastructure with full CRUD operations
- Data Sources - Read-only queries for external data
- Functions - Callable utilities for data transformation
Hub-Based Discovery¶
Components self-register using decorators:
from pyvider import register_resource, ResourceBase
@register_resource("my_resource")
class MyResource(ResourceBase):
"""My custom resource."""
# Implementation here
Schema System¶
Type-safe schemas using attrs:
from attrs import define
from pyvider.schema import Field
@define
class MyResourceConfig:
"""Configuration for my resource."""
name: str = Field(description="Resource name")
enabled: bool = Field(default=False, description="Enable feature")
Architecture Overview¶
Pyvider is built on several key technologies:
- Terraform Plugin Protocol v6 - Industry-standard provider protocol
- gRPC - High-performance RPC via pyvider-rpcplugin
- attrs - Type-safe data modeling
- asyncio - Efficient async operations
- provide-foundation - Logging, configuration, and utilities
Example: Simple Data Source¶
Here's a minimal example to give you a taste of Pyvider:
from attrs import define
from pyvider import register_data_source, DataSourceBase
@define
class EnvVarConfig:
"""Configuration for environment variable data source."""
key: str
@define
class EnvVarData:
"""Output data for environment variable."""
value: str | None
@register_data_source("env_var")
class EnvVarDataSource(DataSourceBase[EnvVarConfig, EnvVarData]):
"""Read environment variables."""
async def read(self, config: EnvVarConfig) -> EnvVarData:
import os
return EnvVarData(value=os.getenv(config.key))
Getting Help¶
- GitHub Issues: Report bugs or request features
- Documentation: Comprehensive guides in the
docs/directory - Examples: Working examples in the
examples/directory
Related Projects¶
- pyvider-components - Example components library
- terraform-provider-pyvider - pre-release provider for testing
- pyvider-rpcplugin - RPC plugin framework
- pyvider-cty - CTY type system
- pyvider-hcl - HCL parsing
Next Steps¶
- Quick Start Guide - Build your first provider
- Core Concepts - Understand Pyvider architecture
- Examples - Explore working examples
- API Reference - Dive into the API
Ready to build your first provider? Head over to the Quick Start Guide!