Is there any way to conditionally omit a block?

I’m working on a project where a certain resource may or may not need to be created, depending on the variables provided when terraform apply is run. I can’t find any documented way to omit a resource block based on provided variables in the docs, but maybe there’s something I’m missing? Hopefully?

The way this is commonly done is to add a count to the resource like this:

resource "xxx" "xxx" {
  count = var.enabled ? 1 : 0

  ...
}