I am new to terraform. Here is what I am trying to achieve and want to know if there is a simple way of doing this in terraform:
- Create a single terraform file (as a template) for updating/creating, say, azure app service web apps.
- However, we have 20+ web apps running and I really don’t want to create a separate file for each one of them.
- I want to use the same terraform template to perform updates to each of the web apps separately.
The problem I am facing is:
- When I use the same file to deploy another web app. It is using the same state file and hence replacing the previous web app with the new one.
- The state of all web apps are not maintained separately.
I come from the cloudformation world and this is very simple in cloudformation:
- I create a single cloudformation template. This is a jinja template.
- When we want to update app1, we render the template with values for app1 (version, tags, etc.).
- We provide a stack name (unique to each app) and pass the rendered template to cloudformation and cloudformation modifies the correct app (determined from the stack name)
I am looking for something similar in terraform. i am not looking to use count, for_each here because that would mean the template is updating all the applications rather than one at time.
Can someone help me how can I achieve this in terraform. Thank you in advance.