This is a Terraform provider for managing Google appscript projects.
-
Download the latest compiled binary from GitHub releases.
-
Unzip/untar the archive.
-
Move it into
$HOME/.terraform.d/plugins
:$ mkdir -p $HOME/.terraform.d/plugins/linux_amd64 $ mv terraform-provider-googleappscript $HOME/.terraform.d/plugins/terraform-provider-googleappscript_v0.1.0
-
Create your Terraform configurations as normal, and run
terraform init
:$ terraform init
This will find the plugin locally.
-
Since google appscript api does not support service account authentication, you will need a OAuth token file to run provider and unfortunately you will have to renew your token file whenever its expired.
- Go to APIs & Services of Google Cloud Platform
- Create a credential and download as a file
- Run this script with credentials file
- Copy-paste url to your browser
- Give permissions and copy back code to terminal
- Your token file should be created.
-
Create a Terraform configuration file:
provider "googleappscript" { token_file = "token.json" } resource "googleappscript_project" "example" { title = "terraform-example" script { name = "appsscript" type = "JSON" source = "{\"timeZone\":\"America/New_York\",\"exceptionLogging\":\"CLOUD\"}" } script { name = "hello" type = "SERVER_JS" source = "function helloWorld() {\n console.log('goodbye, world!');}" } }
-
Run
terraform init
to pull in the provider:$ terraform init
-
Run
terraform plan
andterraform apply
to create events:$ terraform plan $ terraform apply