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.