Terraform files
Overview
When you create your architecture, Brainboard automatically and instantly generates a Terraform code for your infrastructure.
Files structure
By default, if you don't rename or change the generated files, you have the following ones:
main.tf: contains all the definitions of resources and their configuration. See how you can change or rename it below.
outputs.tf: contains the output variables.
providers.tf: contains the definition of
terraformblock and the providers.terraform.tfvars: contains only the values of the variables if defined.
variables.tf: contains the definition of variables and their blocks.
locals.tf: contains the definition of Terraform
locals.backend.tf: contains the configuration of the remote backend.
Create a new Terraform file
To create a new Terraform file that contains some resources:
Using click and drag, select the resource you want to put in the same file and right-click to open the menu. Select
Move to file.On the Edit terraform file name modal, assign a name (without .tf extension) to the new file you are about to create. Click
Save.

Once the file is created, it will be visible in the list of Terraform files in the right menu. Or, you can also access the newly created Terraform file using the hamburger icon given at the bottom next to the right pane.

Rename existing Terraform file
To rename an existing file:
Click the hamburger icon at the bottom right to view the list of available Terraform files.
Click on the file that you want to rename.
Edit the file name as per your requirement.
Click the tick mark icon given next to the editable field. The Terraform file name will be updated accordingly.

Rename it and save.
Delete a Terraform file
To delete an existing file:
Click on the hamburger icon to display the list of existing Terraform files in your architecture.
Click on the bin icon next to the unwanted file.
On the Delete File confirmation popup, enter the complete file name (including the .tf extension) as instructed.
Click
Delete File.

Add resource into an existing file
To add one or more resources into an existing Terraform file, follow these steps:
Using click and drag, select the resource/resources you want to put in the same file and right-click to open the menu.
Select
Move to file.On the Edit terraform file name modal, select the file from the dropdown list.
Click
Save.

Remove resource from a file
To remove a resource from an existing Terraform file:
Select the resource, and right-click to open the shortcut menu.
Select
Move to file.On the Edit terraform file name modal, select
mainfrom the dropdown list.Click
Save.
The selected file/files will be removed from the Terraform file (other than main.tf) that contained it/them.

Best practices
Always group resources that are supposed to work together or have the same logic in a separate group / Terraform file.
Use explicit names for your Terraform files. Usually, there are two conventions of naming:
Infrastructure base naming:
vpc.tf,db.tfApplication base naming:
microservice1.tf,backend.tf
Last updated