Conditional resource creation when dependency is required

Good day.

Am having in issue where am looking to create a disk and attach it to a compute instance which works using:

resource "google_compute_disk" "blue_database_disk-f" {
name = "disk-f"
type = var.db_disk_f_type
size = var.db_disk_f_size
zone = var.blue_zone
}

resource "google_compute_attached_disk" "blue_database_attach_disk_f" {
    disk     = google_compute_disk.blue_database_disk-f.name
    instance = google_compute_instance.blue_database.id
}

The problem comes when I require that drive to use locally attached SSDs for which I need use the scratch_disk block within the compute instance creation. For that I used a dynamic block based on a conditional name:

dynamic "scratch_disk" {
    for_each = range(var.environment_name == "production" ? 1 : 0)
    content {
      interface = "SCSI"
    }
  }

So to the main question that if I’m deploying against “production” I require a scratch disk but not the creation of a drive-f. I can manage the drive resource creation using a conditional but then it fails later as the attach is expecting the resource to be available.

Any thoughts on how best to approach this please?