Conditionally include a key in a resource block

I am using aws_s3_bucket_notification. One of the examples given in the linked doc is:

resource "aws_s3_bucket_notification" "bucket_notification" {
  bucket = aws_s3_bucket.bucket.id

  queue {
    id            = "image-upload-event"
    queue_arn     = aws_sqs_queue.queue.arn
    events        = ["s3:ObjectCreated:*"]
    filter_prefix = "images/"
  }

  queue {
    id            = "video-upload-event"
    queue_arn     = aws_sqs_queue.queue.arn
    events        = ["s3:ObjectCreated:*"]
    filter_prefix = "videos/"
  }
}

Suppose I wanted to only include the queue with id = "video-upload-event" if some variable were set to true, how would I do that?

Essentially I want something like this:

resource "aws_s3_bucket_notification" "bucket_notification" {
  bucket = aws_s3_bucket.bucket.id

  queue {
    id            = "image-upload-event"
    queue_arn     = aws_sqs_queue.queue.arn
    events        = ["s3:ObjectCreated:*"]
    filter_prefix = "images/"
  }

  if var.include_video_upload_event ? queue {
    id            = "video-upload-event"
    queue_arn     = aws_sqs_queue.queue.arn
    events        = ["s3:ObjectCreated:*"]
    filter_prefix = "videos/"
  } : None
}

But I don’t know the correct syntax.

OK, I think I’ve figured it out

resource "aws_s3_bucket_notification" "bucket_notification" {
  bucket = aws_s3_bucket.bucket.id

  queue {
    id            = "image-upload-event"
    queue_arn     = aws_sqs_queue.queue.arn
    events        = ["s3:ObjectCreated:*"]
    filter_prefix = "images/"
  }

  dynamic queue {
    for_each = var. include_video_upload_event ? {
      "video-upload-event" = {
        id            = "video-upload-event"
        queue_arn     = aws_sqs_queue.queue.arn
        events        = ["s3:ObjectCreated:*"]
        filter_prefix = "videos/"
      }
    } : {}
    content {
      id            = queue.value.id
      queue_arn     = queue.value.queue_arn
      events        = queue.value.events
      filter_prefix = queue.value.filter_prefix    
    }
  }
}