task

task create

task create command creates a new task so that it will run and update task resources. The command generates and outputs a Terraform plan, similar to inspect-mode, of how resources will be modified if the task is created. The command will then ask for user approval before creating the task.

It is not to be used for updating a task and will not create a task if the task name already exists.

Usage

consul-terraform-sync task create [options] -task-file=<task config>

Options:

In addition to general options this command also supports the following:

NameRequiredTypeDescription
-task-fileRequiredstringThe path to the task configuration file. See configuration information for details.
-auto-approve  OptionalbooleanWhether to skip the interactive approval of the plan before creating.

Example

task_example.hcl:

  1. task {
  2. name = "task_a"
  3. description = ""
  4. enabled = true,
  5. providers = []
  6. module = "org/example/module"
  7. version = "1.0.0"
  8. variable_files = []
  9. condition "services" {
  10. names = ["web", "api"]
  11. }
  12. }
  1. task {
  2. name = "task_a"
  3. description = ""
  4. enabled = true,
  5. providers = []
  6. module = "org/example/module"
  7. version = "1.0.0"
  8. variable_files = []
  9. condition "services" {
  10. names = ["web", "api"]
  11. }
  12. }

Shell Session:

  1. $ consul-terraform-sync task create -task-file=task_example.hcl
  2. ==> Inspecting changes to resource if creating task 'task_a'...
  3. Generating plan that Consul-Terraform-Sync will use Terraform to execute
  4. Request ID: 1da3e8e0-87c3-069b-51a6-46903e794a76
  5. Request Payload:
  6. // <request payload truncated>
  7. Plan:
  8. Terraform used the selected providers to generate the following execution
  9. plan. Resource actions are indicated with the following symbols:
  10. + create
  11. Terraform will perform the following actions:
  12. // <diff truncated>
  13. Plan: 1 to add, 0 to change, 0 to destroy.
  14. ==> Creating the task will perform the actions described above.
  15. Do you want to perform these actions for 'task_a'?
  16. - This action cannot be undone.
  17. - Consul-Terraform-Sync cannot guarantee Terraform will perform
  18. these exact actions if monitored services have changed.
  19. Only 'yes' will be accepted to approve, enter 'no' or leave blank to reject.
  20. Enter a value: yes
  21. ==> Creating and running task 'api-task'...
  22. The task creation request has been sent to the CTS server.
  23. Please be patient as it may take some time to see a confirmation that this task has completed.
  24. Warning: Terminating this process will not stop task creation.
  25. ==> Task 'task_a' created
  26. Request ID: '78eddd74-0f08-83d6-72b2-6aaac1424fba'
  1. $ consul-terraform-sync task create -task-file=task_example.hcl
  2. ==> Inspecting changes to resource if creating task 'task_a'...
  3. Generating plan that Consul-Terraform-Sync will use Terraform to execute
  4. Request ID: 1da3e8e0-87c3-069b-51a6-46903e794a76
  5. Request Payload:
  6. // <request payload truncated>
  7. Plan:
  8. Terraform used the selected providers to generate the following execution
  9. plan. Resource actions are indicated with the following symbols:
  10. + create
  11. Terraform will perform the following actions:
  12. // <diff truncated>
  13. Plan: 1 to add, 0 to change, 0 to destroy.
  14. ==> Creating the task will perform the actions described above.
  15. Do you want to perform these actions for 'task_a'?
  16. - This action cannot be undone.
  17. - Consul-Terraform-Sync cannot guarantee Terraform will perform
  18. these exact actions if monitored services have changed.
  19. Only 'yes' will be accepted to approve, enter 'no' or leave blank to reject.
  20. Enter a value: yes
  21. ==> Creating and running task 'api-task'...
  22. The task creation request has been sent to the CTS server.
  23. Please be patient as it may take some time to see a confirmation that this task has completed.
  24. Warning: Terminating this process will not stop task creation.
  25. ==> Task 'task_a' created
  26. Request ID: '78eddd74-0f08-83d6-72b2-6aaac1424fba'

task enable

task enable command enables an existing task so that it will run and update task resources. If the task is already enabled, it will return a success. The command generates and outputs a Terraform plan, similar to inspect-mode, of how resources will be modified if task becomes enabled. If resources changes are detected, the command will ask for user approval before enabling the task. If no resources are detected, the command will go ahead and enable the task.

Usage

consul-terraform-sync task enable [options] <task_name>

Arguments:

