Terraform init failing in bitbucket pipeline

I have a private registry connected in my Terraform cloud workspace (version 1.3.7) that was previously working but now returns a 401: unauthorized when running it from a bitbucket pipeline. It works properly from terraform cloud. I have tried republishing the module, adding an ssh key to the vcs provider and redoing the oath consumer.

I would prefer to use bitbucket pipelines because of the flexibility rather than triggering it directly in terraform cloud.

So 2 questions:

  1. Any idea why it is failing to pull from the private registry when run from the pipeline?

  2. Is there some better way to manage the terraform steps from a bitbucket pipeline? I could restrict it to tags or similar but still not ideal for me

+ terraform init

Initializing modules...

- alb in ../alb

│ Error: Error accessing remote module registry

│ Failed to retrieve available versions for module "vpc" (main.tf:15) from

│ app.terraform.io: error looking up module versions: 401 Unauthorized.

Ugh, set TF_TOKEN_app_terraform_io with an appropriate token in your repository variables