Skip to content

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:

  1. 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, and variables.tf.

  2. Directory Names: Use lowercase letters and hyphens to separate words. For example, iam, examples, complete, and model.

  3. File Extensions: Use .tf for Terraform files, .md for Markdown files, and .gitkeep for empty directories.

  4. README.md: Include a README.md file in the root directory of the module to provide an overview of the module, usage instructions, and other relevant information.

  5. /src/ Directory: Place all module files in the /src/ directory.

  6. /src/iam/ Directory: Create a separate directory for each resource type, under the /src/ directory. For example, /src/iam/ for IAM resources.

  7. /src/iam/examples/ Directory: Create an examples directory under each resource type directory to store example configurations.

  8. /src/iam/model/ Directory: Create a model directory under each resource type directory to store the main module configuration.

  9. /src/iam/output.tf: Include an outputs.tf file in the resource type directory to define output variables.

  10. /src/iam/README.md: Include a README.md file in the resource type directory to provide an overview of the resource type and usage instructions.

  11. /src/iam/variables.tf: Include a variables.tf file in the resource type directory to define input variables.

  12. /src/iam/versions.tf: Include a versions.tf file in the resource type directory to define the required Terraform version.

  13. /src/iam/resource-name.tf: Include a separate .tf file for each resource type, following the naming convention resource-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.).

  14. /src/iam/examples/complete/ Directory: Create a complete directory under the examples directory to store a complete example configuration.

  15. /src/iam/examples/complete/main.tf: Include a main.tf file in the complete directory to define the main module configuration.

  16. /src/iam/examples/complete/outputs.tf: Include an outputs.tf file in the complete directory to define output variables.

  17. /src/iam/examples/complete/README.md: Include a README.md file in the complete directory to provide an overview of the complete example configuration.

  18. /src/iam/examples/complete/provider.tf: Include a provider.tf file in the complete directory to define the provider configuration.

  19. /src/iam/examples/complete/versions.tf: Include a versions.tf file in the complete directory to define the required Terraform provider versions.

  20. /src/iam/model/main.tf: Include a main.tf file in the model directory to define the main module configuration.

  21. /src/iam/model/outputs.tf: Include an outputs.tf file in the model directory to define output variables.

  22. /src/iam/model/README.md: Include a README.md file in the model directory to provide an overview of the main module configuration.

  23. /src/iam/model/variables.tf: Include a variables.tf file in the model directory to define input variables.

  24. /src/iam/model/versions.tf: Include a versions.tf file in the model directory to define the required Terraform version.