I am trying to configure my tiny piece of Terraform code to use the cloud{} backend.
Because this code is used in multiple TFE/TFC orgs, I am using the Environment Variables method to supply the config per https://developer.hashicorp.com/terraform/cli/v1.2.x/cloud/settings#environment-variables.
Code snippets:
terraform {
required_version = ">= 1.2"
# https://developer.hashicorp.com/terraform/cli/cloud/settings
cloud {
# cloud block is configured via env settings.
# TF_CLOUD_ORGANIZATION
# TF_CLOUD_HOSTNAME
# TF_CLOUD_WORKSPACE
}
required_providers {
# https://registry.terraform.io/providers/hashicorp/azurerm/latest
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
# https://registry.terraform.io/providers/hashicorp/vault/latest
vault = {
source = "hashicorp/vault"
version = "~>3.7"
}
}
}
The required environment variables exist in my shell:
~azure-basic-test !3: set | grep TF_
TF_CLOUD_HOSTNAME=terraform-qa.redacted.cloud
TF_CLOUD_ORGANIZATION=redactedqa-org
TF_CLOUD_WORKSPACE=terraformPrototypes
When I run the terraform init in my shell, terraform says:
Initializing Terraform Cloud...
╷
│ Error: Invalid or missing required argument
│
│ on main.tf line 6, in terraform:
│ 6: cloud {
│
│ "organization" must be set in the cloud configuration or as an environment variable: TF_CLOUD_ORGANIZATION.
│ Error: Invalid workspaces configuration
│
│ on main.tf line 6, in terraform:
│ 6: cloud {
│
│ Missing workspace mapping strategy. Either workspace "tags" or "name" is required.
│
│ The 'workspaces' block configures how Terraform CLI maps its workspaces for this single
│ configuration to workspaces within a Terraform Cloud organization. Two strategies are available:
│
│ tags - A set of tags used to select remote Terraform Cloud workspaces to be used for this single
│ configuration. New workspaces will automatically be tagged with these tag values. Generally, this
│ is the primary and recommended strategy to use. This option conflicts with "name".
│
│ name - The name of a single Terraform Cloud workspace to be used with this configuration.
│ When configured, only the specified workspace can be used. This option conflicts with "tags".
What am I missing here?