The CronMath provider allows you to perform time arithmetic operations on cron expressions within your Terraform configurations. It uses the cronmath library for cron expression manipulation.
- ➕ Add minutes or hours to cron expressions
- ➖ Subtract minutes or hours from cron expressions
- 🔄 Handle day boundary transitions automatically
- 🌍 Perfect for timezone adjustments
- ⏰ Create staggered schedules easily
terraform {
required_providers {
cronmath = {
source = "ryutaro-asada/cronmath"
version = "~> 1.0"
}
}
}
provider "cronmath" {
# No configuration required
}- Download the latest release from the releases page
- Extract the archive
- Move the binary to
~/.terraform.d/plugins/registry.terraform.io/ryutaro-asada/cronmath/1.0.0/[OS]_[ARCH]/
Calculate a new cron expression by applying time operations:
data "cronmath_calculate" "morning_job" {
input = "30 9 * * *" # 9:30 AM
operations {
type = "sub"
value = 30
unit = "minutes"
}
}
output "adjusted_schedule" {
value = data.cronmath_calculate.morning_job.result # "0 9 * * *"
}# Convert UTC to EST (UTC-5)
data "cronmath_calculate" "est_schedule" {
input = "0 15 * * *" # 3:00 PM UTC
operations {
type = "sub"
value = 5
unit = "hours"
}
}
# Convert UTC to JST (UTC+9)
data "cronmath_calculate" "jst_schedule" {
input = "0 10 * * *" # 10:00 AM UTC
operations {
type = "add"
value = 9
unit = "hours"
}
}# Clone the repository
git clone https://github.com/ryutaro-asada/terraform-provider-cronmath.git
cd terraform-provider-cronmath
# Download dependencies
go mod download
# Build the provider
make build
# Install locally for testing
make install# Run unit tests
make test
# Run acceptance tests
make testacc
# Run specific test
go test -v -run TestCronMathDataSource ./internal/provider/This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
For bugs and feature requests, please open an issue.
- cronmath - The underlying library for cron expression manipulation
- Terraform Plugin Framework - Framework used to build this provider
- Built with Terraform Plugin Framework
- Cron expression manipulation powered by cronmath