/terraform-azuredevops

This my playground for learning Terraform using Azure DevOps as a provider. To create various resources within my own organisation.

Primary LanguageHCL

Terraform Azure DevOps

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.

Development

Dependencies

Prerequisites

  1. Have a Azure DevOps account.
  2. Create an organisation in Azure DevOps,
  3. Generate a personal access token (PAT) as per instructions here.

Usage

  1. Plan your changes with terraform plan to see what changes will be made,
  2. 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.

Pre-Commit hooks

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.

Documentation Generation

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 --->

Requirements

Name Version
terraform >= 1.4.5
azuredevops >= 0.8.0

Providers

Name Version
azuredevops 0.9.0

Modules

Name Source Version
git_repositories git@github.com:kwame-mintah/terraform-azuredevops-git-repositories.git 6c160e89185fef42a2f0c0a0518c9681aa58d06b

Resources

Name Type
azuredevops_agent_pool.raspberrypi_agent_automation_pool resource
azuredevops_agent_pool.raspberrypi_agent_deployment_pool resource
azuredevops_agent_queue.raspberrypi_agent_automation_queue resource
azuredevops_environment.development_environment resource
azuredevops_environment.production_environment resource
azuredevops_environment.staging_environment resource
azuredevops_environment.testing_environment resource
azuredevops_pipeline_authorization.project_agent_queue_authorization resource
azuredevops_project.project resource
azuredevops_project_pipeline_settings.pipeline resource
azuredevops_serviceendpoint_azurerm.auto_azurem_service resource

Inputs

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({
name = string
default_branch = string
source_type = string
source_url = string
init_type = string
}))
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

Outputs

Name Description
git_repositories_repo_attr Name for all git repositories within the
project.
project_id The project id.
project_name The project name.