This repository contains Azure Infrastructure as Code (IaC) modules and GitHub Actions workflows to manage Azure resources efficiently. The initial setup includes workflows for creating and managing resource groups, deploying modules, and deleting resources, with a sample module for deploying a storage account.
There are two ways to deploy resources:
- Deploy by configuring yoru own environment file in environments/, and then deploy it to the appropriate workflow
- Create a resource group from the Actions tab, and then deploy module(s) to your environment
infra-repo/
├── .github/
│ ├── workflows/
│ │ ├── create-resource-group.yml # Creates a new resource group
│ │ ├── deploy-modules.yml # Deploys modules to a resource group (rg)
│ │ ├── deploy-env.yml # Deploy a complete environment configuration to a env-named rg (dev, stag, prod, etc.)
│ │ ├── delete-resource-group.yml # Deletes a resource group
│ │ ├── delete-modules.yml # Deletes specific resources from a group
├── modules/
│ ├── storage-account/
│ │ ├── main.bicep # Storage account Bicep template
│ │ ├── variables.bicep # Variables for storage account
│ │ ├── outputs.bicep # Outputs for the storage account
├── README.md
Creates a new resource group in Azure.
- Workflow File:
.github/workflows/create-resource-group.yml
- Trigger: Manual (
workflow_dispatch
) - Inputs:
resource_group_name
: Name of the resource group.location
: Azure region (default:eastus
).
Deploys specified modules (e.g., a storage account) to a resource group.
- Workflow File:
.github/workflows/deploy-modules.yml
- Trigger: Manual (
workflow_dispatch
) - Inputs:
resource_group_name
: Name of the resource group.storage_account_name
: Name of the storage account to create.location
: Azure region (default:eastus
).
Deletes a specified resource group and all its resources.
- Workflow File:
.github/workflows/delete-resource-group.yml
- Trigger: Manual (
workflow_dispatch
) - Inputs:
resource_group_name
: Name of the resource group to delete.
Deletes specific resources (modules) from a resource group without deleting the group.
- Workflow File:
.github/workflows/delete-modules.yml
- Trigger: Manual (
workflow_dispatch
) - Inputs:
resource_group_name
: Name of the resource group.module_resource_name
: Name of the module/resource to delete.
A sample Bicep module to deploy an Azure Storage Account.
- Location:
modules/storage-account/
- Files:
main.bicep
: Core logic for the storage account deployment.variables.bicep
: Variables for configuration.outputs.bicep
: Outputs resource details.
- Azure CLI: Ensure Azure CLI is installed and available in your GitHub Actions runner.
- Azure Credentials: Add Azure credentials to your repository's secrets:
- Go to
Settings > Secrets > Actions > New Repository Secret
. - Add a secret named
AZURE_CREDENTIALS
with the JSON output ofaz ad sp create-for-rbac
.
- Go to
For more instructions on setting up Azure from scratch, go to ldraney/az-trial-docs
-
Clone the repository:
git clone <repo-url> cd infra-repo
-
Use the workflows:
- Go to the GitHub repository's "Actions" tab.
- Choose a workflow (e.g.,
Create Resource Group
) and trigger it manually with the required inputs.
-
Manage the modules:
- Modify the Bicep files under
modules/
to add new resources. - Update workflows to include new modules as needed.
- Modify the Bicep files under
- Add support for additional Azure resources.
- Implement automated testing for Bicep templates.
- Configure cost management and monitoring.
This project is licensed under the MIT License.