The appliction creates a directory with tf files for each module. The following files will be created in the directories:
- main.tf
- variables.tf
- outputs.tf And in the project "root" directory1 it creates:
- main.tf
- variables.tf
- terraform.tfvars
The program searches for a file called config.yml/yaml and retrieves the project's structure from it. The YAML file format should be as follows:
# required
region: <The aws region>(Example :us-east-1)
modules:
<The module name>:
vars:
- name: <The variable name>
type: <The variable type>
description: <optional>
# optional
# default_tags for the provider
tags:
- name: <The tag key>
value: <The tag value>
project/
├── config.yml
├── main.tf
├── modules
│ ├── compute
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ └── network
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── terraform.tfvars
└── variables.tf
region: us-east-1
tags:
- name: Environment
value: Test
- name: project
value: test
modules:
network:
vars:
- name: availability_zones
type: list(string)
compute:
vars:
- name: instence_type
type: string
description: The instance type to use for the deployment
- name: number_of_instances
type: numberterraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "us-east-1"
default_tags {
tags = {
Environment = "Test"
project = "test"
}
}
}
module "network" {
source = "./modules/network"
availability_zones = var.availability_zones
}
module "compute" {
source = "./modules/compute"
instence_type = var.instence_type
number_of_instances = var.number_of_instances
}variable "availability_zones" {
type = list(string)
}
variable "instence_type" {
type = string
description = "The instance type to use for the deployment"
}
variable "number_of_instances" {
type = number
}availability_zones = "placeholder"
instence_type = "placeholder"
number_of_instances = "placeholder"variable "availability_zones" {
type = list(string)
}variable "instence_type" {
type = string
description = "The instance type to use for the deployment"
}
variable "number_of_instances" {
type = number
}Footnotes
-
The directory in which the appliction was executed ↩