Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sets up a scheduled job to trigger events and run functions

License

NotificationsYou must be signed in to change notification settings

terraform-google-modules/terraform-google-scheduled-function

This modules makes it easy to set up a scheduled job to trigger events/run functions.

Compatibility

This module is meant for use with Terraform v1.3+ and tested using Terraform v1.10+.If you haven'tupgraded and need a Terraform0.12.x-compatible version of this module, the last released versionintended for Terraform 0.12.x isv1.6.0.

Usage

You can go to the examples folder, however the usage of the module could be like this in your own main.tf file:

module"scheduled-function" {source="terraform-google-modules/scheduled-function/google"version="0.1.0"project_id="<PROJECT ID>"job_name="<NAME_OF_JOB>"job_schedule="<CRON_SYNTAX_SCHEDULE>"function_entry_point="<NAME_OF_FUNCTION>"function_source_directory="<DIRECTORY_OF_FUNCTION_SOURCE>"function_name="<RESOURCE_NAMES>"region="<REGION>"}

Then perform the following commands on the root folder:

  • terraform init to get the plugins
  • terraform plan to see the infrastructure plan
  • terraform apply to apply the infrastructure build
  • terraform destroy to destroy the built infrastructure

Inputs

NameDescriptionTypeDefaultRequired
bucket_force_destroyWhen deleting the GCS bucket containing the cloud function, delete all objects in the bucket first.booltrueno
bucket_nameThe name to apply to the bucket. Will default to a string of -scheduled-function-XXXX> with XXXX being random characters.string""no
create_bucketCreate bucket (default). Set tofalse to use existing onebooltrueno
files_to_exclude_in_source_dirSpecify files to ignore when reading the source_dirlist(string)[]no
function_available_memory_mbThe amount of memory in megabytes allotted for the function to use.number256no
function_descriptionThe description of the function.string"Processes log export events provided through a Pub/Sub topic subscription."no
function_docker_registryDocker Registry to use for storing the function's Docker images. Allowed values are CONTAINER_REGISTRY (default) and ARTIFACT_REGISTRY.stringnullno
function_docker_repositoryUser managed repository created in Artifact Registry optionally with a customer managed encryption key. If specified, deployments will use Artifact Registry.stringnullno
function_entry_pointThe name of a method in the function source which will be invoked when the function is executed.stringn/ayes
function_environment_variablesA set of key/value environment variable pairs to assign to the function.map(string){}no
function_event_trigger_failure_policy_retryA toggle to determine if the function should be retried on failure.boolfalseno
function_kms_key_nameResource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function resources.stringnullno
function_labelsA set of key/value label pairs to assign to the function.map(string){}no
function_max_instancesThe maximum number of parallel executions of the function.numbernullno
function_nameThe name to apply to the functionstringn/ayes
function_runtimeThe runtime in which the function will be executed.string"nodejs20"no
function_secret_environment_variablesA list of maps which contains key, project_id, secret_name (not the full secret id) and version to assign to the function as a set of secret environment variables.list(map(string))[]no
function_service_account_emailThe service account to run the function as.string""no
function_source_archive_bucket_labelsA set of key/value label pairs to assign to the function source archive bucket.map(string){}no
function_source_dependent_filesA list of any terraform createdlocal_files that the module will wait for before creating the archive.
list(object({
filename = string
id = string
}))
[]no
function_source_directoryThe contents of this directory will be archived and used as the function source.stringn/ayes
function_timeout_sThe amount of time in seconds allotted for the execution of the function.number60no
grant_token_creatorSpecify true if you want to add token creator role to the default Pub/Sub SAboolfalseno
ingress_settingsThe ingress settings for the function. Allowed values are ALLOW_ALL, ALLOW_INTERNAL_AND_GCLB and ALLOW_INTERNAL_ONLY. Changes to this field will recreate the cloud function.stringnullno
job_descriptionAddition text to describe the jobstring""no
job_nameThe name of the scheduled job to runstringnullno
job_scheduleThe job frequency, in cron syntaxstring"*/2 * * * *"no
message_dataThe data to send in the topic message.string"dGVzdA=="no
project_idThe ID of the project where the resources will be createdstringn/ayes
regionThe region in which resources will be applied.stringn/ayes
scheduler_jobAn existing Cloud Scheduler job instanceobject({ name = string })nullno
time_zoneThe timezone to use in schedulerstring"Etc/UTC"no
topic_kms_key_nameThe resource name of the Cloud KMS CryptoKey to be used to protect access to messages published on this topic.stringnullno
topic_labelsA set of key/value label pairs to assign to the pubsub topic.map(string){}no
topic_nameName of pubsub topic connecting the scheduled job and the functionstring"test-topic"no
vpc_connectorThe VPC Network Connector that this cloud function can connect to. It should be set up as fully-qualified URI. The format of this field is projects//locations//connectors/*.stringnullno
vpc_connector_egress_settingsThe egress settings for the connector, controlling what traffic is diverted through it. Allowed values are ALL_TRAFFIC and PRIVATE_RANGES_ONLY. If unset, this field preserves the previously set value.stringnullno

Outputs

NameDescription
nameThe name of the job created
pubsub_topic_namePubSub topic name
scheduler_jobThe Cloud Scheduler job instance

Requirements

These sections describe requirements for using this module.

Software

The following dependencies must be available:

App Engine

Note that this module requires App Engine being configured in the specified project/region.This is because Google Cloud Scheduler is dependent on the project being configured with App Engine.Refer to theGoogle Cloud Scheduler documentationinformation on the App Engine dependency.

The recommended way to create projects with App Engine enabled is via theProject Factory module.There is an example of how to create the projectwithin that module

Service Account

A service account with the following roles must be used to provisionthe resources of this module:

  • Storage Admin:roles/storage.admin
  • PubSub Editor:roles/pubsub.editor
  • Cloudscheduler Admin:roles/cloudscheduler.admin
  • Cloudfunctions Developer:roles/cloudfunctions.developer
  • IAM ServiceAccount User:roles/iam.serviceAccountUser

TheProject Factory module and theIAM module may be used in combination to provision aservice account with the necessary roles applied.

APIs

A project with the following APIs enabled must be used to host theresources of this module:

  • Cloud Scheduler API:cloudscheduler.googleapis.com
  • Cloud PubSub API:pubsub.googleapis.com
  • Cloud Functions API:cloudfunctions.googleapis.com
  • Cloud Build API:cloudbuild.googleapis.com
  • App Engine Admin API:appengine.googleapis.com

TheProject Factory module can be used toprovision a project with the necessary APIs enabled.

Contributing

Refer to thecontribution guidelines forinformation on contributing to this module.

Packages

No packages published

Contributors34


[8]ページ先頭

©2009-2025 Movatter.jp