Run Terraform Apply and store state in TF Cloud

I have a pipeline that deploys a AWS Resources using terraform. Involved in this deployment is a curl command that sets the backend TF state to be stored in a TF Cloud workspace ← this command needs to be run after a tf init in the same folder ( to create the original state file).

In FirstGen, I am able to run terraform init within a shell script step by exporting the TF_TOKEN_app_terraform_io variable ( export TF_TOKEN_app_terraform_io=$tf_token ) then run the curl command. Then in a separate step I use the Harness provided TF Apply steps to run Plan and Apply including the TF_TOKEN_app_terraform_io as a Terraform Environment Variable.

In NextGen, when I try this I get Required token could not be found . I’ve tried setting the TF_TOKEN_app_terraform_io value as an import variable so it is an environment variable for the step. I’ve tried manually writing it to the /root/.terraform.d/credentials.tfrc.json , I’ve tried using the terraform login command and all of these I get the same error. I’ve tried exporting it in the script at TFE_TOKEN or TF_TOKEN_app_terraform_io none of them work. Has anyone come across this before or can think of a solution? Thanks