https://github.com/winebarrel/terraform-provider-cronplan
Terraform provider to validate Amazon EventBridge Cron expressions.
https://github.com/winebarrel/terraform-provider-cronplan
cloudwatch-events cron eventbridge terraform
Last synced: 3 months ago
JSON representation
Terraform provider to validate Amazon EventBridge Cron expressions.
- Host: GitHub
- URL: https://github.com/winebarrel/terraform-provider-cronplan
- Owner: winebarrel
- License: mit
- Created: 2023-09-30T06:08:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-28T08:18:06.000Z (7 months ago)
- Last Synced: 2024-10-19T00:15:40.998Z (6 months ago)
- Topics: cloudwatch-events, cron, eventbridge, terraform
- Language: Go
- Homepage: https://registry.terraform.io/providers/winebarrel/cronplan
- Size: 204 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-provider-cronplan
[](https://github.com/winebarrel/terraform-provider-cronplan/actions/workflows/ci.yml)
[](https://registry.terraform.io/providers/winebarrel/cronplan/latest/docs)Terraform provider to validate Amazon EventBridge Cron expressions.
If the cron expression is incorrect, an error will occur in terraform plan.

## Usage
```tf
terraform {
required_providers {
cronplan = {
source = "winebarrel/cronplan"
version = ">= 3"
}
}
}provider "cronplan" {
}data "cronplan_expr" "every_weekday" {
# NOTE: Expression is validated with terraform plan.
expr = "cron(5 0 ? * MON-FRI *)"
from = "2023-09-30 10:00:00 UTC" # Optional
}output "every_weekday" {
value = data.cronplan_expr.every_weekday.schedules
}output "every_friday" {
# If the expression is correct, the expression is returned.
value = provider::cronplan::expr("cron(5 0 ? * FRI *)")
}check "every_weekday_schedules" {
assert {
condition = data.cronplan_expr.every_weekday.schedules == tolist([
"Mon, 02 Oct 2023 00:05:00",
"Tue, 03 Oct 2023 00:05:00",
"Wed, 04 Oct 2023 00:05:00",
"Thu, 05 Oct 2023 00:05:00",
"Fri, 06 Oct 2023 00:05:00",
"Mon, 09 Oct 2023 00:05:00",
"Tue, 10 Oct 2023 00:05:00",
"Wed, 11 Oct 2023 00:05:00",
"Thu, 12 Oct 2023 00:05:00",
"Fri, 13 Oct 2023 00:05:00",
])error_message = "Unexpected schedule: \n${join("\n", data.cronplan_expr.every_weekday.schedules)}"
}
}
```## Run locally for development
```sh
cp cronplan.tf.sample cronplan.tf
make tf-plan
```## Related Links
* https://github.com/winebarrel/cronplan
* [Cron expressions reference - Amazon EventBridge](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cron-expressions.html)