The null resource in Terraform is useful for a variety of one off use cases.

Using the null resource in Terraform to Guarantee Uniqueness (of identifiers)

Null Resource Usefulness 1 - Unique SSM Doc Name

# null resource - to ensure unique SSM doc name for each run

resource "null_resource" "nullres" {

  # not spinning up anything.

  }

  # SSM doc

resource "aws_ssm_document" "my_ssm_doc" {

  name = "certbot_${null_resource.nullres.id}"

  document_type   = "Command"

  document_format = "YAML"

  content = file("./ec2_init.yaml")


}

Null Resource Usefulness 2 - To call an external script - e.g. to call  a provisioner script

resource "null_resource" "execfile" 
{ provisioner "local-scripts" 
  { command = "${path.module}/hello.sh" interpreter = ["/bin/bash"] 
  } 
}

Custom script from within a terraform module

Null Resource Usefulness 3 - Using the Null Resource in Terraform to Introduce  a delay

resource "null_resource" "before" {
}

resource "null_resource" "delay" {
  provisioner "local-exec" {
    command = "sleep 10"
  }
  triggers = {
    "before" = "${null_resource.before.id}"
  }
}

resource "null_resource" "after" {
  depends_on = ["null_resource.delay"]
}