# Azurerm CDKTF C# general project structure tips

**URL:** <https://discuss.hashicorp.com/t/azurerm-cdktf-c-general-project-structure-tips/40740>\
**Category:** CDK for Terraform\
**Tags:** azure\
**Created:** [June 14, 2022, 10:53am UTC](https://discuss.hashicorp.com/t/azurerm-cdktf-c-general-project-structure-tips/40740 "2022-06-14T10:53:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arc\_lag](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/arc_lag/32/27851_2.png) [@Arc\_lag](https://discuss.hashicorp.com/u/Arc_lag)\
**Post date:** [June 14, 2022, 10:53am UTC](https://discuss.hashicorp.com/t/azurerm-cdktf-c-general-project-structure-tips/40740/1 "2022-06-14T10:53:34Z")

</div>

Hi there,

First off, I want to thank the team for constantly helping. Also sorry about that, I’m fairly new to the concept of Terraform and cloud environments.

Back on-topic:  
Right now I have two files with all of the resource declarations within my project.  
It ranges from networking to subnetting, k8s etc.

![image](https://global.discourse-cdn.com/hashicorp/original/3X/1/3/13bd0e3517663840f17a704158c96b391d821034.png)

But those files have both become an unreadable mess, and I was wondering whether it is possible to use multiple files/classes to declare multiple resources per category which will all compile/synthesise into the same json file.

---

<div class="post-metadata">

**Author:** ![jsteinich](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jsteinich/32/9502_2.png) [@jsteinich](https://discuss.hashicorp.com/u/jsteinich)\
**Post date:** [June 14, 2022, 1:11pm UTC](https://discuss.hashicorp.com/t/azurerm-cdktf-c-general-project-structure-tips/40740/2 "2022-06-14T13:11:38Z")

</div>

> [@Arc\_lag](#):
>
> But those files have both become an unreadable mess, and I was wondering whether it is possible to use multiple files/classes to declare multiple resources per category which will all compile/synthesise into the same json file.

You absolutely can (and should) split up your code. That’s really one of the most powerful aspects of cdk. You are free to divide and structure your infrastructure code using the same techniques you would use for application code. Take a look [here](https://www.terraform.io/cdktf/create-and-deploy/best-practices#application-architecture) for some more tips.

---

<div class="post-metadata">

**Author:** ![Arc\_lag](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/arc_lag/32/27851_2.png) [@Arc\_lag](https://discuss.hashicorp.com/u/Arc_lag)\
**Post date:** [June 14, 2022, 5:26pm UTC](https://discuss.hashicorp.com/t/azurerm-cdktf-c-general-project-structure-tips/40740/3 "2022-06-14T17:26:46Z")

</div>

I somehow managed it? Albeit it might be a bit… off(?)

 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/1/e/1ed383692de9c246940f4a351bc55e84ce29cf8f.png)

Running `app.Synth()` now results in the following folder structure:

![image](https://global.discourse-cdn.com/hashicorp/original/3X/7/3/7391591ea192ed1a8882bf42b3c495dc86a8f6e4.png)

Is this intended? Am I simply expected to to run `Terraform plan && Terraform apply` on all of those files? I would have ideally had a way to see all of the changes in a single `Terraform plan` command, correct me if I’m wrong but I’m assuming that that is not possible with this structure

---

<div class="post-metadata">

**Author:** ![jsteinich](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jsteinich/32/9502_2.png) [@jsteinich](https://discuss.hashicorp.com/u/jsteinich)\
**Post date:** [June 16, 2022, 2:00am UTC](https://discuss.hashicorp.com/t/azurerm-cdktf-c-general-project-structure-tips/40740/4 "2022-06-16T02:00:59Z")

</div>

> [@Arc\_lag](#):
>
> Is this intended? Am I simply expected to to run `Terraform plan && Terraform apply` on all of those files? I would have ideally had a way to see all of the changes in a single `Terraform plan` command, correct me if I’m wrong but I’m assuming that that is not possible with this structure

Having multiple stacks is intended. If you want to use `Terraform` directly then you’ll need to go through all of them individually. The `cdktf` cli can perform operations at the same time and does them in the correct order.

---

<div class="post-metadata">

**Author:** ![Arc\_lag](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/arc_lag/32/27851_2.png) [@Arc\_lag](https://discuss.hashicorp.com/u/Arc_lag)\
**Post date:** [June 17, 2022, 7:31am UTC](https://discuss.hashicorp.com/t/azurerm-cdktf-c-general-project-structure-tips/40740/5 "2022-06-17T07:31:19Z")

</div>

> If you want to use Terraform **directly**

Could you elaborate a bit more on that? Is there an “indirect” manner?

---

<div class="post-metadata">

**Author:** ![DanielMSchmidt](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/danielmschmidt/32/19126_2.png) [@DanielMSchmidt](https://discuss.hashicorp.com/u/DanielMSchmidt)\
**Post date:** [June 17, 2022, 12:02pm UTC](https://discuss.hashicorp.com/t/azurerm-cdktf-c-general-project-structure-tips/40740/6 "2022-06-17T12:02:04Z")

</div>

You can also run `cdktf plan <stack name>` or `cdktf deploy <stack name>`. You install the cdktf CLI by running `npm install -g cdktf-cli`
