Template Scheduling in Jobs
When we deploy some infrastructure we can set some other template to execute in some specific time for example to destroy the infrascturture or resize it.
This example will show the basic logic to accomplish but it is not creaing a real VM it just running some scripts that are showing the injected terraform variables when running the job.
Example
Define the size as global terraform variables for example SIZE_SMALL and SIZE_BIG, this terraform variables will be injected in our future templates "schedule1" and "schedule2" as terraform variables dynamically.
![](https://docs.terrakube.io/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F4461895%2F225761283-27d0a9c2-6c3d-430c-9d80-66cb6a2d51d8.png&width=768&dpr=4&quality=100&sign=36ada0be&sv=1)
We define a job template that creates the infrasctucture using some small size and create two schedule at the end of the template.
Create Virtual Machine (Example)
This will create our "virtual machine" using size small, after it will set two addtional schedules to run every 5 and 10 minutes to resize it.
We will have 3 templates, one to create the virtual machine and two to resize it
![](https://docs.terrakube.io/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F4461895%2F225761347-18b09e5d-29ae-4815-b27f-ea219db8ffa8.png&width=768&dpr=4&quality=100&sign=e47da783&sv=1)
Once the workspace is executed creating the infrasctructure two automatic shedules will be define
![](https://docs.terrakube.io/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F4461895%2F225761484-ad328fb4-7275-48b0-ab99-3a6a7a219488.png&width=768&dpr=4&quality=100&sign=97217af1&sv=1)
Differente jobs will be executed.
Resize Template (schedule1)
Inject the new size using global terraform variables
![](https://docs.terrakube.io/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F4461895%2F225762481-af2a0779-8383-472a-90a1-61fd362d0c50.png&width=768&dpr=4&quality=100&sign=f094693e&sv=1)
Resize Template (schedule2)
Inject the new size using global terraform variables
![](https://docs.terrakube.io/~gitbook/image?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F4461895%2F225762637-f18f0335-c49a-4761-9a25-446ae196f8d1.png&width=768&dpr=4&quality=100&sign=c5f1a614&sv=1)
Last updated