The main purpose of this repository is for me to play around with Terraform. And I have created this repositories and others, so that I can get familiar with different providers available.
This project will focus on the Azure DevOps provider. This project will not be using Azurerm, a new repository using both providers will be done elsewhere.
- Azure CLI
- terraform,
- terragrunt,
- pre-commit,
- terraform-docs this is required for
terraform_docs
hooks.
- Have a Azure DevOps account.
- Create an organisation in Azure DevOps,
- Generate a personal access token (PAT) as per instructions here.
- Plan your changes with
terraform plan
to see what changes will be made, - If you're happy with the changes
terraform apply
Please note that .tfstate
files are stored locally on your machine as no backend has been specified. If you would like to properly version control your state files, it is possible to use an Blob Storage to store these files. This will ensure anyone else other than you running a plan/apply will always be using the same state file.
Git hook scripts are very helpful for identifying simple issues before pushing any changes. Hooks will run on every commit automatically pointing out issues in the code e.g. trailing whitespace.
To help with the maintenance of these hooks, pre-commit is used, along with pre-commit-hooks.
Please following these instructions to install pre-commit
locally and ensure that you have run pre-commit install
to install the hooks for this project.
Additionally, once installed, the hooks can be updated to the latest available version with pre-commit autoupdate
.
Code formatting and documentation for variables
and outputs
is generated using pre-commit-terraform hooks that in turn uses terraform-docs that will insert/update documentation. The following markers have been added to the README.md
:
<!-- {BEGINNING|END} OF PRE-COMMIT-TERRAFORM DOCS HOOK --->
Name | Version |
---|---|
terraform | >= 1.4.5 |
azuredevops | >= 0.8.0 |
Name | Version |
---|---|
azuredevops | 0.9.0 |
Name | Source | Version |
---|---|---|
git_repositories | git@github.com:kwame-mintah/terraform-azuredevops-git-repositories.git | 6c160e89185fef42a2f0c0a0518c9681aa58d06b |
Name | Description | Type | Default | Required |
---|---|---|---|---|
azurerm_spn_tenantid | The Tenant ID if the service principal. | string |
n/a | yes |
azurerm_subscription_id | The Subscription ID of the Azure targets. | string |
n/a | yes |
azurerm_subscription_name | The Subscription Name of the targets. | string |
n/a | yes |
init_git_repositories | Names of repositories to create in the project. | list(object({ |
n/a | yes |
organization_url | This is the Azure DevOps organization url. It can also be sourced from the AZDO_ORG_SERVICE_URL environment variable. |
string |
n/a | yes |
personal_access_token | This is the Azure DevOps organization personal access token. The account corresponding to the token will need "owner" privileges for this organization. It can also be sourced from the AZDO_PERSONAL_ACCESS_TOKEN environment variable. |
string |
n/a | yes |
project_name | Name of the project. | string |
n/a | yes |
Name | Description |
---|---|
git_repositories_repo_attr | Name for all git repositories within the project. |
project_id | The project id. |
project_name | The project name. |