This repository is dedicated to Infrastructure as Code (IaC) using Terraform for managing an Azure Subscription and its resources.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You will need to have Terraform installed on your machine. Here's how to do it on Windows, Linux, and MacOS:
- Download the Terraform zip file from the Terraform downloads page.
- Extract the contents of the zip file to a location of your choice, e.g.,
C:\terraform
. - Add the path where you extracted the Terraform binary to your system's PATH environment variable.
- Download the Terraform zip file from the Terraform downloads page.
- Extract the contents of the zip file with
unzip
, e.g.,unzip terraform_0.12.0_linux_amd64.zip
. - Move the Terraform binary to a location on your PATH, e.g.,
sudo mv terraform /usr/local/bin/
.
- Download the Terraform zip file from the Terraform downloads page.
- Extract the contents of the zip file with
unzip
, e.g.,unzip terraform_0.12.0_darwin_amd64.zip
. - Move the Terraform binary to a location on your PATH, e.g.,
sudo mv terraform /usr/local/bin/
.
To use Azure CLI, follow these steps:
- Install Azure CLI by following the instructions on the Azure CLI documentation.
- Open a terminal or command prompt.
- Run the
az login
command to sign in to your Azure account. Follow the prompts to complete the login process.
Once you have logged in using Azure CLI, you can manage your Azure resources using the command-line interface.
Ensure you have npm
installed and available locally. Once you clone the repository run npm install
and the Git Hooks from Husky should automatically be applied to you.
Run terraform init
after you are done logging into Azure to have terraform scaffold the state locally.
- After changing files run
terraform fmt
to format files - Use
terraform plan
to dry-run and see what changes would be applied - Finally, if everything looks fine, run
terraform apply
and review the changes before typingyes
for changes to be applied in Azure.
You'll need to have the following secrets created in your GitHub repo for an environment named production
for remote changes to be applied:
secrets.AZURE_CLIENT_ID
secrets.AZURE_CLIENT_SECRET
secrets.AZURE_TENANT_ID
secrets.AZURE_SUBSCRIPTION_ID
Those values may be created by following the tutorials on connecting to azure with openid connect.
This repository uses Azure CLI login instead of the ARM
service providers for simplicity when running locally but uses ARM on the pipeline.
This project uses GitHub Actions as a continuous integration (CI) system. The configuration for these actions is located in the .github/workflows
directory. There are two main workflows:
This workflow is triggered whenever a new pull request is opened or updated. It's responsible for validating the changes proposed in the pull request. This validation can include tasks such as checking the code format, running unit tests, and any other checks that help ensure the quality of the code.
This workflow is triggered when changes are merged into the main branch. It's responsible for deploying the changes to the production environment. The deployment process will typically involve tasks such as building the project, running any necessary migrations, and updating the live application.
These workflows automate the process of validating new code and deploying changes, helping to ensure that the codebase remains stable and that new features and fixes are promptly delivered.