Add protocol example for TFC driver address (#11319)

* Add protocol example for TFC driver address
* Format cts code blocks
This commit is contained in:
Kim Ngo 2021-10-15 11:01:10 -05:00 committed by GitHub
parent feaf45214b
commit 92d0aa05f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 115 additions and 102 deletions

View File

@ -17,9 +17,11 @@ Top level options are reserved for configuring Consul-Terraform-Sync.
log_level = "INFO" log_level = "INFO"
working_dir = "sync-tasks" working_dir = "sync-tasks"
port = 8558 port = 8558
syslog { syslog {
facility = "local2" facility = "local2"
} }
buffer_period { buffer_period {
enabled = true enabled = true
min = "5s" min = "5s"
@ -147,14 +149,19 @@ task {
- `variable_files` - (list[string]) Specifies list of paths to [Terraform variable definition files (`.tfvars`)](https://www.terraform.io/docs/configuration/variables.html#variable-definitions-tfvars-files). The content of these files should consist of only variable name assignments. The variable assignments must match the corresponding variable declarations made available by the Terraform module for the task. - `variable_files` - (list[string]) Specifies list of paths to [Terraform variable definition files (`.tfvars`)](https://www.terraform.io/docs/configuration/variables.html#variable-definitions-tfvars-files). The content of these files should consist of only variable name assignments. The variable assignments must match the corresponding variable declarations made available by the Terraform module for the task.
- Variables are loaded in the order they appear in the files. Duplicate variables are overwritten with the later value. _Unless specified by the module, configure arguments for Terraform providers using [`terraform_provider` blocks](#terraform-provider)._ - Variables are loaded in the order they appear in the files. Duplicate variables are overwritten with the later value. _Unless specified by the module, configure arguments for Terraform providers using [`terraform_provider` blocks](#terraform-provider)._
<CodeBlockConfig filename="example.tfvars">
```hcl ```hcl
# example.tfvars
address_group = "consul-services" address_group = "consul-services"
tags = [ tags = [
"consul-terraform-sync", "consul-terraform-sync",
"terraform" "terraform"
] ]
``` ```
</CodeBlockConfig>
- `version` - (string) The version of the provided source the task will use. For the [Terraform driver](#terraform-driver), this is the module version. The latest version will be used as the default if omitted. - `version` - (string) The version of the provided source the task will use. For the [Terraform driver](#terraform-driver), this is the module version. The latest version will be used as the default if omitted.
- `working_dir` - (string) The working directory to manage generated artifacts by Consul-Terraform-Sync for this task, including Terraform configuration files. By default, a working directory is created for each task as a subdirectory in the base [`working_dir`](#working_dir), e.g. `sync-tasks/task-name`. - `working_dir` - (string) The working directory to manage generated artifacts by Consul-Terraform-Sync for this task, including Terraform configuration files. By default, a working directory is created for each task as a subdirectory in the base [`working_dir`](#working_dir), e.g. `sync-tasks/task-name`.
- `buffer_period` - Configures the buffer period for a dynamic task to dampen the effects of flapping services to downstream network devices. It defines the minimum and maximum amount of time to wait for the cluster to reach a consistent state and accumulate changes before triggering task execution. The default is inherited from the top level [`buffer_period` block](#global-config-options). If configured, these values will take precedence over the global buffer period. This is useful to enable for a task that is dependent on services that have a lot of flapping. Buffer periods do not apply to scheduled tasks. - `buffer_period` - Configures the buffer period for a dynamic task to dampen the effects of flapping services to downstream network devices. It defines the minimum and maximum amount of time to wait for the cluster to reach a consistent state and accumulate changes before triggering task execution. The default is inherited from the top level [`buffer_period` block](#global-config-options). If configured, these values will take precedence over the global buffer period. This is useful to enable for a task that is dependent on services that have a lot of flapping. Buffer periods do not apply to scheduled tasks.
@ -401,7 +408,7 @@ Only one network driver can be configured per deployment of Consul-Terraform-Syn
```hcl ```hcl
driver "terraform-cloud" { driver "terraform-cloud" {
hostname = "my.tfe.hostname.io" hostname = "https://app.terraform.io"
organization = "my-org" organization = "my-org"
token = "<TEAM_TOKEN>" token = "<TEAM_TOKEN>"
// Optionally set the token to be securely queried from Vault instead of // Optionally set the token to be securely queried from Vault instead of
@ -459,7 +466,7 @@ driver "terraform" {
} }
terraform_provider "aws" { terraform_provider "aws" {
# Configuration options // Configuration options
region = "us-east-1" region = "us-east-1"
} }

View File

@ -59,6 +59,8 @@ Piecing it all together, the configuration file for Consul-Terraform-Sync will h
An example HCL configuration file is shown below to automate one task to execute a Terraform module on the condition when there are changes to two services. An example HCL configuration file is shown below to automate one task to execute a Terraform module on the condition when there are changes to two services.
<CodeBlockConfig filename="cts-example-config.hcl">
```hcl ```hcl
log_level = "info" log_level = "info"
@ -97,3 +99,5 @@ terraform_provider "myprovider" {
address = "myprovider.example.com" address = "myprovider.example.com"
} }
``` ```
</CodeBlockConfig>

View File

@ -161,15 +161,17 @@ task {
providers = ["my-provider"] providers = ["my-provider"]
services = ["web-api"] services = ["web-api"]
source = "path/to/consul-kv-module" source = "path/to/consul-kv-module"
condition "schedule" {
cron = "* * * * Mon"
}
source_input "consul-kv" { source_input "consul-kv" {
path = "my-key" path = "my-key"
recurse = true recurse = true
datacenter = "dc1" datacenter = "dc1"
namespace = "default" namespace = "default"
} }
condition "schedule" {
cron = "* * * * Mon"
}
} }
``` ```