The release notes for v0.5.0 focus on a subset of configuration deprecations

Configuration Deprecations in v0.5

We introduced a number of configuration deprecations in Consul-Terraform-Sync (CTS) v0.5. Many of these deprecations are part of an effort to streamline CTS task configuration and reduce the inconsistencies. As CTS support for more use-cases increased, inconsistencies arose and required a lot of documentation to explain.

This documentation outlines the deprecations and examples on how to upgrade your configuration for v0.5. The deprecated configurations will not be removed until v0.8 and later. We plan to also release a tool to automate upgrading your configurations to make the upgrade quicker and smoother.

Overview of Deprecations

The deprecations address two major inconsistencies. First is the use of the terminology “source” in various configuration blocks and fields. The second is the exception to configuring a task condition or a task module input by using the services field and its related service block.

Address “source” terminology

The word “source” is used in the name of a number of task configurations. “Source” in the configuration name commonly refers to the Terraform module though it is not immediately clear and requires additional documentation to explain.

We deprecated all configuration with the term “source” and replaced it with “module” in the task configuration:

Deprecated ConfigReplacement ConfigDescription
source fieldmodule fieldThe path to the Terraform module
source_input blockmodule_input blockThe configuration block to define the values for additional Terraform input variables for the Terraform module
source_includes_var fielduse_as_module_input fieldThe field on the condition block to indicate whether the values of the condition object should also be used as module input

Removal date:

The documentation below will refer to the deprecated configurations by their new name.

Address services field and service block

The services field and its associated service block are frequently an exception to task configuration use-cases and add complexity and restrictions.

The services field is the only task condition that is not configured through the condition block. It is also the only additional module input that is not configured through a module_input block. This leads to a lot of inconsistent relationships with other condition and module_input blocks.

We deprecated the services field and its associated service filter to remove these exceptions and complicated relationship with other condition and module_input blocks:

Deprecated ConfigReplacement ConfigDescription
services fieldcondition “services” or module_input “services” blockThe services to provide module input and occasionally act as the task condition
service blockfields moved into the condition “services” and module_input “services” blockThe configuration block to provide additional filtering on the services in the services field

The services field and its associated service block will be removed in a future major release after v0.8.

Further Details on Deprecations

Deprecate source field

The source field in the task configuration is deprecated and can be directly renamed to module.

Example:

Deprecate source field

Deprecate source field

Deprecated

v0.5.x - 图1

  • Deprecated
  • New
  1. task {
  2. name = "services_task"
  3. services = ["api", "web"]
  4. source = "path/to/module"
  5. }
  1. task {
  2. name = "services_task"
  3. services = ["api", "web"]
  4. source = "path/to/module"
  5. }
  1. task {
  2. name = "services_task"
  3. services = ["api", "web"]
  4. module = "path/to/module"
  5. }
  1. task {
  2. name = "services_task"
  3. services = ["api", "web"]
  4. module = "path/to/module"
  5. }

Deprecate source_input block

The source_input block in the task configuration is deprecated and can be directly renamed to module_input.

Example:

Deprecate source_input block

Deprecate source_input block

Deprecated

v0.5.x - 图2

  • Deprecated
  • New
  1. task {
  2. name = "scheduled_task"
  3. module = "path/to/module"
  4. condition "schedule" {
  5. cron = "* * * * Mon"
  6. }
  7. source_input "consul-kv" {
  8. path = "my_key"
  9. }
  10. }
  1. task {
  2. name = "scheduled_task"
  3. module = "path/to/module"
  4. condition "schedule" {
  5. cron = "* * * * Mon"
  6. }
  7. source_input "consul-kv" {
  8. path = "my_key"
  9. }
  10. }
  1. task {
  2. name = "scheduled_task"
  3. module = "path/to/module"
  4. condition "schedule" {
  5. cron = "* * * * Mon"
  6. }
  7. module_input "consul-kv" {
  8. path = "my_key"
  9. }
  10. }
  1. task {
  2. name = "scheduled_task"
  3. module = "path/to/module"
  4. condition "schedule" {
  5. cron = "* * * * Mon"
  6. }
  7. module_input "consul-kv" {
  8. path = "my_key"
  9. }
  10. }

Deprecate source_includes_var field

The condition block’s source_includes_var field is deprecated for all types of conditions and can be directly renamed to use_as_module_input.

Example:

Deprecate source_includes_var field

Deprecate source_includes_var field

Deprecated

v0.5.x - 图3

  • Deprecated
  • New
  1. task {
  2. name = "catalog_services_task"
  3. module = "path/to/module"
  4. condition "catalog-services" {
  5. regexp = "api"
  6. source_includes_var = true
  7. }
  8. }
  1. task {
  2. name = "catalog_services_task"
  3. module = "path/to/module"
  4. condition "catalog-services" {
  5. regexp = "api"
  6. source_includes_var = true
  7. }
  8. }
  1. task {
  2. name = "catalog_services_task"
  3. module = "path/to/module"
  4. condition "catalog-services" {
  5. regexp = "api"
  6. use_as_module_input = true
  7. }
  8. }
  1. task {
  2. name = "catalog_services_task"
  3. module = "path/to/module"
  4. condition "catalog-services" {
  5. regexp = "api"
  6. use_as_module_input = true
  7. }
  8. }

Deprecate services field

