A function-only Terraform provider that provides utility functions for data manipulation and transformation in your Terraform configurations.
- 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
- β Function-only provider implementation
- β Terraform Plugin Framework usage
- β Type-safe function definitions
- β Comprehensive testing strategy
- β Clean, modular Go code
- β Extensive unit test coverage
- β CI/CD automation with GitHub Actions
- β Cross-platform build support
- β Comprehensive function reference
- β Real-world usage examples
- β Developer-friendly guides
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
| 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 for complete documentation.
git clone https://github.com/gilbertrios/terraform-provider-utils.git
cd terraform-provider-utils
make installSee Installation Guide for manual installation and platform-specific instructions.
Add the provider to your Terraform configuration:
terraform {
required_providers {
utils = {
source = "gilbertrios/utils"
}
}
}
provider "utils" {}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"
}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"
}locals {
config_content = jsonencode({
version = "1.0"
features = ["auth", "api"]
})
# Generate content hash for cache busting
config_hash = provider::utils::sha256(local.config_content)
}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
- Installation Guide - Install the provider
- Quick Start Guide - Get up and running quickly
- Usage Guide - Common patterns and best practices
- Function Reference - Complete API documentation
- Examples - Working example configurations
- Development Guide - Build and test the provider
- Contributing Guidelines - How to contribute
Run the test suite:
# Run all tests
make test
# Run with coverage
make test-coverage
# Run specific test
go test ./internal/provider -run TestBase64EncodeSee Development Guide for detailed testing documentation.
Automated workflow for:
- β Running tests on multiple Go versions
- β Linting and formatting checks
- β Building binaries for multiple platforms
- β Release automation ready
Generate deterministic, URL-friendly names across environments:
resource_name = provider::utils::slugify("${var.app_name} ${var.environment}")Create cache keys and version identifiers:
version_id = provider::utils::sha256(local.config_content)Transform external data sources (CSV, JSON) for Terraform:
ip_list = provider::utils::split(data.http.allowed_ips.body, ",")Handle cloud provider name length restrictions:
bucket_name = provider::utils::truncate(local.full_name, 63, "")See Usage Guide for more examples and patterns.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-function) - Commit your changes (
git commit -m 'Add some amazing function') - Push to the branch (
git push origin feature/amazing-function) - Open a Pull Request
See Contributing Guidelines for detailed instructions.
Interested in Infrastructure as Code, Azure, or DevOps? Let's connect!
- πΌ LinkedIn: Connect with me
- π§ Email: gilbertrios@hotmail.com
- π‘ GitHub: @gilbertrios
- Quick Start Guide - Get started in 5 minutes
- Function Reference - Complete API documentation
- Usage Guide - Real-world patterns and examples
- Examples Directory - Working configurations
β If you find this project useful, please consider giving it a star!