Terraform Cloud: “Couldn't create env variable test: resource not found” when using tfe_variable

I’m using Terraform Cloud with the tfe provider to create environment variables for a workspace but I receive the following error during terraform apply:

Couldn’t create env variable test: resource not found

Here’s a minimal example of the code:

provider "tfe" {}

data "tfe_workspace" "this" {
  organization = "my-org"
  name         = terraform.workspace
}

resource "tfe_variable" "example" {
  key          = "test"
  value        = "some-value"
  category     = "env"
  workspace_id = data.tfe_workspace.this.id
  sensitive    = false
}