NameRequiredTypeDescription
task_nameRequiredstringThe name of the task to enable.

Options:

In addition to general options this command also supports the following:

NameRequiredTypeDescription
-auto-approveOptionalbooleanWhether to skip the interactive approval of the plan before enabling.

Example

  1. $ consul-terraform-sync task enable task_a
  2. ==> Inspecting changes to resource if enabling 'task_a'...
  3. Generating plan that Consul-Terraform-Sync will use Terraform to execute
  4. An execution plan has been generated and is shown below.
  5. Resource actions are indicated with the following symbols:
  6. + create
  7. Terraform will perform the following actions:
  8. // <diff truncated>
  9. Plan: 3 to add, 0 to change, 0 to destroy.
  10. ==> Enabling the task will perform the actions described above.
  11. Do you want to perform these actions for 'task_a'?
  12. - This action cannot be undone.
  13. - Consul-Terraform-Sync cannot guarantee Terraform will perform
  14. these exact actions if monitored services have changed.
  15. Only 'yes' will be accepted to approve.
  16. Enter a value: yes
  17. ==> Enabling and running 'task_a'...
  18. ==> 'task_a' enable complete!
  1. $ consul-terraform-sync task enable task_a
  2. ==> Inspecting changes to resource if enabling 'task_a'...
  3. Generating plan that Consul-Terraform-Sync will use Terraform to execute
  4. An execution plan has been generated and is shown below.
  5. Resource actions are indicated with the following symbols:
  6. + create
  7. Terraform will perform the following actions:
  8. // <diff truncated>
  9. Plan: 3 to add, 0 to change, 0 to destroy.
  10. ==> Enabling the task will perform the actions described above.
  11. Do you want to perform these actions for 'task_a'?
  12. - This action cannot be undone.
  13. - Consul-Terraform-Sync cannot guarantee Terraform will perform
  14. these exact actions if monitored services have changed.
  15. Only 'yes' will be accepted to approve.
  16. Enter a value: yes
  17. ==> Enabling and running 'task_a'...
  18. ==> 'task_a' enable complete!

task disable

task disable command disables an existing task so that it will no longer run and update task resources. If the task is already disabled, it will return a success.

Usage

consul-terraform-sync task disable [options] <task_name>

Arguments:

NameRequiredTypeDescription
task_nameRequiredstringThe name of the task to disable.

Options: Currently only supporting general options

Example

  1. $ consul-terraform-sync task disable task_b
  2. ==> Waiting to disable 'task_b'...
  3. ==> 'task_b' disable complete!
  1. $ consul-terraform-sync task disable task_b
  2. ==> Waiting to disable 'task_b'...
  3. ==> 'task_b' disable complete!

task delete

task delete command deletes an existing task. The command will ask the user for approval before deleting the task. The task will be marked for deletion and will be deleted immediately if it is not running. Otherwise, the task will be deleted once it has completed.

Note: Deleting a task will not destroy the infrastructure managed by the task.

Usage

consul-terraform-sync task delete [options] <task_name>

Arguments:

NameRequiredTypeDescription
task_nameRequiredstringThe name of the task to delete.

Options:

In addition to general options this command also supports the following:

NameRequiredTypeDescription
-auto-approveOptionalbooleanWhether to skip the interactive approval of the task deletion.

Example

  1. $ consul-terraform-sync task delete task_a
  2. ==> Do you want to delete 'task_a'?
  3. - This action cannot be undone.
  4. - Deleting a task will not destroy the infrastructure managed by the task.
  5. - If the task is not running, it will be deleted immediately.
  6. - If the task is running, it will be deleted once it has completed.
  7. Only 'yes' will be accepted to approve, enter 'no' or leave blank to reject.
  8. Enter a value: yes
  9. ==> Marking task 'task_a' for deletion...
  10. ==> Task 'task_a' has been marked for deletion and will be deleted when not running.
  1. $ consul-terraform-sync task delete task_a
  2. ==> Do you want to delete 'task_a'?
  3. - This action cannot be undone.
  4. - Deleting a task will not destroy the infrastructure managed by the task.
  5. - If the task is not running, it will be deleted immediately.
  6. - If the task is running, it will be deleted once it has completed.
  7. Only 'yes' will be accepted to approve, enter 'no' or leave blank to reject.
  8. Enter a value: yes
  9. ==> Marking task 'task_a' for deletion...
  10. ==> Task 'task_a' has been marked for deletion and will be deleted when not running.