The services field can play different roles in a task depending on other task configurations:

  • When no condition block is configured, then the services field is the task’s condition and module input
  • When there is a condition block configured, then the `services field is only module input for the task

The services field can be replaced depending on the role it has for the task.

Deprecate services field as a condition

When the services field behaves as a condition, it can be replaced with a condition "services" block with the names field set to the list of the services.

Example:

Deprecate services field as a condition

Deprecate services field as a condition

Deprecated

v0.5.x - 图4

  • Deprecated
  • New
  1. task {
  2. name = "services_condition_task"
  3. module = "path/to/module"
  4. services = ["api", "web"]
  5. }
  1. task {
  2. name = "services_condition_task"
  3. module = "path/to/module"
  4. services = ["api", "web"]
  5. }
  1. task {
  2. name = "services_condition_task"
  3. module = "path/to/module"
  4. condition "services" {
  5. names = ["api", "web"]
  6. }
  7. }
  1. task {
  2. name = "services_condition_task"
  3. module = "path/to/module"
  4. condition "services" {
  5. names = ["api", "web"]
  6. }
  7. }

Deprecate services field as module input only

When the services field only provides module input, it can be replaced with a module_input "services" block with the names field set to the list of the services.

Example:

Deprecate services field as a module input

Deprecate services field as a module input

Deprecated

v0.5.x - 图5

  • Deprecated
  • New
  1. task {
  2. name = "services_module_input_task"
  3. module = "path/to/module"
  4. condition "consul-kv" {
  5. path = "my_key"
  6. source_includes_var = true
  7. }
  8. services = ["api", "web"]
  9. }
  1. task {
  2. name = "services_module_input_task"
  3. module = "path/to/module"
  4. condition "consul-kv" {
  5. path = "my_key"
  6. source_includes_var = true
  7. }
  8. services = ["api", "web"]
  9. }
  1. task {
  2. name = "services_module_input_task"
  3. module = "path/to/module"
  4. condition "consul-kv" {
  5. path = "my_key"
  6. use_as_module_input = true
  7. }
  8. module_input "services" {
  9. names = ["api", "web"]
  10. }
  11. }
  1. task {
  2. name = "services_module_input_task"
  3. module = "path/to/module"
  4. condition "consul-kv" {
  5. path = "my_key"
  6. use_as_module_input = true
  7. }
  8. module_input "services" {
  9. names = ["api", "web"]
  10. }
  11. }

Note: use_as_module_input was updated in v0.5 so that it will default to true when unconfigured. In the new configuration, the line to set use_as_module_input = true is no longer necessary

Deprecate service block

The service block is a configuration block outside of the task block. The fields of the service block provides additional filtering to any task that has that service set in the services field.

Once the services field is upgraded to a condition or module_input block, as described in the section above, the deprecated service block’s fields can be moved to the new condition or module_input block.

Example:

Deprecate service block

Deprecate service block

Deprecated

v0.5.x - 图6

  • Deprecated
  • New
  1. task {
  2. name = "services_filter_task"
  3. module = "path/to/module"
  4. condition "services" {
  5. names = ["api"]
  6. }
  7. }
  8. service {
  9. name = "api"
  10. datacenter = "dc2"
  11. namespace = "ns"
  12. }
  1. task {
  2. name = "services_filter_task"
  3. module = "path/to/module"
  4. condition "services" {
  5. names = ["api"]
  6. }
  7. }
  8. service {
  9. name = "api"
  10. datacenter = "dc2"
  11. namespace = "ns"
  12. }
  1. task {
  2. name = "services_filter_task"
  3. module = "path/to/module"
  4. condition "services" {
  5. names = ["api"]
  6. datacenter = "dc2"
  7. namespace = "ns"
  8. }
  9. }
  1. task {
  2. name = "services_filter_task"
  3. module = "path/to/module"
  4. condition "services" {
  5. names = ["api"]
  6. datacenter = "dc2"
  7. namespace = "ns"
  8. }
  9. }

There is an edge-case that requires a more complicated deprecation upgrade. Some tasks may have multiple services in the services field and a service block configured for each of those services. When the fields are different across the service blocks, it is necessary to split the task and create new, separate tasks for each service.

Example:

Deprecate service block edge-case

Deprecate service block edge-case

Deprecated

v0.5.x - 图7

  • Deprecated
  • New
  1. task {
  2. name = "services_task"
  3. module = "path/to/module"
  4. services = ["api", "web"]
  5. }
  6. service {
  7. name = "api"
  8. datacenter = "api_dc"
  9. }
  10. service {
  11. name = "web"
  12. datacenter = "web_dc"
  13. }
  1. task {
  2. name = "services_task"
  3. module = "path/to/module"
  4. services = ["api", "web"]
  5. }
  6. service {
  7. name = "api"
  8. datacenter = "api_dc"
  9. }
  10. service {
  11. name = "web"
  12. datacenter = "web_dc"
  13. }
  1. task {
  2. name = "api_services_task"
  3. module = "path/to/module"
  4. condition "services" {
  5. names = ["api"]
  6. datacenter = "api_dc"
  7. }
  8. }
  9. task {
  10. name = "web_services_task"
  11. module = "path/to/module"
  12. condition "services" {
  13. names = ["web"]
  14. datacenter = "web_dc"
  15. }
  16. }
  1. task {
  2. name = "api_services_task"
  3. module = "path/to/module"
  4. condition "services" {
  5. names = ["api"]
  6. datacenter = "api_dc"
  7. }
  8. }
  9. task {
  10. name = "web_services_task"
  11. module = "path/to/module"
  12. condition "services" {
  13. names = ["web"]
  14. datacenter = "web_dc"
  15. }
  16. }