I have a workflow that creates 2 AWS CloudFront distributions as required resources. I want to add an option where you can optionally create a 3rd distribution if it’s needed.
What I need to happen is when a specific input has been passed to the workflow related to the optional distribution, it would determine whether to create the resource or not. It should apply to the whole resource block itself and not to just some configurations inside it.
resource "aws_cloudfront_distribution" "optional_distribution" {...}
So if the input is “create”, “yes”, or whatever value, the resource block above would get executed and the optional distribution would get created giving me 3 distributions in total. Else, it would entirely skip it and the workflow would only create 2.
I understand there is an if-else condition in Terraform and I’ve seen several posts about it as well. But I haven’t seen any that would handle the resource block, only the arguments inside it.
Any way it can be done?