<p>I tend to prefer infra code living separately from application deployment code.  Multiple reasons for this:</p>
<ul>
<li>You want your infra team to make infra changes.  You want your app team to make application changes (including application configuration).  Putting them separately lets you specify separate guard rails on them (for example, only the infra team is allowed to push changes to your infra repo).</li>
<li>You don't necessarily want to trigger a redeployment of the app if you make infra changes, and you rarely want to trigger a redeploy of your infrastructure if you trigger a new app build.</li>
<li>You don't want a bad build of your app preventing you from making any infrastructure changes until it's fixed, and vice-versa.</li>
</ul>
<p>It actually makes sense to put your app deployment code (i.e. Helm chart) inside the app repo itself.</p>
<p>Then, you can actually package up application config changes along with the corresponding release of your application.  You also empower developers to do it themselves, without running the risk of breaking production more than they already can.</p>
<p>It will also allow your CI/CD tool to deploy both at once.</p>
<p>And since there's a strict mapping of app IaC and app itself in each GitHub branch, this actually lets you very easily create feature branch environments (i.e. a developer creates a new branch, your CI/CD picks it up, and automatically deploys it to a kube environment).</p>

CC BY-SA 4.0
2021-05-13T09:25:58.613Z
Having them applied separately and managed by separate states/ roles would also allow you to implement security and controls better, for example restricting who can create VPC, NAT Gateways, as you might not want your application developers to have that level of access to your accounts.
Alastair Montgomery
CC BY-SA 4.0
2021-04-04T05:47:34.393Z
2021-04-04T05:47:34.393Z
maplebird
<p>Are there any advantages of maintaining both infrastructure (Infra-as-code) and application/service (helm chart deployment using helm_release provider of terraform ) under one state file?</p>
<p>I don't like the idea of maintaining both infra and application under one state, because for some reason it could be possible that our intention was just to change application however as there is one state and it could detect some other infra related change, and it will deploy them, which could have unintended consequences on the infrastructure.</p>
<p>however I would like to be open and see suggestion, if there are any advantages which maintaining one state file provides.</p>

<terraform><helm>
Terrafrom to declare both infra and application deployment in one state
Ruchir Bharadwaj
# Terrafrom to declare both infra and application deployment in one state

(Asked by: username_0 on 2021-04-01)

Are there any advantages of maintaining both infrastructure (Infra-as-code) and application/service (helm chart deployment using helm\_release provider of terraform ) under one state file?

I don't like the idea of maintaining both infra and application under one state, because for some reason it could be possible that our intention was just to change application however as there is one state and it could detect some other infra related change, and it will deploy them, which could have unintended consequences on the infrastructure.

however I would like to be open and see suggestion, if there are any advantages which maintaining one state file provides.

**Tags:** terraform, helm


---

## 1 answers

### Answer by username_1 on 2021-04-04. Score: 2

I tend to prefer infra code living separately from application deployment code. Multiple reasons for this:

* You want your infra team to make infra changes. You want your app team to make application changes (including application configuration). Putting them separately lets you specify separate guard rails on them (for example, only the infra team is allowed to push changes to your infra repo).
* You don't necessarily want to trigger a redeployment of the app if you make infra changes, and you rarely want to trigger a redeploy of your infrastructure if you trigger a new app build.
* You don't want a bad build of your app preventing you from making any infrastructure changes until it's fixed, and vice-versa.

It actually makes sense to put your app deployment code (i.e. Helm chart) inside the app repo itself.

Then, you can actually package up application config changes along with the corresponding release of your application. You also empower developers to do it themselves, without running the risk of breaking production more than they already can.

It will also allow your CI/CD tool to deploy both at once.

And since there's a strict mapping of app IaC and app itself in each GitHub branch, this actually lets you very easily create feature branch environments (i.e. a developer creates a new branch, your CI/CD picks it up, and automatically deploys it to a kube environment).

> **Comments:**
> **username_2**: Having them applied separately and managed by separate states/ roles would also allow you to implement security and controls better, for example restricting who can create VPC, NAT Gateways, as you might not want your application developers to have that level of access to your accounts.  

---

