Run Tasks (Ad hoc Tasks)
Sometimes you may want to execute arbitrary commands on your deployment container - for example, manually altering the state or manipulating a local file. These commands can be run using Custom Flows, but that requires committing the commands to your git repository, which doesn't always fit the use case. In these cases, it is possible to execute Run a Task on the deployment container.
Permissions to run a one time tasks
Ad hoc tasks allow you to run any command on the deployment container, so by default only organization administrators may run these tasks. You can use custom roles to grant this permission to other users.
Executing a Run Task
From the environment's advanced context menu, click on Run a Task
.
It will prompt you to enter the commands you desire to execute.
Enter the commands, as you would in a bash script. Separate commands with new lines.
When you are ready to run your task - click the RUN A TASK
button below.
Task Timeouts
Tasks have a 30 minute timeout
Your task will be queued and executed on the deployment container, including the local cache env0 saves between deployments. You'll be able to see your commands execute in the Deployment Logs, like any other deployment.
During the task execution, all the variables that are defined in the environment will be available for you to use.
Common Tasks
- Migrate state:
terraform init -migrate-state -force-copy
orecho "yes" | terraform init -migrate-state
- Unlock state:
terraform force-unlock -force LOCK_ID [DIR]
- Retrieve output:
terraform output [options] [NAME]
- Taint a resource
terraform taint [options] <address>
- Move state:
terraform state mv [options] SOURCE DESTINATION
Task Comments
You can add a comment, to let your teammates know why the task was run.
Add a comment, by filling in the "Comment" input down below the bash
input.
The comment will be displayed in the Task page.
Markdown syntax is supported.
Markdown Support
The comment supports Markdown, so you would be able to generate even more context.
Updated 5 months ago