This project aims to provide a blueprint for creating a robust, scalable web server infrastructure on AWS using Terraform. It emphasizes:
-
Infrastructure as Code (IaC): Infrastructure components are defined as code using Terraform, ensuring consistency and repeatability.
-
Modular Design: Terraform modules have been authored for key components, allowing for easy reuse and extensibility.
-
Testing with Terratest: Rigorous testing is integral to this project. Terratest is used to validate the infrastructure, reducing the risk of issues in production.
-
Efficient CI/CD: A GitHub Actions workflow automates updates and maintenance, ensuring the infrastructure stays reliable and up-to-date.
- Configure AWS Credentials
- Terraform and Go installed on local machine
- Fork the repo and pull it down
- Customise the Terraform variables in the appropriate
.tfvarsfiles.
To test the modules:
- Make sure you are in the test directory.
cd tests. go test -v modules_test.go- This command will use the Terratest file to check if the modules work and do what they're intended to do.
To manually provision the infrastructure:
- Make sure you are in the right environment, example being:
cd environments/devshould put you in the dev environment directory. terraform init- This command will initialise a working directory containing Terraform configuration files with the required plugins mentioned.terraform validate- This command will validate the syntax in these configuration files in the working directory.terraform plan- This command will plan the infrastructure.terraform apply- Once everything has been checked and you are happy with the planned infrastructure, you can go ahead and apply the configuration with this command. Once prompted to approve the infrastructure, typeyesto proceed.- (OPTIONAL)
terraform destroy- When happy to remove the provisioned infrastructure, use this command. Like the previous command, when prompted typeyesto proceed.