docs/nia: Update CTS configuration example to not confuse vault provider with vault config block (#9909)

This commit is contained in:
Kim Ngo 2021-03-19 16:52:32 -05:00 committed by GitHub
parent 9e90e6d2cd
commit 90ad52575f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 18 deletions

View File

@ -177,25 +177,26 @@ driver "terraform" {
A `terraform_provider` block configures the options to interface with network infrastructure. Define a block for each provider required by the set of Terraform modules across all tasks. This block resembles [provider blocks for Terraform configuration](https://www.terraform.io/docs/configuration/providers.html). To find details on how to configure a provider, refer to the corresponding documentation for the Terraform provider. The main directory of publicly available providers are hosted on the [Terraform Registry](https://registry.terraform.io/browse/providers). A `terraform_provider` block configures the options to interface with network infrastructure. Define a block for each provider required by the set of Terraform modules across all tasks. This block resembles [provider blocks for Terraform configuration](https://www.terraform.io/docs/configuration/providers.html). To find details on how to configure a provider, refer to the corresponding documentation for the Terraform provider. The main directory of publicly available providers are hosted on the [Terraform Registry](https://registry.terraform.io/browse/providers).
The below configuration captures the general design of defining a provider using the [Vault Terraform provider](https://registry.terraform.io/providers/hashicorp/vault/latest/docs) as an example. The below configuration captures the general design of defining a provider using the [AWS Terraform provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) as an example.
```hcl ```hcl
driver "terraform" { driver "terraform" {
required_providers { required_providers {
vault = { aws = {
source = "hashicorp/vault" source = "hashicorp/aws"
version = "2.13.0" version = "3.33.0"
} }
} }
} }
terraform_provider "vault" { terraform_provider "aws" {
address = "vault.example.com" # Configuration options
region = "us-east-1"
} }
task { task {
source = "some/source" source = "some/source"
providers = ["vault"] providers = ["aws"]
services = ["web", "api"] services = ["web", "api"]
} }
``` ```
@ -298,24 +299,22 @@ terraform_provider "example" {
Consul-Terraform-Sync supports the [Terraform feature to define multiple configurations](https://www.terraform.io/docs/configuration/providers.html#alias-multiple-provider-configurations) for the same provider by utilizing the `alias` meta-argument. Define multiple provider blocks with the same provider name and set the `alias` to a unique value across a given provider. Select which provider configuration to use for a task by specifying the configuration with the provider name and alias (`<name>.<alias>`) within the list of providers in the [`task.provider`](#task) parameter. A task can use multiple providers, but only one provider instance of a provider is allowed per task. Consul-Terraform-Sync supports the [Terraform feature to define multiple configurations](https://www.terraform.io/docs/configuration/providers.html#alias-multiple-provider-configurations) for the same provider by utilizing the `alias` meta-argument. Define multiple provider blocks with the same provider name and set the `alias` to a unique value across a given provider. Select which provider configuration to use for a task by specifying the configuration with the provider name and alias (`<name>.<alias>`) within the list of providers in the [`task.provider`](#task) parameter. A task can use multiple providers, but only one provider instance of a provider is allowed per task.
The example Consul-Terraform-Sync configuration below defines two similar tasks executing the same module with different instances of the Vault provider. The example Consul-Terraform-Sync configuration below defines two similar tasks executing the same module with different instances of the AWS provider.
```hcl ```hcl
terraform_provider "vault" { terraform_provider "aws" {
alias = "a" alias = "a"
address = "vault.example.com" profile = "team-a"
namespace = "team-a"
task_env { task_env {
"VAULT_TOKEN" = "{{ env \"CTS_VAULT_TOKEN_A\" }}" "AWS_ACCESS_KEY_ID" = "{{ env \"CTS_AWS_ACCESS_KEY_ID_A\" }}"
} }
} }
terraform_provider "vault" { terraform_provider "aws" {
alias = "b" alias = "b"
address = "vault.internal.com" profile = "team-b"
namespace = "team-b"
task_env { task_env {
"VAULT_TOKEN" = "{{ env \"CTS_VAULT_TOKEN_B\" }}" "AWS_ACCESS_KEY_ID" = "{{ env \"CTS_AWS_ACCESS_KEY_ID_B\" }}"
} }
} }
@ -326,14 +325,14 @@ terraform_provider "dns" {
task { task {
name = "task-a" name = "task-a"
source = "org/module" source = "org/module"
providers = ["vault.a", "dns"] providers = ["aws.a", "dns"]
// ... // ...
} }
task { task {
name = "task-b" name = "task-b"
source = "org/module" source = "org/module"
providers = ["vault.b", "dns"] providers = ["aws.b", "dns"]
// ... // ...
} }
``` ```