Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add terraform files to create Azure DevOps project and repository #44

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tf-modules/azure/devops/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# DevOps Module

Configuration in this directory creates an Azure DevOps Project and repository.

## Usage

Legacy shared modules with their own provider configurations are not compatible
with new features like for_each, count and depends_on as described
[here](https://developer.hashicorp.com/terraform/language/modules/develop/providers#legacy-shared-modules-with-provider-configurations).
To use these features by passing provider configuration to the legacy module,
create version.tf file with the following content -

```hcl
terraform {
required_providers {
azuredevops = {
source = "microsoft/azuredevops"
}
}
}
```

In main.tf, create the provider configuration and pass it to the devops module.

```hcl
provider "azuredevops" {
org_service_url = "https://dev.azure.com/azuredevops_org"
personal_access_token = "azuredevops_pat"
}

module "devops" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/azure/devops"
providers = {
azuredevops = azuredevops
}
dipti-pai marked this conversation as resolved.
Show resolved Hide resolved

project_name = local.project_name
repository_name = local.repo_name
}
```
16 changes: 16 additions & 0 deletions tf-modules/azure/devops/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "azuredevops_project" "project" {
name = var.project_name
visibility = "private"
version_control = "Git"
work_item_template = "Agile"
description = var.project_description
}

resource "azuredevops_git_repository" "application" {
project_id = azuredevops_project.project.id
name = var.repository_name
default_branch = "refs/heads/main"
initialization {
init_type = "Clean"
}
}
9 changes: 9 additions & 0 deletions tf-modules/azure/devops/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "repo_url" {
description = "Azure Devops Git repository HTTPS url"
value = azuredevops_git_repository.application.remote_url
}

output "project_id" {
description = "Azure Devops Project ID"
value = azuredevops_project.project.id
}
15 changes: 15 additions & 0 deletions tf-modules/azure/devops/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "project_name" {
description = "The name of the Azure DevOps project"
type = string
}

variable "project_description" {
description = "The description of the Azure DevOps project"
type = string
default = "Test Project for Flux E2E test - Managed by Terraform"
}

variable "repository_name" {
description = "The name of the Azure DevOps repository"
type = string
}
8 changes: 8 additions & 0 deletions tf-modules/azure/devops/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
azuredevops = {
source = "microsoft/azuredevops"
version = ">= 1.2.0"
}
}
}