Welcome to the Terraform Modules Repository. This repository contains a collection of reusable Terraform modules for AWS resources, making infrastructure provisioning efficient, consistent, and reliable.
To start using these Terraform modules, follow these steps:
- Clone the Repository: Begin by cloning this repository to your local machine.
- Start SSH Agent: Ensure your ssh agent is started and you have added your git private key. This is to allow you to downlonload the modules
- Create the following files in a directory of your choice:
main.tf
: The main Terraform configvariables.tf
: For your terraform variablesoutputs.tf
: For your Terraform Outputsversions.tf
: For your Terraform provider and region setup
- Follow the usage example specified in your required module. Examples are located in the
README.md
section of each module.- For example the
ec2_autoscale
module:module "tags" { source = "[email protected]:UKHSA-Internal/devops-terraform-modules.git//terraform-modules/helpers/tags?ref=TF/helpers/tags/vALPHA_0.0.1" project = "MyProject" client = "ClientName" owner = "OwnerName" environment = "prod" additional_tags = { "CostCenter" = "IT-Dept" } } module "ec2_autoscale" { source = "[email protected]:UKHSA-Internal/devops-terraform-modules.git//terraform-modules/ec2-autoscale?ref=ec2-autoscale/vALPHA_0.0.1" name = "MyProjectName" ami = "ami-0123456789abcdef0" instance_type = "t2.micro" vpc_id = "vpc-01234567" vpc_zone_identifiers = ["subnet-0123456a", "subnet-0123456b"] # Example with SSH Access ingress_rules = [ { from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } ] tags = module.tags.tags } # Referencing outputs from the module output "asg_name" { value = module.ec2_autoscale.autoscaling_group_name }
- Take note of the
TF/helpers/tags/vALPHA_0.0.1
. This is the version of the module you would like to use. We recommend you use the latest version of a module.
- For example the
- WIP - To be Updated Soon!
- Modules are split up in the format
<IaC_Tool>-modules/<cloud_provider>/<module_name>
- All Terraform modules are located in the terraform-modules folder.
- Each Module has a
README.md
that is a autogenerated doc providing details of its respective module - Each Module has a
CHANGELOG.md
that highlights changes made to the module
- Modules in this repository are versioned using git tags in the format
<environment>/<IaC_tool>/<cloud_provider>/<module_name>/v<sem_version>
. For a list of all versions, check the tags in this repository.
- Semantic Versioning: Use SemVer (major.minor.patch) for clear version increments.
- Document Changes: Update documentation and changelogs with each release.
- Pin Versions: In configurations, specify module versions for consistency.
- Limit Major Changes: Introduce backward-incompatible changes sparingly.
- Testing: Test modules thoroughly before releasing, especially for major updates.
Additional documentation, diagrams, and assets related to the modules can be found in the doc folder.