-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Terraform files to create ado project and repository
Signed-off-by: Dipti Pai <[email protected]>
- Loading branch information
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
project_name = local.project_name | ||
repository_name = local.repo_name | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |