This script creates VM with a specific label and does the automatic shutdown of that VM at 18:00 CET and automatic start at 8:00 CET.
To run the script:
- Clone this repository (obviously)
- Create new project under: https://console.cloud.google.com/projectcreate (optional if you have one already)
- Create service account for the newly created project, here: https://console.cloud.google.com/apis/credentials/serviceaccountkey (Pssst: I used 'owner' role to simplify things as this is PoC only)
- from the above account creation, download file in JSON format
- Save the downloaded file into disk
- Edit variables.tf file, set "credential_file" to point to the downloaded JSON file (needs to be locally)
- Edit variables.tf to set the variable called: "project" to the name of the created project. (The value can be easily found in the JSON file too!)
- Initialize plugins:
terraform init
- Run it:
terraform apply