@@ -7,13 +7,13 @@ date: 2025-02-15 23:21:00+01:00
77excerpt : In this blog I would show you how to schedule serverless applications using
88 Cloud Run and Cloud Scheduler
99focus-keywords : markdown upload wordpress
10- guid : https://xebia.com /wp-json/wp/v2/posts/86328
10+ guid : https://env-xebiainnovationproject-staging.kinsta.cloud /wp-json/wp/v2/posts/102254
1111image : images/banner.jpg
1212og :
1313 description : this goes to the Rankmath og description through meta
1414 image : images/og-banner.jpg
1515slug : try-this-one-5
16- status : draft
16+ status : publish
1717subtitle : using Google Cloud Run and Cloud Scheduler
1818title : Testing markdown upload through wordpress API
1919---
@@ -32,7 +32,7 @@ As I promote the principle of infrastructure as code, I will show you how to do
3232### Create a service account
3333You can create a service account for the scheduler with which to invoke the application as follows:
3434
35- ``` hcl
35+ ``` { . hcl .wp-block-code }
3636resource "google_service_account" "scheduler" {
3737 display_name = "Google Cloud Scheduler"
3838 account_id = "scheduler"
@@ -41,7 +41,7 @@ resource "google_service_account" "scheduler" {
4141### Deploy using your serverless application
4242Next you can deploy your serverless application:
4343
44- ``` hcl
44+ ``` { . hcl .wp-block-code }
4545resource "google_cloud_run_service" "application" {
4646 name = "application"
4747 location = "europe-west1"
@@ -64,7 +64,7 @@ in this case, the applicaton deployed is my trusty [paas-monitor](https://github
6464### Grant the scheduler permission
6565After the application is deploy, you grant the service account permission to invoke it:
6666
67- ``` hcl
67+ ``` { . hcl .wp-block-code }
6868resource "google_cloud_run_service_iam_member" "scheduler-run-invoker" {
6969 role = "roles/run.invoker"
7070 member = "serviceAccount:${google_service_account.scheduler.email}"
@@ -77,7 +77,7 @@ resource "google_cloud_run_service_iam_member" "scheduler-run-invoker" {
7777### Create a schedule
7878Finally you create a schedule to invoke the service as follows:
7979
80- ``` hcl
80+ ``` { . hcl .wp-block-code }
8181resource "google_cloud_scheduler_job" "application" {
8282 name = "application"
8383 description = "invoke every 5 minutes"
@@ -97,7 +97,7 @@ resource "google_cloud_scheduler_job" "application" {
9797The schedule is defined using a [ cron expression] ( https://en.wikipedia.org/wiki/Cron ) . Note
9898that Google Cloud Scheduler requires an app engine application to be deployed:
9999
100- ``` hcl
100+ ``` { . hcl .wp-block-code }
101101resource "google_app_engine_application" "app" {
102102 project = data.google_project.current.project_id
103103 location_id = "europe-west"
@@ -108,7 +108,7 @@ resource "google_app_engine_application" "app" {
108108## Installation
109109If you want to deploy the complete example, download [ main.tf] ( ./main.tf ) and type:
110110
111- ``` bash
111+ ``` { . bash .wp-block-code }
112112export TF_VAR_project=$( gcloud config get-value project)
113113terraform init
114114terraform apply
0 commit comments