This repository automates the provisioning and management of Azure infrastructure using Terraform. It leverages GitHub Actions workflows to enable continuous deployment and infrastructure as code (IaC) practices. The workflows in this repository allow you to apply Terraform configurations automatically when changes are pushed to the repository.
- Prerequisites
- Folder Structure
- Workflow Configuration
- Usage
- Terraform Best Practices
- Contributing
- License
Before using this repository, ensure you have the following prerequisites:
- Azure Subscription: You should have access to an Azure subscription where you can create and manage resources.
- Azure Service Principal: Create a service principal in Azure and obtain the necessary credentials (client ID, client secret, tenant ID). These will be used for authentication during Terraform deployments.
- GitHub Repository: Fork or clone this repository into your GitHub account.
- GitHub Secrets: Set up GitHub repository secrets to securely store your Azure service principal credentials. Refer to the Workflow Configuration section for details.
.github/workflows/
: Contains GitHub Actions workflow files.deploy/terraform/
: Contains Terraform configuration files and modules.README.md
: This README file.
GitHub Actions workflows are defined in the .github/workflows/
directory.
To securely store sensitive information, such as Azure service principal credentials, use GitHub repository secrets. The following secrets are required for the workflow:
AZURE_CREDENTIALS
: Azure service principal CREDENTIALS.AZURE_AD_CLIENT_SECRET
: Azure service principal client secret.
And store the following variables in Github > Settings > Secrets and Variables:
INFRA_SUBSCRIPTION_ID
: Azure service principal client secret.INFRA_AD_CLIENT_ID
: "your-client-id"INFRA_AD_TENANT_ID
: "your-tenant-id"
The workflow is triggered manually by selecting the environment from the dropdown. You can customize the trigger conditions in the workflow file to when changes are pushed to the main
branch
The workflow can be configured to deploy to one or more Azure environments (e.g., development, staging, production). Modify the workflow file to specify the deployment target.
-
Fork or clone this repository into your GitHub account.
-
Configure the GitHub repository secrets mentioned in the Workflow Configuration section.
-
Customize the Terraform configurations in the
terraform/
directory to match your infrastructure requirements. Update the variables and secrets. -
Commit and push your changes to the repository. GitHub Actions will trigger the Terraform deployment workflow based on your configured trigger conditions.
Follow Terraform best practices to maintain a clean and organized codebase:
- Organize your Terraform configurations into modules for reusability.
- Use version control to track changes to your infrastructure code.
- Avoid hardcoding sensitive credentials or secrets in your configurations.
- Document your configurations and provide clear README instructions.