Failing to export CLOUDFLARE_API_TOKEN

I have setup terraform and added some .tf files on a debian os. The test was successfully. Now I wish to hide my Cloudflare api token using export. After doing so, I am prompt with this error when I run terraform plan.

 Error: must provide one of "api_key", "api_token" or "api_user_service_key".

   with provider["registry.terraform.io/cloudflare/cloudflare"],
   on cloudflare-teams-main.tf line 11, in provider "cloudflare":
   11: provider "cloudflare" 

I have tried running export CLOUDFLARE_API_TOKEN=my-api-token in cl and am able to see the api key under export -p cmd.

I have also tried adding the key via nano ~/.bashrc and run source ~/.bashrc afterwards.

my main.tf

terraform {
  required_providers {
    cloudflare = {
      source = "cloudflare/cloudflare"
      version = "~> 3.0"
    }
  }
}

provider "cloudflare" {

}

Is there something I am doing incorrectly??

That looks correct. One small thing is that the latest version of the terraform provider is 4.4.0, but that shouldn’t make a different.
Couple of things

  1. If you run echo CLOUDFLARE_API_TOKEN do you see your token?
  2. Does it work if you add api_token = "my-api-token" to the provider configuration?

Hi.
running echo CLOUDFLARE_API_TOKEN
returns → CLOUDFLARE_API_TOKEN (no actually api key digits were shown.)

point #2 It works .

I mistyped. What does echo $CLOUDFLARE_API_TOKEN show? It should show the token. If it does, then I would open an issue on the terraform repo. If it doesn’t show, then the variable isn’t being set correctly.

echo $CLOUDFLARE_API_TOKEN does shows my api key.