https://github.com/gilbertrios/terraform-provider-utils
Terraform function-only provider with utilities for string manipulation, encoding, hashing, and data transformation. Perfect for resource naming and data processing.
https://github.com/gilbertrios/terraform-provider-utils
data-transformation hashicorp string-manipulation terraform-functions terraform-plugin utility-functions
Last synced: 3 months ago
JSON representation
Terraform function-only provider with utilities for string manipulation, encoding, hashing, and data transformation. Perfect for resource naming and data processing.
- Host: GitHub
- URL: https://github.com/gilbertrios/terraform-provider-utils
- Owner: gilbertrios
- License: mit
- Created: 2025-11-08T15:04:53.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-11-16T19:25:00.000Z (8 months ago)
- Last Synced: 2025-11-16T21:15:07.820Z (8 months ago)
- Topics: data-transformation, hashicorp, string-manipulation, terraform-functions, terraform-plugin, utility-functions
- Language: Go
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Terraform Provider Utils
[](https://golang.org)
[](LICENSE)
A function-only Terraform provider that provides utility functions for data manipulation and transformation in your Terraform configurations.
## ๐ฏ Key Features
- **Encoding & Hashing** - Base64 encoding/decoding, SHA256, MD5 hashing
- **Deterministic ID Generation** - UUID v4 generation from seed values
- **String Manipulation** - Slugify, truncate, reverse, trim, case conversion
- **List Operations** - Join and split operations for list handling
- **Zero Configuration** - No provider configuration required
- **Lightweight** - Pure function provider with no external dependencies
- **Type-Safe** - Strong typing with proper error handling
## ๐ What This Repo Demonstrates
### Terraform Best Practices
- โ
Function-only provider implementation
- โ
Terraform Plugin Framework usage
- โ
Type-safe function definitions
- โ
Comprehensive testing strategy
### Development Best Practices
- โ
Clean, modular Go code
- โ
Extensive unit test coverage
- โ
CI/CD automation with GitHub Actions
- โ
Cross-platform build support
### Documentation
- โ
Comprehensive function reference
- โ
Real-world usage examples
- โ
Developer-friendly guides
## ๐ ๏ธ Tech Stack
**Application**
- Go 1.21+ - Modern Go with generics support
- Terraform Plugin Framework - Official provider framework
- Terraform 1.8+ - Provider-defined functions support
**DevOps**
- GitHub Actions - CI/CD automation
- Makefile - Build automation
- golangci-lint - Code quality checks
## ๐ Available Functions
| Category | Functions |
|----------|-----------|
| **Encoding & Hashing** | `base64_encode`, `base64_decode`, `sha256`, `md5` |
| **ID Generation** | `uuidv4` |
| **String Manipulation** | `slugify`, `truncate`, `reverse`, `trim`, `to_upper`, `to_lower` |
| **List Operations** | `join`, `split` |
See [Function Reference](docs/functions.md) for complete documentation.
## ๐ป Quick Start
### Installation
```bash
git clone https://github.com/gilbertrios/terraform-provider-utils.git
cd terraform-provider-utils
make install
```
See [Installation Guide](docs/installation.md) for manual installation and platform-specific instructions.
### Basic Usage
Add the provider to your Terraform configuration:
```hcl
terraform {
required_providers {
utils = {
source = "gilbertrios/utils"
}
}
}
provider "utils" {}
```
### Example: Resource Naming
```hcl
locals {
environment = "production"
application = "web-app"
# Generate URL-friendly resource name
resource_name = provider::utils::slugify("${local.application} ${local.environment}")
# Result: "web-app-production"
# Create deterministic UUID
resource_id = provider::utils::uuidv4(local.resource_name)
# Result: "a1b2c3d4-e5f6-4789-a012-b3c4d5e6f7a8"
}
```
### Example: Data Transformation
```hcl
locals {
# Parse CSV data
ip_ranges = "10.0.1.0/24,10.0.2.0/24,10.0.3.0/24"
ip_list = provider::utils::split(local.ip_ranges, ",")
# Join tags
tags = ["production", "web", "critical"]
tag_string = provider::utils::join(local.tags, "-")
# Result: "production-web-critical"
}
```
### Example: Content Hashing
```hcl
locals {
config_content = jsonencode({
version = "1.0"
features = ["auth", "api"]
})
# Generate content hash for cache busting
config_hash = provider::utils::sha256(local.config_content)
}
```
## ๐๏ธ Repository Structure
```
terraform-provider-utils/
โโโ main.go # Provider entry point
โโโ go.mod # Go module definition
โโโ Makefile # Build automation
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ CHANGELOG.md # Version history
โ
โโโ internal/
โ โโโ provider/
โ โโโ provider.go # Provider definition
โ โโโ provider_test.go # Provider tests
โ โโโ functions.go # Function implementations
โ โโโ functions_test.go # Function tests
โ
โโโ examples/ # Example configurations
โ โโโ basic/ # Basic usage examples
โ โโโ advanced/ # Real-world use cases
โ
โโโ docs/ # Documentation
โโโ installation.md # Installation guide
โโโ quickstart.md # Quick start guide
โโโ functions.md # Function reference
โโโ usage.md # Usage patterns
โโโ development.md # Development guide
โโโ contributing.md # Contributing guidelines
```
## ๐ Documentation
### Getting Started
- [Installation Guide](docs/installation.md) - Install the provider
- [Quick Start Guide](docs/quickstart.md) - Get up and running quickly
- [Usage Guide](docs/usage.md) - Common patterns and best practices
### Reference
- [Function Reference](docs/functions.md) - Complete API documentation
- [Examples](examples/) - Working example configurations
### Development
- [Development Guide](docs/development.md) - Build and test the provider
- [Contributing Guidelines](docs/contributing.md) - How to contribute
## ๐งช Testing
Run the test suite:
```bash
# Run all tests
make test
# Run with coverage
make test-coverage
# Run specific test
go test ./internal/provider -run TestBase64Encode
```
See [Development Guide](docs/development.md) for detailed testing documentation.
## ๐ CI/CD Pipeline
Automated workflow for:
- โ
Running tests on multiple Go versions
- โ
Linting and formatting checks
- โ
Building binaries for multiple platforms
- โ
Release automation ready
## ๐ก Use Cases
### Consistent Resource Naming
Generate deterministic, URL-friendly names across environments:
```hcl
resource_name = provider::utils::slugify("${var.app_name} ${var.environment}")
```
### Content Hashing
Create cache keys and version identifiers:
```hcl
version_id = provider::utils::sha256(local.config_content)
```
### Data Processing
Transform external data sources (CSV, JSON) for Terraform:
```hcl
ip_list = provider::utils::split(data.http.allowed_ips.body, ",")
```
### Length Constraints
Handle cloud provider name length restrictions:
```hcl
bucket_name = provider::utils::truncate(local.full_name, 63, "")
```
See [Usage Guide](docs/usage.md) for more examples and patterns.
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-function`)
3. Commit your changes (`git commit -m 'Add some amazing function'`)
4. Push to the branch (`git push origin feature/amazing-function`)
5. Open a Pull Request
See [Contributing Guidelines](docs/contributing.md) for detailed instructions.
### ๐ Connect With Me
Interested in Infrastructure as Code, Azure, or DevOps? Let's connect!
- ๐ผ LinkedIn: [Connect with me](https://linkedin.com/in/gilbert-rios-22586918)
- ๐ง Email: [gilbertrios@hotmail.com](mailto:gilbertrios@hotmail.com)
- ๐ก GitHub: [@gilbertrios](https://github.com/gilbertrios)
## ๐ Quick Links
- [Quick Start Guide](docs/quickstart.md) - Get started in 5 minutes
- [Function Reference](docs/functions.md) - Complete API documentation
- [Usage Guide](docs/usage.md) - Real-world patterns and examples
- [Examples Directory](examples/) - Working configurations
---
โญ If you find this project useful, please consider giving it a star!