We have a repo that is creating ECS resources (cluster + ECS tasks) for multiple different environments. We usually use tfvar.json files so that we can make the relevant changes per environment. However, this means we can’t use pipeline variables for sensitive values like passwords. To fix this, we have it set up with locals so that we can use the pipeline variables but again, it means that the variables have to be the same across all the environments.
If we put everything into a .tf file, it means that the number of resources deployed have to be exactly the same for each environment. But will only want to deploy some ECS tasks in some environments and not in others.
If we only had two environments we could use count, but we have a varying number of environments that are always changing. Is there a good solution for this to be able to deploy a varying number of resources with different variables?
Thank you