QA File Structure Naming Conventions
When QA validates a module, it is crucial to follow a consistent structure to ensure that the module adheres to best practices and is easy to understand. Below is the example structure to be followed when creating a Terraform AWS module.
Directorysrc/
Directoryiam/
Directoryexamples/
Directorycomplete/
- main.tf
- outputs.tf
- README.md
- provider.tf
- versions.tf
- .gitkeep
Directorymodel/
- main.tf
- outputs.tf
- README.md
- variables.tf
- versions.tf
- iam-access-key.tf
- iam-account-alias.tf
- iam-account-password-policy.tf
- iam-group.tf
- iam-group-membership.tf
- …
- outputs.tf
- README.md
- variables.tf
- versions.tf
- .gitkeep
- README.md
Naming Conventions
The following naming conventions should be followed when creating QA files in Terraform AWS modules:
-
File Names: Use lowercase letters and hyphens to separate words. For example,
iam-access-key.tf,iam-account-alias.tf,iam-account-password-policy.tf,iam-group.tf,iam-group-membership.tf,outputs.tf,README.md, andvariables.tf. -
Directory Names: Use lowercase letters and hyphens to separate words. For example,
iam,examples,complete, andmodel. -
File Extensions: Use
.tffor Terraform files,.mdfor Markdown files, and.gitkeepfor empty directories. -
README.md: Include a
README.mdfile in the root directory of the module to provide an overview of the module, usage instructions, and other relevant information. -
/src/ Directory: Place all module files in the
/src/directory. -
/src/iam/ Directory: Create a separate directory for each resource type, under the
/src/directory. For example,/src/iam/for IAM resources. -
/src/iam/examples/ Directory: Create an
examplesdirectory under each resource type directory to store example configurations. -
/src/iam/model/ Directory: Create a
modeldirectory under each resource type directory to store the main module configuration. -
/src/iam/output.tf: Include an
outputs.tffile in the resource type directory to define output variables. -
/src/iam/README.md: Include a
README.mdfile in the resource type directory to provide an overview of the resource type and usage instructions. -
/src/iam/variables.tf: Include a
variables.tffile in the resource type directory to define input variables. -
/src/iam/versions.tf: Include a
versions.tffile in the resource type directory to define the required Terraform version. -
/src/iam/resource-name.tf: Include a separate
.tffile for each resource type, following the naming conventionresource-name.tf(e.g.,iam-access-key.tf,iam-account-alias.tf,iam-account-password-policy.tf,iam-group.tf,iam-group-membership.tf, etc.). -
/src/iam/examples/complete/ Directory: Create a
completedirectory under theexamplesdirectory to store a complete example configuration. -
/src/iam/examples/complete/main.tf: Include a
main.tffile in thecompletedirectory to define the main module configuration. -
/src/iam/examples/complete/outputs.tf: Include an
outputs.tffile in thecompletedirectory to define output variables. -
/src/iam/examples/complete/README.md: Include a
README.mdfile in thecompletedirectory to provide an overview of the complete example configuration. -
/src/iam/examples/complete/provider.tf: Include a
provider.tffile in thecompletedirectory to define the provider configuration. -
/src/iam/examples/complete/versions.tf: Include a
versions.tffile in thecompletedirectory to define the required Terraform provider versions. -
/src/iam/model/main.tf: Include a
main.tffile in themodeldirectory to define the main module configuration. -
/src/iam/model/outputs.tf: Include an
outputs.tffile in themodeldirectory to define output variables. -
/src/iam/model/README.md: Include a
README.mdfile in themodeldirectory to provide an overview of the main module configuration. -
/src/iam/model/variables.tf: Include a
variables.tffile in themodeldirectory to define input variables. -
/src/iam/model/versions.tf: Include a
versions.tffile in themodeldirectory to define the required Terraform version.