Introduction
Problem
Using the TFE provider data source tfe_team to get information about a specific team from Terraform Enterprise errors with:
Error: could not find team daniela-team
with module.base.module.data_admin_test.data.tfe_team.admin[0]
on .terraform/modules/base.data_admin_test/main.tf line 26, in data "tfe_team" "admin
The following Terraform code is an example of what can trigger this error:
terraform {
required_providers {
tfe = {
source = "hashicorp/tfe"
version = "0.50.0"
}
}
}
provider "tfe" {
hostname = "xx.xxx.xx.101.nip.io"
}
data "tfe_team" "admin" {
name = "daniela-team"
organization = "daniela-org"
}
Cause
-
A TFE token is not used
Overview of possible solutions
Solutions:
-
Set the token argument in the provider configuration. You can set the token argument in the provider configuration. Use an input variable for the token, as in the following example:
provider "tfe" {
hostname = "xx.xxx.xx.101.nip.io"
token = var.token # team token
}
variable "token" {
type = string
description = "TFE token"
}
- Set the TFE_TOKEN environment variable: The provider can read the TFE_TOKEN environment variable and the token stored there to authenticate.
Outcome
The information for the team can be retrieved from TFE without any errors.