https://github.com/chainguard-dev/terraform-google-cron
Terraform module for deploying cron jobs that run on a defined schedule
https://github.com/chainguard-dev/terraform-google-cron
cloudrun terraform terraform-module
Last synced: about 2 months ago
JSON representation
Terraform module for deploying cron jobs that run on a defined schedule
- Host: GitHub
- URL: https://github.com/chainguard-dev/terraform-google-cron
- Owner: chainguard-dev
- License: apache-2.0
- Created: 2023-03-02T16:20:56.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T07:21:05.000Z (about 2 months ago)
- Last Synced: 2025-04-08T08:28:39.476Z (about 2 months ago)
- Topics: cloudrun, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 59.6 KB
- Stars: 3
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cloud Run-based cron jobs.
This repository contains a terraform module for deploying cron jobs that run on a defined schedule.
## Defining a custom cron job.
A cron job can be defined as a simple Go program, with as little code as:
```go
import "log"func main() {
log.Println("hello")
}
```> See our [example](./example/).
## Deploying a custom cron job
With the terraform module provided here, a cron job can be deployed with a little
configuration as:```terraform
module "cron" {
source = "chainguard-dev/cron/google"
version = "v0.1.2"name = "example"
project_id = var.project_id
schedule = "*/8 * * * *" # Every 8 minutes.importpath = "github.com/chainguard-dev/terraform-google-cron/example"
working_dir = path.module
}
```> See our [example](./example/).
## Passing additional configuration
You can pass additional configuration to your custom cron jobs via environment
variables passed to the application. These can be specified in the module:```terraform
env = {
"FOO" : "bar"
}
```> See our [example](./example/).
or as from a secret in Google Secret Manager:
```terraform
env_secret = {
"FOO" : "secret_name_in_secret_manager"
}
```## Requirements
No requirements.
## Providers
| Name | Version |
|------|---------|
| [google](#provider\_google) | n/a |
| [ko](#provider\_ko) | n/a |## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [google_cloud_run_v2_job.job](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_job) | resource |
| [google_cloud_run_v2_job_iam_binding.authorize-calls](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_job_iam_binding) | resource |
| [google_cloud_scheduler_job.cron](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_scheduler_job) | resource |
| [google_project_service.cloud_run_api](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_service) | resource |
| [google_project_service.cloudscheduler](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_service) | resource |
| [google_service_account.delivery](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
| [ko_build.image](https://registry.terraform.io/providers/ko-build/ko/latest/docs/resources/build) | resource |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [base\_image](#input\_base\_image) | The base image that will be used to build the container image. | `string` | `"cgr.dev/chainguard/static:latest-glibc"` | no |
| [cpu](#input\_cpu) | The CPU limit for the job. | `string` | `"1000m"` | no |
| [env](#input\_env) | A map of custom environment variables (e.g. key=value) | `map` | `{}` | no |
| [execution\_environment](#input\_execution\_environment) | The execution environment to use for the job. | `string` | `""` | no |
| [importpath](#input\_importpath) | The import path that contains the cron application. | `string` | n/a | yes |
| [max\_retries](#input\_max\_retries) | The maximum number of times to retry the job. | `number` | `3` | no |
| [memory](#input\_memory) | The memory limit for the job. | `string` | `"512Mi"` | no |
| [name](#input\_name) | Name to prefix to created resources. | `any` | n/a | yes |
| [project\_id](#input\_project\_id) | The project that will host the cron job. | `string` | n/a | yes |
| [region](#input\_region) | The region to run the job. | `string` | `"us-east4"` | no |
| [repository](#input\_repository) | Container repository to publish images to. | `string` | `""` | no |
| [schedule](#input\_schedule) | The cron schedule on which to run the job. | `any` | n/a | yes |
| [secret\_env](#input\_secret\_env) | A map of secrets to mount as environment variables from Google Secrets Manager (e.g. secret\_key=secret\_name) | `map` | `{}` | no |
| [service\_account](#input\_service\_account) | The email address of the service account to run the service as, and to invoke the job as. | `string` | n/a | yes |
| [timeout](#input\_timeout) | The maximum amount of time in seconds to allow the job to run. | `string` | `"600s"` | no |
| [vpc\_access](#input\_vpc\_access) | The VPC to send egress to. For more information, visit https://cloud.google.com/run/docs/configuring/vpc-direct-vpc |object({| `null` | no |
# Currently, only one network interface is supported.
network_interfaces = list(object({
network = string
subnetwork = string
tags = optional(list(string))
}))
# Egress is one of "PRIVATE_RANGES_ONLY", "ALL_TRAFFIC", or "ALL_PRIVATE_RANGES"
egress = string
})
| [working\_dir](#input\_working\_dir) | The working directory that contains the importpath. | `string` | n/a | yes |## Outputs
No outputs.